website refactor

This commit is contained in:
2026-01-12 01:01:49 +01:00
parent 5ca6023a5a
commit fefd8d1cd6
294 changed files with 4628 additions and 4991 deletions

View File

@@ -1,6 +1,5 @@
import { RaceListItemViewModel } from './RaceListItemViewModel';
import type { RacesPageDataRaceDTO } from '../types/generated/RacesPageDataRaceDTO';
import type { RaceListItemDTO } from './RaceListItemViewModel';
import type { RacesPageDataRaceDTO } from '@/lib/types/generated/RacesPageDataRaceDTO';
// DTO matching the backend RacesPageDataDTO
interface RacesPageDTO {
@@ -16,23 +15,33 @@ export class RacesPageViewModel {
constructor(dto: RacesPageDTO) {
this.races = dto.races.map((r) => {
const status = (r as any).status as string | undefined;
const status = 'status' in r ? r.status : 'unknown';
const isUpcoming =
(r as any).isUpcoming ??
'isUpcoming' in r ? r.isUpcoming :
(status === 'upcoming' || status === 'scheduled');
const isLive =
(r as any).isLive ??
'isLive' in r ? r.isLive :
(status === 'live' || status === 'running');
const isPast =
(r as any).isPast ??
'isPast' in r ? r.isPast :
(status === 'completed' || status === 'finished' || status === 'cancelled');
const normalized: RaceListItemDTO = {
...(r as any),
strengthOfField: (r as any).strengthOfField ?? null,
// Build the RaceListItemDTO from the input with proper type checking
const scheduledAt = 'scheduledAt' in r ? r.scheduledAt :
('date' in r ? (r as { date?: string }).date : '');
const normalized = {
id: r.id,
track: 'track' in r ? r.track : '',
car: 'car' in r ? r.car : '',
scheduledAt: scheduledAt || '',
status: status,
leagueId: 'leagueId' in r ? r.leagueId : '',
leagueName: 'leagueName' in r ? r.leagueName : '',
strengthOfField: 'strengthOfField' in r ? (r as { strengthOfField?: number }).strengthOfField ?? null : null,
isUpcoming: Boolean(isUpcoming),
isLive: Boolean(isLive),
isPast: Boolean(isPast),
@@ -76,4 +85,4 @@ export class RacesPageViewModel {
get completedRaces(): RaceListItemViewModel[] {
return this.races.filter(r => r.status === 'completed');
}
}
}