34 lines
818 B
TypeScript
34 lines
818 B
TypeScript
import { PrizeDto } from '../dtos';
|
|
|
|
export class PrizeViewModel implements PrizeDto {
|
|
id: string;
|
|
name: string;
|
|
amount: number;
|
|
currency: string;
|
|
position?: number;
|
|
|
|
constructor(dto: PrizeDto) {
|
|
Object.assign(this, dto);
|
|
}
|
|
|
|
/** UI-specific: Formatted amount */
|
|
get formattedAmount(): string {
|
|
return `${this.currency} ${this.amount.toFixed(2)}`;
|
|
}
|
|
|
|
/** 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';
|
|
case 3: return '3rd Place';
|
|
default: return `${this.position}th Place`;
|
|
}
|
|
}
|
|
|
|
/** UI-specific: Prize description */
|
|
get prizeDescription(): string {
|
|
return `${this.name} - ${this.formattedAmount}`;
|
|
}
|
|
} |