view models
This commit is contained in:
@@ -1,12 +1,63 @@
|
||||
export interface RaceCardViewModel {
|
||||
// Note: No generated DTO available for RaceCard yet
|
||||
interface RaceCardDTO {
|
||||
id: string;
|
||||
title: string;
|
||||
scheduledTime: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface RacesPageViewModel {
|
||||
/**
|
||||
* Race card view model
|
||||
* Represents a race card in list views
|
||||
*/
|
||||
export class RaceCardViewModel {
|
||||
id: string;
|
||||
title: string;
|
||||
scheduledTime: string;
|
||||
status: string;
|
||||
|
||||
constructor(dto: RaceCardDTO) {
|
||||
this.id = dto.id;
|
||||
this.title = dto.title;
|
||||
this.scheduledTime = dto.scheduledTime;
|
||||
this.status = dto.status;
|
||||
}
|
||||
|
||||
/** UI-specific: Formatted scheduled time */
|
||||
get formattedScheduledTime(): string {
|
||||
return new Date(this.scheduledTime).toLocaleString();
|
||||
}
|
||||
}
|
||||
|
||||
// Note: No generated DTO available for RacesPage yet
|
||||
interface RacesPageDTO {
|
||||
upcomingRaces: RaceCardDTO[];
|
||||
completedRaces: RaceCardDTO[];
|
||||
totalCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Races page view model
|
||||
* Represents the races page data
|
||||
*/
|
||||
export class RacesPageViewModel {
|
||||
upcomingRaces: RaceCardViewModel[];
|
||||
completedRaces: RaceCardViewModel[];
|
||||
totalCount: number;
|
||||
|
||||
constructor(dto: RacesPageDTO) {
|
||||
this.upcomingRaces = dto.upcomingRaces.map(r => new RaceCardViewModel(r));
|
||||
this.completedRaces = dto.completedRaces.map(r => new RaceCardViewModel(r));
|
||||
this.totalCount = dto.totalCount;
|
||||
}
|
||||
|
||||
/** UI-specific: Total upcoming races */
|
||||
get upcomingCount(): number {
|
||||
return this.upcomingRaces.length;
|
||||
}
|
||||
|
||||
/** UI-specific: Total completed races */
|
||||
get completedCount(): number {
|
||||
return this.completedRaces.length;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user