view data fixes
This commit is contained in:
@@ -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,
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user