52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { notFound } from 'next/navigation';
|
|
import { LeagueDetailTemplate } from '@/templates/LeagueDetailTemplate';
|
|
import { LeagueDetailPageQuery } from '@/lib/page-queries/page-queries/LeagueDetailPageQuery';
|
|
import { LeagueDetailViewDataBuilder } from '@/lib/builders/view-data/LeagueDetailViewDataBuilder';
|
|
|
|
interface Props {
|
|
params: { id: string };
|
|
}
|
|
|
|
export default async function Page({ params }: Props) {
|
|
// Execute the PageQuery
|
|
const result = await LeagueDetailPageQuery.execute(params.id);
|
|
|
|
// Handle different result types
|
|
if (result.isErr()) {
|
|
const error = result.getError();
|
|
|
|
switch (error) {
|
|
case 'notFound':
|
|
notFound();
|
|
case 'redirect':
|
|
// In a real app, this would redirect to login
|
|
notFound();
|
|
case 'LEAGUE_FETCH_FAILED':
|
|
case 'UNKNOWN_ERROR':
|
|
default:
|
|
// Return error state
|
|
return (
|
|
<div className="min-h-screen bg-deep-graphite py-12 px-4 sm:px-6 lg:px-8">
|
|
<div className="max-w-6xl mx-auto">
|
|
<div className="text-center text-gray-400">Failed to load league details</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
const data = result.unwrap();
|
|
|
|
// Build ViewData using the builder
|
|
// Note: This would need additional data (owner, scoring config, etc.) in real implementation
|
|
const viewData = LeagueDetailViewDataBuilder.build({
|
|
league: data.league,
|
|
owner: null,
|
|
scoringConfig: null,
|
|
memberships: { members: [] },
|
|
races: [],
|
|
sponsors: [],
|
|
});
|
|
|
|
return <LeagueDetailTemplate viewData={viewData} />;
|
|
} |