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