website refactor
This commit is contained in:
@@ -1,13 +1,29 @@
|
||||
import { LeagueWalletViewData } from '@/lib/view-data/leagues/LeagueWalletViewData';
|
||||
import { LeagueWalletViewData, LeagueWalletTransactionViewData } from '@/lib/view-data/leagues/LeagueWalletViewData';
|
||||
import { LeagueWalletApiDto } from '@/lib/types/tbd/LeagueWalletApiDto';
|
||||
|
||||
export class LeagueWalletViewDataBuilder {
|
||||
static build(apiDto: LeagueWalletApiDto): LeagueWalletViewData {
|
||||
const transactions: LeagueWalletTransactionViewData[] = apiDto.transactions.map(t => ({
|
||||
...t,
|
||||
formattedAmount: `${t.amount} ${apiDto.currency}`,
|
||||
amountColor: t.amount >= 0 ? 'green' : 'red',
|
||||
formattedDate: new Date(t.createdAt).toLocaleDateString(),
|
||||
statusColor: t.status === 'completed' ? 'green' : t.status === 'pending' ? 'yellow' : 'red',
|
||||
typeColor: 'blue',
|
||||
}));
|
||||
|
||||
return {
|
||||
leagueId: apiDto.leagueId,
|
||||
balance: apiDto.balance,
|
||||
formattedBalance: `${apiDto.balance} ${apiDto.currency}`,
|
||||
totalRevenue: apiDto.balance, // Mock
|
||||
formattedTotalRevenue: `${apiDto.balance} ${apiDto.currency}`,
|
||||
totalFees: 0, // Mock
|
||||
formattedTotalFees: `0 ${apiDto.currency}`,
|
||||
pendingPayouts: 0, // Mock
|
||||
formattedPendingPayouts: `0 ${apiDto.currency}`,
|
||||
currency: apiDto.currency,
|
||||
transactions: apiDto.transactions,
|
||||
transactions,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user