import { ViewModel } from "../contracts/view-models/ViewModel"; import { CurrencyFormatter } from "../formatters/CurrencyFormatter"; import { DateFormatter } from "../formatters/DateFormatter"; import { FinishFormatter } from "../formatters/FinishFormatter"; import { PrizeTypeFormatter } from "../formatters/PrizeTypeFormatter"; import type { PrizeViewData } from "../view-data/PrizeViewData"; export class PrizeViewModel extends ViewModel { private readonly data: PrizeViewData; constructor(data: PrizeViewData) { super(); this.data = data; } get id(): string { return this.data.id; } get leagueId(): string { return this.data.leagueId; } get seasonId(): string { return this.data.seasonId; } get position(): number { return this.data.position; } get name(): string { return this.data.name; } get amount(): number { return this.data.amount; } get type(): string { return this.data.type; } get description(): string | undefined { return this.data.description; } get awarded(): boolean { return this.data.awarded; } get awardedTo(): string | undefined { return this.data.awardedTo; } get awardedAt(): string | undefined { return this.data.awardedAt; } get createdAt(): string { return this.data.createdAt; } /** UI-specific: Formatted amount */ get formattedAmount(): string { return CurrencyFormatter.format(this.amount, 'EUR'); } /** UI-specific: Position display */ get positionDisplay(): string { return FinishFormatter.format(this.position); } /** UI-specific: Type display */ get typeDisplay(): string { return PrizeTypeFormatter.format(this.type); } /** UI-specific: Status display */ get statusDisplay(): string { return this.awarded ? 'Awarded' : 'Available'; } /** UI-specific: Status color */ get statusColor(): string { return this.awarded ? 'green' : 'blue'; } /** UI-specific: Prize description */ get prizeDescription(): string { return `${this.name} - ${this.formattedAmount}`; } /** UI-specific: Formatted awarded date */ get formattedAwardedAt(): string { return this.awardedAt ? DateFormatter.formatShort(this.awardedAt) : 'Not awarded'; } /** UI-specific: Formatted created date */ get formattedCreatedAt(): string { return DateFormatter.formatShort(this.createdAt); } }