fix issues
This commit is contained in:
@@ -16,12 +16,26 @@ export class RacesPageViewModel {
|
||||
|
||||
constructor(dto: RacesPageDTO) {
|
||||
this.races = dto.races.map((r) => {
|
||||
const status = (r as any).status as string | undefined;
|
||||
|
||||
const isUpcoming =
|
||||
(r as any).isUpcoming ??
|
||||
(status === 'upcoming' || status === 'scheduled');
|
||||
|
||||
const isLive =
|
||||
(r as any).isLive ??
|
||||
(status === 'live' || status === 'running');
|
||||
|
||||
const isPast =
|
||||
(r as any).isPast ??
|
||||
(status === 'completed' || status === 'finished' || status === 'cancelled');
|
||||
|
||||
const normalized: RaceListItemDTO = {
|
||||
...r,
|
||||
...(r as any),
|
||||
strengthOfField: (r as any).strengthOfField ?? null,
|
||||
isUpcoming: r.isUpcoming,
|
||||
isLive: r.isLive,
|
||||
isPast: r.isPast,
|
||||
isUpcoming: Boolean(isUpcoming),
|
||||
isLive: Boolean(isLive),
|
||||
isPast: Boolean(isPast),
|
||||
};
|
||||
|
||||
return new RaceListItemViewModel(normalized);
|
||||
|
||||
Reference in New Issue
Block a user