view data fixes
This commit is contained in:
@@ -1,22 +1,32 @@
|
||||
import { CreateLeagueOutputDTO } from '@/lib/types/generated/CreateLeagueOutputDTO';
|
||||
import type { CreateLeagueViewData } from '../view-data/CreateLeagueViewData';
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import { LeagueCreationStatusDisplay } from '../display-objects/LeagueCreationStatusDisplay';
|
||||
|
||||
/**
|
||||
* View Model for Create League Result
|
||||
*
|
||||
* Represents the result of creating a league in a UI-ready format.
|
||||
* Composes Display Objects and transforms ViewData for UI consumption.
|
||||
*/
|
||||
export class CreateLeagueViewModel {
|
||||
leagueId: string;
|
||||
success: boolean;
|
||||
export class CreateLeagueViewModel extends ViewModel {
|
||||
readonly leagueId: string;
|
||||
readonly success: boolean;
|
||||
|
||||
constructor(dto: CreateLeagueOutputDTO) {
|
||||
this.leagueId = dto.leagueId;
|
||||
this.success = dto.success;
|
||||
// UI-specific derived fields (primitive outputs only)
|
||||
readonly successMessage: string;
|
||||
|
||||
constructor(viewData: CreateLeagueViewData) {
|
||||
super();
|
||||
this.leagueId = viewData.leagueId;
|
||||
this.success = viewData.success;
|
||||
|
||||
// Derive UI-specific fields using Display Object
|
||||
this.successMessage = LeagueCreationStatusDisplay.statusMessage(this.success);
|
||||
}
|
||||
|
||||
/** UI-specific: Success message */
|
||||
get successMessage(): string {
|
||||
return this.success ? 'League created successfully!' : 'Failed to create league.';
|
||||
/** UI-specific: Whether league creation was successful */
|
||||
get isSuccessful(): boolean {
|
||||
return this.success;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user