"use client"; import { useState, useEffect } from "react"; import { ProtestViewModel } from "@/lib/view-models/ProtestViewModel"; import { RaceViewModel } from "@/lib/view-models/RaceViewModel"; import { DriverViewModel } from "@/lib/view-models/DriverViewModel"; import { Card } from "@/ui/Card"; import { Stack } from "@/ui/Stack"; import { Text } from "@/ui/Text"; import { Heading } from "@/ui/Heading"; import { Icon } from "@/ui/Icon"; import { AlertCircle, Flag } from "lucide-react"; interface PenaltyHistoryListProps { protests: ProtestViewModel[]; races: Record; drivers: Record; } export function PenaltyHistoryList({ protests, races, drivers, }: PenaltyHistoryListProps) { const [filteredProtests, setFilteredProtests] = useState([]); useEffect(() => { setFilteredProtests(protests); }, [protests]); const getStatusColor = (status: string) => { switch (status) { case "upheld": return { text: "text-red-400", bg: "bg-red-500/20" }; case "dismissed": return { text: "text-gray-400", bg: "bg-gray-500/20" }; case "withdrawn": return { text: "text-blue-400", bg: "bg-blue-500/20" }; default: return { text: "text-orange-400", bg: "bg-orange-500/20" }; } }; return ( {filteredProtests.length === 0 ? ( No Resolved Protests No protests have been resolved in this league ) : ( {filteredProtests.map((protest) => { const race = races[protest.raceId]; const protester = drivers[protest.protestingDriverId]; const accused = drivers[protest.accusedDriverId]; const incident = protest.incident; const resolvedDate = protest.reviewedAt || protest.filedAt; const statusColors = getStatusColor(protest.status); return ( Protest #{protest.id.substring(0, 8)} {resolvedDate ? `Resolved ${new Date(resolvedDate).toLocaleDateString()}` : 'Resolved'} {protest.status.toUpperCase()} {protester?.name || 'Unknown'} vs {accused?.name || 'Unknown'} {race && incident && ( {race.track} ({race.car}) - Lap {incident.lap} )} {incident && ( {incident.description} )} {protest.decisionNotes && ( Steward Notes: {protest.decisionNotes} )} ); })} )} ); }