43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { PrizeDto } from '../types/generated/PrizeDto';
|
|
|
|
export class PrizeViewModel implements PrizeDto {
|
|
id: string;
|
|
leagueId: string;
|
|
seasonId: string;
|
|
position: number;
|
|
name: string;
|
|
amount: number;
|
|
|
|
constructor(dto: PrizeDto) {
|
|
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)}`;
|
|
}
|
|
|
|
/** UI-specific: Position display */
|
|
get positionDisplay(): string {
|
|
switch (this.position) {
|
|
case 1: return '1st Place';
|
|
case 2: return '2nd Place';
|
|
case 3: return '3rd Place';
|
|
default: return `${this.position}th Place`;
|
|
}
|
|
}
|
|
|
|
/** UI-specific: Prize description */
|
|
get prizeDescription(): string {
|
|
return `${this.name} - ${this.formattedAmount}`;
|
|
}
|
|
} |