46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { LeagueSettingsPageQuery } from '@/lib/page-queries/LeagueSettingsPageQuery';
|
|
import { LeagueSettingsTemplate } from '@/templates/LeagueSettingsTemplate';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
interface Props {
|
|
params: Promise<{ id: string }>;
|
|
}
|
|
|
|
export default async function LeagueSettingsPage({ params }: Props) {
|
|
const { id: leagueId } = await params;
|
|
|
|
if (!leagueId) {
|
|
notFound();
|
|
}
|
|
|
|
const result = await LeagueSettingsPageQuery.execute(leagueId);
|
|
|
|
if (result.isErr()) {
|
|
const error = result.getError();
|
|
if (error === 'notFound') {
|
|
notFound();
|
|
}
|
|
// For serverError, show the template with empty data
|
|
return <LeagueSettingsTemplate viewData={{
|
|
leagueId,
|
|
league: {
|
|
id: leagueId,
|
|
name: 'Unknown League',
|
|
description: 'League information unavailable',
|
|
visibility: 'private',
|
|
ownerId: 'unknown',
|
|
createdAt: '1970-01-01T00:00:00Z',
|
|
updatedAt: '1970-01-01T00:00:00Z',
|
|
},
|
|
config: {
|
|
maxDrivers: 0,
|
|
scoringPresetId: 'unknown',
|
|
allowLateJoin: false,
|
|
requireApproval: false,
|
|
},
|
|
}} />;
|
|
}
|
|
|
|
return <LeagueSettingsTemplate viewData={result.unwrap()} />;
|
|
}
|