page wrapper

This commit is contained in:
2026-01-07 12:40:52 +01:00
parent e589c30bf8
commit 0db80fa98d
128 changed files with 7386 additions and 8096 deletions

View File

@@ -0,0 +1,47 @@
import { usePageData, usePageMutation } from '@/lib/page/usePageData';
import { useInject } from '@/lib/di/hooks/useInject';
import { LEAGUE_WALLET_SERVICE_TOKEN } from '@/lib/di/tokens';
export function useLeagueWalletPageData(leagueId: string) {
const leagueWalletService = useInject(LEAGUE_WALLET_SERVICE_TOKEN);
const queryResult = usePageData({
queryKey: ['leagueWallet', leagueId],
queryFn: () => leagueWalletService.getWalletForLeague(leagueId),
enabled: !!leagueId,
});
return queryResult;
}
export function useLeagueWalletWithdrawal(leagueId: string, data: any, refetch: () => void) {
const leagueWalletService = useInject(LEAGUE_WALLET_SERVICE_TOKEN);
const withdrawMutation = usePageMutation(
async ({ amount }: { amount: number }) => {
if (!data) throw new Error('Wallet data not available');
const result = await leagueWalletService.withdraw(
leagueId,
amount,
data.currency,
'season-2', // Current active season
'bank-account-***1234'
);
if (!result.success) {
throw new Error(result.message || 'Withdrawal failed');
}
return result;
},
{
onSuccess: () => {
// Refetch wallet data after successful withdrawal
refetch();
},
}
);
return withdrawMutation;
}