Files
gridpilot.gg/apps/website/lib/view-models/RacesPageViewModel.ts
2025-12-18 00:08:47 +01:00

63 lines
1.5 KiB
TypeScript

// Note: No generated DTO available for RaceCard yet
interface RaceCardDTO {
id: string;
title: string;
scheduledTime: string;
status: string;
}
/**
* 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;
}
}