37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { LeagueSponsorshipsPageQuery } from '@/lib/page-queries/page-queries/LeagueSponsorshipsPageQuery';
|
|
import { LeagueSponsorshipsTemplate } from '@/templates/LeagueSponsorshipsTemplate';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
interface Props {
|
|
params: { id: string };
|
|
}
|
|
|
|
export default async function LeagueSponsorshipsPage({ params }: Props) {
|
|
const leagueId = params.id;
|
|
|
|
if (!leagueId) {
|
|
notFound();
|
|
}
|
|
|
|
const result = await LeagueSponsorshipsPageQuery.execute(leagueId);
|
|
|
|
if (result.isErr()) {
|
|
const error = result.getError();
|
|
if (error.type === 'notFound') {
|
|
notFound();
|
|
}
|
|
// For serverError, show the template with empty data
|
|
return <LeagueSponsorshipsTemplate viewData={{
|
|
leagueId,
|
|
league: {
|
|
id: leagueId,
|
|
name: 'Unknown League',
|
|
description: 'League information unavailable',
|
|
},
|
|
sponsorshipSlots: [],
|
|
sponsorshipRequests: [],
|
|
}} />;
|
|
}
|
|
|
|
return <LeagueSponsorshipsTemplate viewData={result.unwrap()} />;
|
|
} |