import { useMemo } from "react"; import { DraftTimer } from "./DraftTimer"; interface Team { id: string; name: string; draftOrder: number; ownerId: string | null; } interface DraftPick { id: string; teamId: string; participantId: string; pickNumber: number; round: number; pickInRound: number; pickedByType: "owner" | "commissioner" | "auto"; } interface Participant { id: string; name: string; sport: string; } interface Timer { teamId: string; timeRemaining: number; } interface DraftGridProps { teams: Team[]; draftPicks: DraftPick[]; participants: Participant[]; draftRounds: number; currentPickNumber: number; userTeamId?: string; timers?: Timer[]; } export function DraftGrid({ teams, draftPicks, participants, draftRounds, currentPickNumber, userTeamId, timers = [], }: DraftGridProps) { // Create a map of participant IDs to participant data for quick lookup const participantMap = useMemo(() => { return new Map(participants.map((p) => [p.id, p])); }, [participants]); // Create a map of pick numbers to draft picks const pickMap = useMemo(() => { return new Map(draftPicks.map((p) => [p.pickNumber, p])); }, [draftPicks]); // Create a map of team IDs to timers const timerMap = useMemo(() => { return new Map(timers.map((t) => [t.teamId, t])); }, [timers]); // Calculate pick number for a given round and team const getPickNumber = (round: number, teamIndex: number): number => { const isOddRound = round % 2 === 1; const pickInRound = isOddRound ? teamIndex + 1 : teams.length - teamIndex; return (round - 1) * teams.length + pickInRound; }; return (