import { ViewModel } from "../contracts/view-models/ViewModel"; import { CurrencyFormatter } from "../formatters/CurrencyFormatter"; import { DateFormatter } from "../formatters/DateFormatter"; import { PayerTypeFormatter } from "../formatters/PayerTypeFormatter"; import { PaymentTypeFormatter } from "../formatters/PaymentTypeFormatter"; import { StatusFormatter } from "../formatters/StatusFormatter"; import type { PaymentViewData } from "../view-data/PaymentViewData"; export class PaymentViewModel extends ViewModel { private readonly data: PaymentViewData; constructor(data: PaymentViewData) { super(); this.data = data; } get id(): string { return this.data.id; } get type(): string { return this.data.type; } get amount(): number { return this.data.amount; } get platformFee(): number { return this.data.platformFee; } get netAmount(): number { return this.data.netAmount; } get payerId(): string { return this.data.payerId; } get payerType(): string { return this.data.payerType; } get leagueId(): string { return this.data.leagueId; } get seasonId(): string | undefined { return this.data.seasonId; } get status(): string { return this.data.status; } get createdAt(): string { return this.data.createdAt; } get completedAt(): string | undefined { return this.data.completedAt; } /** UI-specific: Formatted amount */ get formattedAmount(): string { return CurrencyFormatter.format(this.amount, 'EUR'); } /** UI-specific: Formatted net amount */ get formattedNetAmount(): string { return CurrencyFormatter.format(this.netAmount, 'EUR'); } /** UI-specific: Status color */ get statusColor(): string { switch (this.status) { case 'completed': return 'green'; case 'pending': return 'yellow'; case 'failed': return 'red'; case 'refunded': return 'orange'; default: return 'gray'; } } /** UI-specific: Formatted created date */ get formattedCreatedAt(): string { return DateFormatter.formatShort(this.createdAt); } /** UI-specific: Formatted completed date */ get formattedCompletedAt(): string { return this.completedAt ? DateFormatter.formatShort(this.completedAt) : 'Not completed'; } /** UI-specific: Status display */ get statusDisplay(): string { return StatusFormatter.transactionStatus(this.status); } /** UI-specific: Type display */ get typeDisplay(): string { return PaymentTypeFormatter.format(this.type); } /** UI-specific: Payer type display */ get payerTypeDisplay(): string { return PayerTypeFormatter.format(this.payerType); } }