view models
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user