website refactor

This commit is contained in:
2026-01-14 02:02:24 +01:00
parent 8d7c709e0c
commit 4522d41aef
291 changed files with 12763 additions and 9309 deletions

View File

@@ -1,19 +1,39 @@
import { notFound } from 'next/navigation';
import { PageWrapper } from '@/components/shared/state/PageWrapper';
import { LeaguesTemplate } from '@/templates/LeaguesTemplate';
import { PageDataFetcher } from '@/lib/page/PageDataFetcher';
import { LEAGUE_SERVICE_TOKEN } from '@/lib/di/tokens';
import type { LeagueService } from '@/lib/services/leagues/LeagueService';
import { LeaguesPageQuery } from '@/lib/page-queries/page-queries/LeaguesPageQuery';
import type { LeaguesViewData } from '@/lib/view-data/LeaguesViewData';
export default async function Page() {
const data = await PageDataFetcher.fetch<LeagueService, 'getAllLeagues'>(
LEAGUE_SERVICE_TOKEN,
'getAllLeagues'
);
if (!data) {
notFound();
// Execute the PageQuery
const result = await LeaguesPageQuery.execute();
// Handle different result types
if (result.isErr()) {
const error = result.getError();
switch (error) {
case 'notFound':
notFound();
case 'redirect':
// In a real app, this would redirect to login
notFound();
case 'LEAGUES_FETCH_FAILED':
case 'UNKNOWN_ERROR':
default:
// Return error state that PageWrapper can handle
return (
<PageWrapper
data={undefined}
error={new Error('Failed to fetch leagues')}
Template={LeaguesTemplate}
errorConfig={{ variant: 'full-screen' }}
/>
);
}
}
return <PageWrapper data={data} Template={LeaguesTemplate} />;
const viewData = result.unwrap();
return <PageWrapper data={viewData} Template={LeaguesTemplate} />;
}