import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "~/components/ui/table"; import { Badge } from "~/components/ui/badge"; import { TrendingUp, TrendingDown, Minus, Trophy, Medal, Award } from "lucide-react"; export interface StandingsRow { teamId: string; teamName: string; totalPoints: number; currentRank: number; previousRank?: number | null; firstPlaceCount: number; secondPlaceCount: number; thirdPlaceCount: number; fourthPlaceCount: number; fifthPlaceCount: number; sixthPlaceCount: number; seventhPlaceCount: number; eighthPlaceCount: number; participantsRemaining: number; } interface StandingsTableProps { standings: StandingsRow[]; showMovement?: boolean; showPlacementBreakdown?: boolean; } export function StandingsTable({ standings, showMovement = true, showPlacementBreakdown = false, }: StandingsTableProps) { const getMovementIndicator = (current: number, previous?: number | null) => { if (!showMovement || !previous) return null; const change = previous - current; // Positive means moved up if (change > 0) { return (
+{change}
); } else if (change < 0) { return (
{change}
); } else { return (
-
); } }; const getRankBadge = (rank: number) => { if (rank === 1) { return (
{rank}
); } else if (rank === 2) { return (
{rank}
); } else if (rank === 3) { return (
{rank}
); } else { return {rank}; } }; return ( Rank {showMovement && Change} Team Total Points {showPlacementBreakdown && ( <> 🥇 🥈 🥉 4th 5th 6th 7th 8th )} Remaining {standings.length === 0 ? ( No standings data available yet ) : ( standings.map((row) => ( {getRankBadge(row.currentRank)} {showMovement && ( {getMovementIndicator(row.currentRank, row.previousRank)} )} {row.teamName} {row.totalPoints.toFixed(1)} {showPlacementBreakdown && ( <> {row.firstPlaceCount || "-"} {row.secondPlaceCount || "-"} {row.thirdPlaceCount || "-"} {row.fourthPlaceCount || "-"} {row.fifthPlaceCount || "-"} {row.sixthPlaceCount || "-"} {row.seventhPlaceCount || "-"} {row.eighthPlaceCount || "-"} )} {row.participantsRemaining > 0 ? ( {row.participantsRemaining} ) : ( - )} )) )}
); }