27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import type { RaceProtestDTO } from '@/lib/types/generated/RaceProtestDTO';
|
|
import type { ProtestDetailViewData } from '@/lib/view-data/ProtestDetailViewData';
|
|
|
|
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
|
|
|
export class ProtestDetailViewDataBuilder implements ViewDataBuilder<any, any> {
|
|
build(input: any): any {
|
|
return ProtestDetailViewDataBuilder.build(input);
|
|
}
|
|
|
|
static build(apiDto: RaceProtestDTO): ProtestDetailViewData {
|
|
return {
|
|
protestId: apiDto.id,
|
|
leagueId: (apiDto as any).leagueId || '',
|
|
status: apiDto.status,
|
|
submittedAt: (apiDto as any).submittedAt || apiDto.filedAt,
|
|
incident: {
|
|
lap: (apiDto.incident as any)?.lap || 0,
|
|
description: (apiDto.incident as any)?.description || '',
|
|
},
|
|
protestingDriver: (apiDto as any).protestingDriver || { id: apiDto.protestingDriverId, name: 'Unknown' },
|
|
accusedDriver: (apiDto as any).accusedDriver || { id: apiDto.accusedDriverId, name: 'Unknown' },
|
|
race: (apiDto as any).race || { id: '', name: '', scheduledAt: '' },
|
|
penaltyTypes: (apiDto as any).penaltyTypes || [],
|
|
};
|
|
}
|
|
} |