Files
gridpilot.gg/apps/website/app/leagues/[id]/rulebook/page.tsx
2026-01-17 01:04:36 +01:00

39 lines
1.0 KiB
TypeScript

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