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,16 +1,26 @@
import { PrizeDto } from '../dtos';
import { PrizeDto } from '../types/generated/PrizeDto';
export class PrizeViewModel implements PrizeDto {
id: string;
leagueId: string;
seasonId: string;
position: number;
name: string;
amount: number;
currency: string;
position?: number;
constructor(dto: PrizeDto) {
Object.assign(this, dto);
this.id = dto.id;
this.leagueId = dto.leagueId;
this.seasonId = dto.seasonId;
this.position = dto.position;
this.name = dto.name;
this.amount = dto.amount;
}
// Note: The generated DTO doesn't have currency
// This will need to be added when the OpenAPI spec is updated
currency: string = 'USD';
/** UI-specific: Formatted amount */
get formattedAmount(): string {
return `${this.currency} ${this.amount.toFixed(2)}`;
@@ -18,7 +28,6 @@ export class PrizeViewModel implements PrizeDto {
/** UI-specific: Position display */
get positionDisplay(): string {
if (!this.position) return 'Special';
switch (this.position) {
case 1: return '1st Place';
case 2: return '2nd Place';