view data fixes
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 6m4s
Contract Testing / contract-snapshot (pull_request) Has been skipped

This commit is contained in:
2026-01-23 11:59:49 +01:00
parent ae58839eb2
commit d97f50ed72
191 changed files with 2889 additions and 1019 deletions

View File

@@ -1,8 +1,11 @@
import { ProtestDriverViewModel } from './ProtestDriverViewModel';
import { ProtestViewModel } from './ProtestViewModel';
import { RaceViewModel } from './RaceViewModel';
import { ProtestDetailViewData } from "../view-data/ProtestDetailViewData";
export type PenaltyTypeOptionViewModel = {
import { ViewModel } from "../contracts/view-models/ViewModel";
export type PenaltyTypeOptionViewModel = ViewModel & {
type: string;
label: string;
description: string;
@@ -11,16 +14,52 @@ export type PenaltyTypeOptionViewModel = {
defaultValue: number;
};
export type ProtestDetailViewModel = {
protest: ProtestViewModel;
race: RaceViewModel;
protestingDriver: ProtestDriverViewModel;
accusedDriver: ProtestDriverViewModel;
penaltyTypes: PenaltyTypeOptionViewModel[];
defaultReasons: {
upheld: string;
dismissed: string;
};
initialPenaltyType: string | null;
initialPenaltyValue: number;
};
export class ProtestDetailViewModel extends ViewModel {
constructor(private readonly viewData: ProtestDetailViewData) {
super();
}
get protest(): ProtestViewModel {
return new ProtestViewModel({
id: this.viewData.protestId,
status: this.viewData.status,
submittedAt: this.viewData.submittedAt,
incident: this.viewData.incident,
protestingDriverId: this.viewData.protestingDriver.id,
accusedDriverId: this.viewData.accusedDriver.id,
} as any);
}
get race(): RaceViewModel {
return new RaceViewModel({
id: this.viewData.race.id,
name: this.viewData.race.name,
scheduledAt: this.viewData.race.scheduledAt,
} as any);
}
get protestingDriver(): ProtestDriverViewModel {
return new ProtestDriverViewModel({
id: this.viewData.protestingDriver.id,
name: this.viewData.protestingDriver.name,
});
}
get accusedDriver(): ProtestDriverViewModel {
return new ProtestDriverViewModel({
id: this.viewData.accusedDriver.id,
name: this.viewData.accusedDriver.name,
});
}
get penaltyTypes(): PenaltyTypeOptionViewModel[] {
return this.viewData.penaltyTypes.map((pt) => ({
type: pt.type,
label: pt.label,
description: pt.description,
requiresValue: false,
valueLabel: '',
defaultValue: 0,
}));
}
}