import { Card } from "~/components/ui/card"; import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger, } from "~/components/ui/context-menu"; interface DraftGridProps { draftSlots: Array<{ id: string; draftOrder: number; team: { id: string; name: string; }; }>; draftGrid: any[][]; currentPick: number; teamTimers?: Record; formatTime?: (seconds: number | undefined) => string; title?: string; isCommissioner?: boolean; onForceAutopick?: (pickNumber: number, teamId: string) => void; onForceManualPick?: (pickNumber: number, teamId: string) => void; autodraftStatus?: Record; connectedTeams?: Set; ownerMap?: Record; } export function DraftGrid({ draftSlots, draftGrid, currentPick, teamTimers, formatTime, title, isCommissioner = false, onForceAutopick, onForceManualPick, autodraftStatus = {}, connectedTeams = new Set(), ownerMap = {}, }: DraftGridProps) { const totalTeams = draftSlots.length; return ( {title &&

{title}

}
{/* Team Headers */}
{draftSlots.map((slot) => { const teamTime = teamTimers?.[slot.team.id]; const isAutodraft = autodraftStatus[slot.team.id] || false; const isConnected = connectedTeams.has(slot.team.id); return (
{ownerMap[slot.team.id] || slot.team.name}
{teamTimers && formatTime && (
60 ? "text-emerald-400" : teamTime > 30 ? "text-amber-accent" : "text-coral-accent" }`} > {formatTime(teamTime)} {isAutodraft && ( (auto) )}
)}
); })}
{/* Draft Grid Rows */}
{draftGrid.map((roundPicks, roundIndex) => { const round = roundIndex + 1; const isEvenRound = round % 2 === 0; const displayPicks = isEvenRound ? [...roundPicks].reverse() : roundPicks; return (
{displayPicks.map((cell, index) => { const actualIndex = isEvenRound ? roundPicks.length - 1 - index : index; const slot = draftSlots[actualIndex]; const pickNumber = roundIndex * totalTeams + actualIndex + 1; const isCurrent = pickNumber === currentPick; const isPicked = !!cell; const cellContent = (
{round}.{String(actualIndex + 1).padStart(2, "0")}
{isPicked ? (
{cell.participant.name}
{cell.sport.name}
) : isCurrent ? (
On Clock
) : null}
); // Wrap with context menu if commissioner and current unpicked cell if ( isCommissioner && !isPicked && isCurrent && onForceAutopick && onForceManualPick ) { return ( {cellContent} onForceAutopick(pickNumber, slot.team.id) } > Force Auto Pick onForceManualPick(pickNumber, slot.team.id) } > Force Manual Pick ); } return cellContent; })}
); })}
); }