view data fixes

This commit is contained in:
2026-01-23 15:30:23 +01:00
parent e22033be38
commit f8099f04bc
213 changed files with 3466 additions and 3003 deletions

View File

@@ -1,37 +1,30 @@
import { WalletDTO } from '@/lib/types/generated/WalletDTO';
import { WalletTransactionViewModel } from './WalletTransactionViewModel';
import { ViewModel } from "../contracts/view-models/ViewModel";
import { CurrencyDisplay } from "../display-objects/CurrencyDisplay";
import type { WalletViewData } from "../view-data/WalletViewData";
export class WalletViewModel extends ViewModel {
id: string;
leagueId: string;
balance: number;
totalRevenue: number;
totalPlatformFees: number;
totalWithdrawn: number;
createdAt: string;
currency: string;
private readonly data: WalletViewData;
readonly transactions: WalletTransactionViewModel[];
constructor(dto: WalletDTO & { transactions?: any[] }) {
this.id = dto.id;
this.leagueId = dto.leagueId;
this.balance = dto.balance;
this.totalRevenue = dto.totalRevenue;
this.totalPlatformFees = dto.totalPlatformFees;
this.totalWithdrawn = dto.totalWithdrawn;
this.createdAt = dto.createdAt;
this.currency = dto.currency;
// Map transactions if provided
this.transactions = dto.transactions?.map(t => new WalletTransactionViewModel(t)) || [];
constructor(data: WalletViewData) {
super();
this.data = data;
this.transactions = data.transactions?.map(t => new WalletTransactionViewModel(t)) || [];
}
transactions: WalletTransactionViewModel[] = [];
get id(): string { return this.data.id; }
get leagueId(): string { return this.data.leagueId; }
get balance(): number { return this.data.balance; }
get totalRevenue(): number { return this.data.totalRevenue; }
get totalPlatformFees(): number { return this.data.totalPlatformFees; }
get totalWithdrawn(): number { return this.data.totalWithdrawn; }
get createdAt(): string { return this.data.createdAt; }
get currency(): string { return this.data.currency; }
/** UI-specific: Formatted balance */
get formattedBalance(): string {
return `${this.currency} ${this.balance.toFixed(2)}`;
return CurrencyDisplay.format(this.balance, this.currency);
}
/** UI-specific: Balance color */
@@ -48,4 +41,4 @@ export class WalletViewModel extends ViewModel {
get totalTransactions(): number {
return this.transactions.length;
}
}
}