view data fixes

This commit is contained in:
2026-01-23 15:30:23 +01:00
parent e22033be38
commit f8099f04bc
213 changed files with 3466 additions and 3003 deletions

View File

@@ -1,75 +1,20 @@
// DTO interfaces matching the API responses
interface RaceDetailDTO {
race: {
id: string;
track: string;
scheduledAt: string;
status: string;
} | null;
league: {
id: string;
name: string;
} | null;
}
interface RaceProtestsDTO {
protests: Array<{
id: string;
protestingDriverId: string;
accusedDriverId: string;
incident: {
lap: number;
description: string;
};
filedAt: string;
status: string;
decisionNotes?: string;
proofVideoUrl?: string;
}>;
driverMap: Record<string, { id: string; name: string }>;
}
interface RacePenaltiesDTO {
penalties: Array<{
id: string;
driverId: string;
type: string;
value: number;
reason: string;
notes?: string;
}>;
driverMap: Record<string, { id: string; name: string }>;
}
interface RaceStewardingDTO {
raceDetail: RaceDetailDTO;
protests: RaceProtestsDTO;
penalties: RacePenaltiesDTO;
}
/**
* Race Stewarding View Model
* Represents all data needed for race stewarding (protests, penalties, race info)
*/
import { ViewModel } from "../contracts/view-models/ViewModel";
import type { RaceStewardingViewData } from "../view-data/RaceStewardingViewData";
export class RaceStewardingViewModel extends ViewModel {
race: RaceDetailDTO['race'];
league: RaceDetailDTO['league'];
protests: RaceProtestsDTO['protests'];
penalties: RacePenaltiesDTO['penalties'];
driverMap: Record<string, { id: string; name: string }>;
private readonly data: RaceStewardingViewData;
constructor(dto: RaceStewardingDTO) {
this.race = dto.raceDetail.race;
this.league = dto.raceDetail.league;
this.protests = dto.protests.protests;
this.penalties = dto.penalties.penalties;
// Merge driver maps from protests and penalties
this.driverMap = { ...dto.protests.driverMap, ...dto.penalties.driverMap };
constructor(data: RaceStewardingViewData) {
super();
this.data = data;
}
get race() { return this.data.race; }
get league() { return this.data.league; }
get protests() { return this.data.protests; }
get penalties() { return this.data.penalties; }
get driverMap() { return this.data.driverMap; }
/** UI-specific: Pending protests */
get pendingProtests() {
return this.protests.filter(p => p.status === 'pending' || p.status === 'under_review');