'use client'; import DriverIdentity from '@/components/drivers/DriverIdentity'; import type { DriverDTO } from '@gridpilot/racing/application/dto/DriverDTO'; import type { LeagueDriverSeasonStatsDTO } from '@gridpilot/racing/application/dto/LeagueDriverSeasonStatsDTO'; interface StandingsTableProps { standings: LeagueDriverSeasonStatsDTO[]; drivers: DriverDTO[]; leagueId: string; } export default function StandingsTable({ standings, drivers, leagueId }: StandingsTableProps) { const getDriver = (driverId: string): DriverDTO | undefined => { return drivers.find((d) => d.id === driverId); }; if (standings.length === 0) { return (
No standings available
); } return (
{standings.map((row) => { const isLeader = row.position === 1; const driver = getDriver(row.driverId); const totalPointsLine = row.penaltyPoints > 0 ? `Total Points: ${row.totalPoints} (-${row.penaltyPoints} penalty)` : `Total Points: ${row.totalPoints}`; const ratingDelta = row.ratingChange === null || row.ratingChange === 0 ? '—' : row.ratingChange > 0 ? `+${row.ratingChange}` : `${row.ratingChange}`; return ( ); })}
Pos Driver Team Total Pts Pts / Race Started Finished DNF No‑Shows Penalty Bonus Avg Finish Rating Δ
{row.position} {driver ? ( ) : ( Unknown Driver )} {row.teamName ?? '—'}
{row.totalPoints} {row.penaltyPoints > 0 || row.bonusPoints !== 0 ? ( base {row.basePoints} {row.penaltyPoints > 0 && ( −{row.penaltyPoints} )} {row.bonusPoints !== 0 && ( +{row.bonusPoints} )} ) : null}
{row.pointsPerRace.toFixed(2)} {row.racesStarted} {row.racesFinished} {row.dnfs} {row.noShows} 0 ? 'text-red-400' : 'text-gray-300'}> {row.penaltyPoints > 0 ? `-${row.penaltyPoints}` : '—'} {row.bonusPoints !== 0 ? `+${row.bonusPoints}` : '—'} {row.avgFinish !== null ? row.avgFinish.toFixed(2) : '—'} 0 ? 'text-green-400' : row.ratingChange && row.ratingChange < 0 ? 'text-red-400' : 'text-gray-300'}> {ratingDelta}
); }