66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
|
|
|
|
import { RaceListItem } from '@/components/races/RaceListItem';
|
|
import { routes } from '@/lib/routing/RouteConfig';
|
|
import type { RaceViewData } from '@/lib/view-data/RacesViewData';
|
|
import { DateHeader } from '@/ui/DateHeader';
|
|
import { EmptyState } from '@/ui/EmptyState';
|
|
import { Stack } from '@/ui/Stack';
|
|
import { Calendar, CheckCircle2, Clock, PlayCircle, XCircle } from 'lucide-react';
|
|
|
|
interface RaceListProps {
|
|
racesByDate: Array<{
|
|
dateKey: string;
|
|
dateLabel: string;
|
|
races: RaceViewData[];
|
|
}>;
|
|
totalCount: number;
|
|
onRaceClick: (raceId: string) => void;
|
|
}
|
|
|
|
export function RaceList({ racesByDate, totalCount, onRaceClick }: RaceListProps) {
|
|
if (racesByDate.length === 0) {
|
|
return (
|
|
<EmptyState
|
|
icon={Calendar}
|
|
title="No races found"
|
|
description={totalCount === 0 ? 'No races have been scheduled yet' : 'Try adjusting your filters'}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Stack gap={4}>
|
|
{racesByDate.map((group) => (
|
|
<Stack key={group.dateKey} gap={3}>
|
|
<DateHeader
|
|
date={group.dateLabel}
|
|
/>
|
|
|
|
<Stack gap={2}>
|
|
{group.races.map((race) => {
|
|
return (
|
|
<RaceListItem
|
|
key={race.id}
|
|
track={race.track}
|
|
car={race.car}
|
|
timeLabel={race.timeLabel}
|
|
relativeTimeLabel={race.relativeTimeLabel}
|
|
status={race.status}
|
|
leagueName={race.leagueName ?? 'Unknown League'}
|
|
leagueHref={routes.league.detail(race.leagueId ?? '')}
|
|
strengthOfField={race.strengthOfField}
|
|
onClick={() => onRaceClick(race.id)}
|
|
statusLabel={race.statusLabel}
|
|
statusVariant={race.statusVariant as any}
|
|
statusIconName={race.statusIconName}
|
|
/>
|
|
);
|
|
})}
|
|
</Stack>
|
|
</Stack>
|
|
))}
|
|
</Stack>
|
|
);
|
|
}
|