47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { LeagueStewardingPageQuery } from '@/lib/page-queries/LeagueStewardingPageQuery';
|
|
import { StewardingPageClient } from './StewardingPageClient';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
interface Props {
|
|
params: Promise<{ id: string }>;
|
|
}
|
|
|
|
export default async function LeagueStewardingPage({ params }: Props) {
|
|
const { id: leagueId } = await params;
|
|
|
|
if (!leagueId) {
|
|
notFound();
|
|
}
|
|
|
|
const result = await LeagueStewardingPageQuery.execute(leagueId);
|
|
|
|
if (result.isErr()) {
|
|
const error = result.getError();
|
|
if (error === 'notFound') {
|
|
notFound();
|
|
}
|
|
// For serverError, show the template with empty data
|
|
return <StewardingPageClient
|
|
leagueId={leagueId}
|
|
currentDriverId=""
|
|
onRefetch={() => {}}
|
|
data={{
|
|
leagueId,
|
|
totalPending: 0,
|
|
totalResolved: 0,
|
|
totalPenalties: 0,
|
|
races: [],
|
|
drivers: []
|
|
}}
|
|
/>;
|
|
}
|
|
|
|
const data = result.unwrap();
|
|
|
|
return <StewardingPageClient
|
|
data={data}
|
|
leagueId={leagueId}
|
|
currentDriverId="" // Should be fetched or passed
|
|
onRefetch={() => {}} // Should be handled
|
|
/>;
|
|
} |