import type { GetLeagueWalletOutputDTO } from '@/lib/types/generated/GetLeagueWalletOutputDTO'; import type { LeagueWalletViewData } from '@/lib/view-data/LeagueWalletViewData'; import type { WalletTransactionViewData } from '@/lib/view-data/WalletTransactionViewData'; import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder"; export class LeagueWalletViewDataBuilder implements ViewDataBuilder { build(input: any): any { return LeagueWalletViewDataBuilder.build(input); } static build(apiDto: GetLeagueWalletOutputDTO): LeagueWalletViewData { const transactions: WalletTransactionViewData[] = apiDto.transactions.map(t => ({ id: t.id, type: t.type as any, description: t.description, amount: t.amount, fee: t.fee, netAmount: t.netAmount, date: (t as any).createdAt || (t as any).date || new Date().toISOString(), status: t.status as any, reference: t.reference, })); return { balance: apiDto.balance, currency: apiDto.currency, totalRevenue: apiDto.totalRevenue, totalFees: apiDto.totalFees, totalWithdrawals: apiDto.totalWithdrawals, pendingPayouts: apiDto.pendingPayouts, transactions, canWithdraw: apiDto.canWithdraw, withdrawalBlockReason: apiDto.withdrawalBlockReason, }; } }