view models

This commit is contained in:
2025-12-18 00:08:47 +01:00
parent f7a56a92ce
commit 7c449af311
56 changed files with 2594 additions and 206 deletions

View File

@@ -1,8 +1,10 @@
import { ProtestDTO } from '../types/generated/ProtestDTO';
/**
* Protest view model
* Represents a race protest
*/
export interface ProtestViewModel {
export class ProtestViewModel implements ProtestDTO {
id: string;
raceId: string;
complainantId: string;
@@ -10,4 +12,24 @@ export interface ProtestViewModel {
description: string;
status: string;
createdAt: string;
constructor(dto: ProtestDTO) {
this.id = dto.id;
this.raceId = dto.raceId;
this.complainantId = dto.complainantId;
this.defendantId = dto.defendantId;
this.description = dto.description;
this.status = dto.status;
this.createdAt = dto.createdAt;
}
/** UI-specific: Formatted created date */
get formattedCreatedAt(): string {
return new Date(this.createdAt).toLocaleString();
}
/** UI-specific: Status display */
get statusDisplay(): string {
return this.status.charAt(0).toUpperCase() + this.status.slice(1);
}
}