Files
gridpilot.gg/apps/website/components/leagues/LeagueStandingsTable.tsx
2026-01-21 22:36:01 +01:00

72 lines
2.2 KiB
TypeScript

'use client';
import { LeaderboardTableShell } from '@/ui/LeaderboardTableShell';
import { LeaderboardList } from '@/ui/LeaderboardList';
import { RankingRow } from '@/components/leaderboards/RankingRow';
import { useRouter } from 'next/navigation';
import { routes } from '@/lib/routing/RouteConfig';
import { Box } from '@/ui/Box';
import { Text } from '@/ui/Text';
import { Group } from '@/ui/Group';
import { Badge } from '@/ui/Badge';
import { Icon } from '@/ui/Icon';
import { Droplet, XCircle } from 'lucide-react';
interface StandingEntry {
position: number;
driverName: string;
driverId?: string; // Added to support navigation
teamName?: string;
points: number;
wins: number;
podiums: number;
races: number;
avgFinish: number | null;
gap: string;
positionChange: number;
lastRacePoints: number;
droppedRaceIds: string[];
}
interface LeagueStandingsTableProps {
standings: StandingEntry[];
'data-testid'?: string;
}
export function LeagueStandingsTable({ standings, 'data-testid': dataTestId }: LeagueStandingsTableProps) {
const router = useRouter();
if (!standings || standings.length === 0) {
return (
<Box p={12} textAlign="center" border borderColor="zinc-800" bg="zinc-900/30" data-testid={dataTestId}>
<Text color="text-zinc-500" italic>No standings data available for this season.</Text>
</Box>
);
}
return (
<LeaderboardTableShell data-testid={dataTestId}>
<LeaderboardList>
{standings.map((entry) => (
<RankingRow
key={entry.driverId || entry.driverName}
id={entry.driverId || ''}
rank={entry.position}
rankDelta={entry.positionChange}
name={entry.driverName}
avatarUrl="" // Not provided in StandingEntry
nationality="INT"
skillLevel="pro"
racesCompleted={entry.races}
rating={0}
wins={entry.wins}
onClick={entry.driverId ? () => router.push(routes.driver.detail(entry.driverId!)) : undefined}
data-testid="standings-row"
droppedRaceIds={entry.droppedRaceIds}
/>
))}
</LeaderboardList>
</LeaderboardTableShell>
);
}