website cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { ProtestDTO } from '../types/generated/ProtestDTO';
|
||||
import { RaceProtestDTO } from '../types/generated/RaceProtestDTO';
|
||||
|
||||
/**
|
||||
* Protest view model
|
||||
@@ -11,22 +12,49 @@ export class ProtestViewModel {
|
||||
accusedDriverId: string;
|
||||
description: string;
|
||||
submittedAt: string;
|
||||
filedAt?: string;
|
||||
status: string;
|
||||
reviewedAt?: string;
|
||||
decisionNotes?: string;
|
||||
incident?: { lap?: number } | null;
|
||||
incident?: { lap?: number; description?: string } | null;
|
||||
proofVideoUrl?: string | null;
|
||||
comment?: string | null;
|
||||
|
||||
constructor(dto: ProtestDTO) {
|
||||
constructor(dto: ProtestDTO | RaceProtestDTO) {
|
||||
this.id = dto.id;
|
||||
this.raceId = dto.raceId;
|
||||
this.raceId = (dto as any).raceId || '';
|
||||
this.protestingDriverId = dto.protestingDriverId;
|
||||
this.accusedDriverId = dto.accusedDriverId;
|
||||
this.description = dto.description;
|
||||
this.submittedAt = dto.submittedAt;
|
||||
this.description = (dto as any).description || dto.description;
|
||||
this.submittedAt = (dto as any).submittedAt || (dto as any).filedAt || '';
|
||||
this.filedAt = (dto as any).filedAt || (dto as any).submittedAt;
|
||||
|
||||
// Handle different DTO structures
|
||||
if ('status' in dto) {
|
||||
this.status = dto.status;
|
||||
} else {
|
||||
this.status = 'pending';
|
||||
}
|
||||
|
||||
// Handle incident data
|
||||
if ('incident' in dto && dto.incident) {
|
||||
this.incident = {
|
||||
lap: (dto.incident as any).lap,
|
||||
description: (dto.incident as any).description
|
||||
};
|
||||
} else if ('lap' in dto || 'description' in dto) {
|
||||
this.incident = {
|
||||
lap: (dto as any).lap,
|
||||
description: (dto as any).description
|
||||
};
|
||||
} else {
|
||||
this.incident = null;
|
||||
}
|
||||
|
||||
// Status and decision metadata are not part of the protest DTO in this build; they default to a pending, unreviewed protest
|
||||
this.status = 'pending';
|
||||
if (!('status' in dto)) {
|
||||
this.status = 'pending';
|
||||
}
|
||||
this.reviewedAt = undefined;
|
||||
this.decisionNotes = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user