31 lines
819 B
TypeScript
31 lines
819 B
TypeScript
import { LeagueSchedulePageQuery } from '@/lib/page-queries/LeagueSchedulePageQuery';
|
|
import { LeagueScheduleTemplate } from '@/templates/LeagueScheduleTemplate';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
interface Props {
|
|
params: Promise<{ id: string }>;
|
|
}
|
|
|
|
export default async function LeagueSchedulePage({ params }: Props) {
|
|
const { id: leagueId } = await params;
|
|
|
|
if (!leagueId) {
|
|
notFound();
|
|
}
|
|
|
|
const result = await LeagueSchedulePageQuery.execute(leagueId);
|
|
|
|
if (result.isErr()) {
|
|
const error = result.getError();
|
|
if (error === 'notFound') {
|
|
notFound();
|
|
}
|
|
// For serverError, show the template with empty data
|
|
return <LeagueScheduleTemplate viewData={{
|
|
leagueId,
|
|
races: [],
|
|
}} />;
|
|
}
|
|
|
|
return <LeagueScheduleTemplate viewData={result.unwrap()} />;
|
|
} |