view data fixes
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { CurrencyDisplay } from '@/lib/display-objects/CurrencyDisplay';
|
||||
import { DateDisplay } from '@/lib/display-objects/DateDisplay';
|
||||
import { LeagueWalletApiDto } from '@/lib/types/tbd/LeagueWalletApiDto';
|
||||
import { LeagueWalletTransactionViewData, LeagueWalletViewData } from '@/lib/view-data/LeagueWalletViewData';
|
||||
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";
|
||||
|
||||
@@ -10,29 +9,29 @@ export class LeagueWalletViewDataBuilder implements ViewDataBuilder<any, any> {
|
||||
return LeagueWalletViewDataBuilder.build(input);
|
||||
}
|
||||
|
||||
static build(
|
||||
static build(apiDto: LeagueWalletApiDto): LeagueWalletViewData {
|
||||
const transactions: LeagueWalletTransactionViewData[] = apiDto.transactions.map(t => ({
|
||||
...t,
|
||||
formattedAmount: CurrencyDisplay.format(t.amount, apiDto.currency),
|
||||
amountColor: t.amount >= 0 ? 'green' : 'red',
|
||||
formattedDate: DateDisplay.formatShort(t.createdAt),
|
||||
statusColor: t.status === 'completed' ? 'green' : t.status === 'pending' ? 'yellow' : 'red',
|
||||
typeColor: 'blue',
|
||||
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 {
|
||||
leagueId: apiDto.leagueId,
|
||||
balance: apiDto.balance,
|
||||
formattedBalance: CurrencyDisplay.format(apiDto.balance, apiDto.currency),
|
||||
totalRevenue: apiDto.balance, // Mock
|
||||
formattedTotalRevenue: CurrencyDisplay.format(apiDto.balance, apiDto.currency),
|
||||
totalFees: 0, // Mock
|
||||
formattedTotalFees: CurrencyDisplay.format(0, apiDto.currency),
|
||||
pendingPayouts: 0, // Mock
|
||||
formattedPendingPayouts: CurrencyDisplay.format(0, apiDto.currency),
|
||||
currency: apiDto.currency,
|
||||
totalRevenue: apiDto.totalRevenue,
|
||||
totalFees: apiDto.totalFees,
|
||||
totalWithdrawals: apiDto.totalWithdrawals,
|
||||
pendingPayouts: apiDto.pendingPayouts,
|
||||
transactions,
|
||||
canWithdraw: apiDto.canWithdraw,
|
||||
withdrawalBlockReason: apiDto.withdrawalBlockReason,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user