website refactor
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import { StatefulPageWrapper } from '@/components/shared/state/StatefulPageWrapper';
|
||||
import { RaceResultsTemplate } from '@/templates/RaceResultsTemplate';
|
||||
import { RaceResultsPageQuery } from '@/lib/page-queries/races/RaceResultsPageQuery';
|
||||
import { Trophy } from 'lucide-react';
|
||||
import RaceResultsPageClient from './RaceResultsPageClient';
|
||||
|
||||
interface RaceResultsPageProps {
|
||||
params: {
|
||||
params: Promise<{
|
||||
id: string;
|
||||
};
|
||||
}>;
|
||||
}
|
||||
|
||||
export default async function RaceResultsPage({ params }: RaceResultsPageProps) {
|
||||
const raceId = params.id;
|
||||
const { id: raceId } = await params;
|
||||
|
||||
if (!raceId) {
|
||||
notFound();
|
||||
@@ -23,56 +22,18 @@ export default async function RaceResultsPage({ params }: RaceResultsPageProps)
|
||||
if (result.isErr()) {
|
||||
const error = result.getError();
|
||||
|
||||
switch (error) {
|
||||
case 'notFound':
|
||||
notFound();
|
||||
case 'redirect':
|
||||
notFound();
|
||||
default:
|
||||
// Pass error to template via StatefulPageWrapper
|
||||
return (
|
||||
<StatefulPageWrapper
|
||||
data={null}
|
||||
isLoading={false}
|
||||
error={new globalThis.Error('Failed to load race results')}
|
||||
retry={() => Promise.resolve()}
|
||||
Template={() => (
|
||||
<RaceResultsTemplate
|
||||
viewData={{
|
||||
raceTrack: '',
|
||||
raceScheduledAt: '',
|
||||
totalDrivers: 0,
|
||||
leagueName: '',
|
||||
raceSOF: null,
|
||||
results: [],
|
||||
penalties: [],
|
||||
pointsSystem: {},
|
||||
fastestLapTime: 0,
|
||||
}}
|
||||
isAdmin={false}
|
||||
isLoading={false}
|
||||
error={null}
|
||||
onBack={() => {}}
|
||||
onImportResults={() => Promise.resolve()}
|
||||
onPenaltyClick={() => {}}
|
||||
importing={false}
|
||||
importSuccess={false}
|
||||
importError={null}
|
||||
showImportForm={false}
|
||||
setShowImportForm={() => {}}
|
||||
/>
|
||||
)}
|
||||
loading={{ variant: 'skeleton', message: 'Loading race results...' }}
|
||||
errorConfig={{ variant: 'full-screen' }}
|
||||
empty={{
|
||||
icon: Trophy,
|
||||
title: 'No results available',
|
||||
description: 'Race results will appear here once the race is completed',
|
||||
action: { label: 'Back to Race', onClick: () => {} }
|
||||
}}
|
||||
/>
|
||||
);
|
||||
if (error === 'notFound') {
|
||||
notFound();
|
||||
}
|
||||
// For other errors, let StatefulPageWrapper handle it
|
||||
return (
|
||||
<StatefulPageWrapper
|
||||
data={undefined}
|
||||
Template={RaceResultsPageClient as any}
|
||||
error={new Error('Failed to load race results')}
|
||||
retry={() => Promise.resolve()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const viewData = result.unwrap();
|
||||
@@ -80,33 +41,8 @@ export default async function RaceResultsPage({ params }: RaceResultsPageProps)
|
||||
return (
|
||||
<StatefulPageWrapper
|
||||
data={viewData}
|
||||
isLoading={false}
|
||||
error={null}
|
||||
Template={RaceResultsPageClient}
|
||||
retry={() => Promise.resolve()}
|
||||
Template={() => (
|
||||
<RaceResultsTemplate
|
||||
viewData={viewData}
|
||||
isAdmin={false}
|
||||
isLoading={false}
|
||||
error={null}
|
||||
onBack={() => {}}
|
||||
onImportResults={() => Promise.resolve()}
|
||||
onPenaltyClick={() => {}}
|
||||
importing={false}
|
||||
importSuccess={false}
|
||||
importError={null}
|
||||
showImportForm={false}
|
||||
setShowImportForm={() => {}}
|
||||
/>
|
||||
)}
|
||||
loading={{ variant: 'skeleton', message: 'Loading race results...' }}
|
||||
errorConfig={{ variant: 'full-screen' }}
|
||||
empty={{
|
||||
icon: Trophy,
|
||||
title: 'No results available',
|
||||
description: 'Race results will appear here once the race is completed',
|
||||
action: { label: 'Back to Race', onClick: () => {} }
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user