website cleanup
This commit is contained in:
@@ -1,20 +1,10 @@
|
||||
import { RaceListItemViewModel } from './RaceListItemViewModel';
|
||||
import type { RacesPageDataRaceDTO } from '../types/generated/RacesPageDataRaceDTO';
|
||||
import type { RaceListItemDTO } from './RaceListItemViewModel';
|
||||
|
||||
// DTO matching the backend RacesPageDataDTO
|
||||
interface RacesPageDTO {
|
||||
races: Array<{
|
||||
id: string;
|
||||
track: string;
|
||||
car: string;
|
||||
scheduledAt: string;
|
||||
status: string;
|
||||
leagueId: string;
|
||||
leagueName: string;
|
||||
strengthOfField: number | null;
|
||||
isUpcoming: boolean;
|
||||
isLive: boolean;
|
||||
isPast: boolean;
|
||||
}>;
|
||||
races: RacesPageDataRaceDTO[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,7 +15,17 @@ export class RacesPageViewModel {
|
||||
races: RaceListItemViewModel[];
|
||||
|
||||
constructor(dto: RacesPageDTO) {
|
||||
this.races = dto.races.map(r => new RaceListItemViewModel(r));
|
||||
this.races = dto.races.map((r) => {
|
||||
const normalized: RaceListItemDTO = {
|
||||
...r,
|
||||
strengthOfField: (r as any).strengthOfField ?? null,
|
||||
isUpcoming: r.isUpcoming,
|
||||
isLive: r.isLive,
|
||||
isPast: r.isPast,
|
||||
};
|
||||
|
||||
return new RaceListItemViewModel(normalized);
|
||||
});
|
||||
}
|
||||
|
||||
/** UI-specific: Total races */
|
||||
@@ -62,4 +62,4 @@ export class RacesPageViewModel {
|
||||
get completedRaces(): RaceListItemViewModel[] {
|
||||
return this.races.filter(r => r.status === 'completed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user