view data fixes
This commit is contained in:
@@ -1,33 +1,5 @@
|
||||
import { ProtestDetailViewData } from '@/lib/view-data/ProtestDetailViewData';
|
||||
|
||||
interface ProtestDetailApiDto {
|
||||
id: string;
|
||||
leagueId: string;
|
||||
status: string;
|
||||
submittedAt: string;
|
||||
incident: {
|
||||
lap: number;
|
||||
description: string;
|
||||
};
|
||||
protestingDriver: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
accusedDriver: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
race: {
|
||||
id: string;
|
||||
name: string;
|
||||
scheduledAt: string;
|
||||
};
|
||||
penaltyTypes: Array<{
|
||||
type: string;
|
||||
label: string;
|
||||
description: string;
|
||||
}>;
|
||||
}
|
||||
import type { RaceProtestDTO } from '@/lib/types/generated/RaceProtestDTO';
|
||||
import type { ProtestDetailViewData } from '@/lib/view-data/ProtestDetailViewData';
|
||||
|
||||
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
||||
|
||||
@@ -36,18 +8,20 @@ export class ProtestDetailViewDataBuilder implements ViewDataBuilder<any, any> {
|
||||
return ProtestDetailViewDataBuilder.build(input);
|
||||
}
|
||||
|
||||
static build(
|
||||
static build(apiDto: ProtestDetailApiDto): ProtestDetailViewData {
|
||||
static build(apiDto: RaceProtestDTO): ProtestDetailViewData {
|
||||
return {
|
||||
protestId: apiDto.id,
|
||||
leagueId: apiDto.leagueId,
|
||||
leagueId: (apiDto as any).leagueId || '',
|
||||
status: apiDto.status,
|
||||
submittedAt: apiDto.submittedAt,
|
||||
incident: apiDto.incident,
|
||||
protestingDriver: apiDto.protestingDriver,
|
||||
accusedDriver: apiDto.accusedDriver,
|
||||
race: apiDto.race,
|
||||
penaltyTypes: apiDto.penaltyTypes,
|
||||
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 || [],
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user