60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { WalletTransactionViewModel } from './WalletTransactionViewModel';
|
|
|
|
export class LeagueWalletViewModel {
|
|
balance: number;
|
|
currency: string;
|
|
totalRevenue: number;
|
|
totalFees: number;
|
|
totalWithdrawals: number;
|
|
pendingPayouts: number;
|
|
transactions: WalletTransactionViewModel[];
|
|
canWithdraw: boolean;
|
|
withdrawalBlockReason?: string;
|
|
|
|
constructor(dto: {
|
|
balance: number;
|
|
currency: string;
|
|
totalRevenue: number;
|
|
totalFees: number;
|
|
totalWithdrawals: number;
|
|
pendingPayouts: number;
|
|
transactions: WalletTransactionViewModel[];
|
|
canWithdraw: boolean;
|
|
withdrawalBlockReason?: string;
|
|
}) {
|
|
this.balance = dto.balance;
|
|
this.currency = dto.currency;
|
|
this.totalRevenue = dto.totalRevenue;
|
|
this.totalFees = dto.totalFees;
|
|
this.totalWithdrawals = dto.totalWithdrawals;
|
|
this.pendingPayouts = dto.pendingPayouts;
|
|
this.transactions = dto.transactions;
|
|
this.canWithdraw = dto.canWithdraw;
|
|
this.withdrawalBlockReason = dto.withdrawalBlockReason;
|
|
}
|
|
|
|
/** UI-specific: Formatted balance */
|
|
get formattedBalance(): string {
|
|
return `$${this.balance.toFixed(2)}`;
|
|
}
|
|
|
|
/** UI-specific: Formatted total revenue */
|
|
get formattedTotalRevenue(): string {
|
|
return `$${this.totalRevenue.toFixed(2)}`;
|
|
}
|
|
|
|
/** UI-specific: Formatted total fees */
|
|
get formattedTotalFees(): string {
|
|
return `$${this.totalFees.toFixed(2)}`;
|
|
}
|
|
|
|
/** UI-specific: Formatted pending payouts */
|
|
get formattedPendingPayouts(): string {
|
|
return `$${this.pendingPayouts.toFixed(2)}`;
|
|
}
|
|
|
|
/** 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);
|
|
}
|
|
} |