65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import { ProtestDetailViewData } from "../view-data/ProtestDetailViewData";
|
|
import { ProtestDriverViewModel } from './ProtestDriverViewModel';
|
|
import { ProtestViewModel } from './ProtestViewModel';
|
|
import { RaceViewModel } from './RaceViewModel';
|
|
|
|
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
|
|
export type PenaltyTypeOptionViewModel = ViewModel & {
|
|
type: string;
|
|
label: string;
|
|
description: string;
|
|
requiresValue: boolean;
|
|
valueLabel: string;
|
|
defaultValue: 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,
|
|
}));
|
|
}
|
|
} |