website refactor

This commit is contained in:
2026-01-14 13:39:24 +01:00
parent faa4c3309e
commit 8b67295442
28 changed files with 1082 additions and 851 deletions

View File

@@ -1,52 +1,33 @@
'use client';
import { LeagueWalletPageQuery } from '@/lib/page-queries/page-queries/LeagueWalletPageQuery';
import { LeagueWalletTemplate } from '@/templates/LeagueWalletTemplate';
import { notFound } from 'next/navigation';
import { useParams } from 'next/navigation';
import { useLeagueWalletPageData, useLeagueWalletWithdrawal } from "@/lib/hooks/league/useLeagueWalletPageData";
import { PageWrapper } from '@/components/shared/state/PageWrapper';
import { WalletTemplate } from './WalletTemplate';
import { Wallet } from 'lucide-react';
interface Props {
params: { id: string };
}
export default function LeagueWalletPage() {
const params = useParams();
const leagueId = params.id as string;
export default async function LeagueWalletPage({ params }: Props) {
const leagueId = params.id;
// Query for wallet data using domain hook
const { data, isLoading, error, refetch } = useLeagueWalletPageData(leagueId);
if (!leagueId) {
notFound();
}
// Mutation for withdrawal using domain hook
const withdrawMutation = useLeagueWalletWithdrawal(leagueId, data, refetch);
const result = await LeagueWalletPageQuery.execute(leagueId);
// Export handler (placeholder)
const handleExport = () => {
alert('Export functionality coming soon!');
};
if (result.isErr()) {
const error = result.getError();
if (error.type === 'notFound') {
notFound();
}
// For serverError, show the template with empty data
return <LeagueWalletTemplate viewData={{
leagueId,
balance: 0,
currency: 'USD',
transactions: [],
}} />;
}
// Render function for the template
const renderTemplate = (walletData: any) => {
return (
<WalletTemplate
data={walletData}
onWithdraw={(amount) => withdrawMutation.mutate({ amount })}
onExport={handleExport}
mutationLoading={withdrawMutation.isPending}
/>
);
};
return (
<PageWrapper
data={data}
isLoading={isLoading}
error={error}
retry={refetch}
Template={({ data }) => renderTemplate(data)}
loading={{ variant: 'skeleton', message: 'Loading wallet...' }}
errorConfig={{ variant: 'full-screen' }}
empty={{
icon: Wallet,
title: 'No wallet data available',
description: 'Wallet data will appear here once loaded',
}}
/>
);
return <LeagueWalletTemplate viewData={result.unwrap()} />;
}