35 lines
899 B
TypeScript
35 lines
899 B
TypeScript
import { LeagueStewardingPageQuery } from '@/lib/page-queries/page-queries/LeagueStewardingPageQuery';
|
|
import { StewardingTemplate } from '@/templates/StewardingTemplate';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
interface Props {
|
|
params: { id: string };
|
|
}
|
|
|
|
export default async function LeagueStewardingPage({ params }: Props) {
|
|
const leagueId = params.id;
|
|
|
|
if (!leagueId) {
|
|
notFound();
|
|
}
|
|
|
|
const result = await LeagueStewardingPageQuery.execute(leagueId);
|
|
|
|
if (result.isErr()) {
|
|
const error = result.getError();
|
|
if (error.type === 'notFound') {
|
|
notFound();
|
|
}
|
|
// For serverError, show the template with empty data
|
|
return <StewardingTemplate viewData={{
|
|
leagueId,
|
|
totalPending: 0,
|
|
totalResolved: 0,
|
|
totalPenalties: 0,
|
|
races: [],
|
|
drivers: []
|
|
}} />;
|
|
}
|
|
|
|
return <StewardingTemplate viewData={result.unwrap()} />;
|
|
} |