import { ViewModel } from "../contracts/view-models/ViewModel"; import { CurrencyFormatter } from "../formatters/CurrencyFormatter"; import type { LeagueWalletViewData } from "../view-data/LeagueWalletViewData"; import { WalletTransactionViewModel } from './WalletTransactionViewModel'; export class LeagueWalletViewModel extends ViewModel { private readonly data: LeagueWalletViewData; readonly transactions: WalletTransactionViewModel[]; constructor(data: LeagueWalletViewData) { super(); this.data = data; this.transactions = data.transactions.map(t => new WalletTransactionViewModel(t)); } get balance(): number { return this.data.balance; } get currency(): string { return this.data.currency; } get totalRevenue(): number { return this.data.totalRevenue; } get totalFees(): number { return this.data.totalFees; } get totalWithdrawals(): number { return this.data.totalWithdrawals; } get pendingPayouts(): number { return this.data.pendingPayouts; } get canWithdraw(): boolean { return this.data.canWithdraw; } get withdrawalBlockReason(): string | undefined { return this.data.withdrawalBlockReason; } /** UI-specific: Formatted balance */ get formattedBalance(): string { return CurrencyFormatter.format(this.balance, this.currency); } /** UI-specific: Formatted total revenue */ get formattedTotalRevenue(): string { return CurrencyFormatter.format(this.totalRevenue, this.currency); } /** UI-specific: Formatted total fees */ get formattedTotalFees(): string { return CurrencyFormatter.format(this.totalFees, this.currency); } /** UI-specific: Formatted pending payouts */ get formattedPendingPayouts(): string { return CurrencyFormatter.format(this.pendingPayouts, this.currency); } /** UI-specific: Filtered transactions by type */ getFilteredTransactions(type: 'all' | 'sponsorship' | 'membership' | 'withdrawal' | 'prize'): WalletTransactionViewModel[] { return type === 'all' ? this.transactions : this.transactions.filter(t => t.type === type); } }