api client refactor
This commit is contained in:
34
apps/website/lib/view-models/PrizeViewModel.ts
Normal file
34
apps/website/lib/view-models/PrizeViewModel.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user