Files
gridpilot.gg/apps/website/app/leagues/[id]/rulebook/page.tsx
2026-01-14 13:27:26 +01:00

36 lines
926 B
TypeScript

import { LeagueRulebookPageQuery } from '@/lib/page-queries/page-queries/LeagueRulebookPageQuery';
import { RulebookTemplate } from '@/templates/RulebookTemplate';
import { notFound } from 'next/navigation';
interface Props {
params: { id: string };
}
export default async function Page({ params }: Props) {
const leagueId = params.id;
if (!leagueId) {
notFound();
}
const result = await LeagueRulebookPageQuery.execute(leagueId);
if (result.isErr()) {
const error = result.getError();
if (error.type === 'notFound') {
notFound();
}
// For serverError, show the template with empty data
return <RulebookTemplate viewData={{
leagueId,
scoringConfig: {
gameName: 'Unknown',
scoringPresetName: 'Unknown',
championships: [],
dropPolicySummary: 'Unknown',
},
}} />;
}
return <RulebookTemplate viewData={result.unwrap()} />;
}