import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger, } from "~/components/ui/context-menu"; import { DraftPickCell, type CoronaState } from "~/components/draft/DraftPickCell"; import { TeamAvatar } from "~/components/TeamAvatar"; import type { SeasonStatus } from "~/models/season"; import type { AvatarData, RawFlagConfig } from "~/lib/flag-types"; interface DraftCell { pickNumber: number; participant: { id: string; name: string }; sport: { id: string; name: string }; team: { id: string; name: string }; } interface DraftGridProps { draftSlots: Array<{ id: string; draftOrder: number; team: { id: string; name: string; logoUrl?: string | null; flagConfig?: RawFlagConfig | null; avatarType?: string | null; ownerAvatarData?: AvatarData | null; }; }>; draftGrid: Array>; 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; coronaStates?: Record; seasonStatus?: SeasonStatus; draftPaused?: boolean; } export function DraftGrid({ draftSlots, draftGrid, currentPick, teamTimers, formatTime, title, isCommissioner = false, onForceAutopick, onForceManualPick, autodraftStatus = {}, connectedTeams = new Set(), ownerMap = {}, coronaStates = {}, seasonStatus, draftPaused, }: 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 (
{isAutodraft && ( A )} {ownerMap[slot.team.id] || slot.team.name}
{teamTimers && formatTime && (
60 ? "text-emerald-400" : teamTime > 30 ? "text-amber-accent" : "text-coral-accent" }`} > {formatTime(teamTime)}
)}
); })}
{/* Draft Grid Rows */}
{draftGrid.map((roundPicks, roundIndex) => { const round = roundIndex + 1; const isEvenRound = round % 2 === 0; const displayPicks = isEvenRound ? [...roundPicks].toReversed() : roundPicks; return (
{displayPicks.map((cell, index) => { const actualIndex = isEvenRound ? roundPicks.length - 1 - index : index; const pickNumber = roundIndex * totalTeams + actualIndex + 1; const isCurrent = pickNumber === currentPick; const isPicked = !!cell; const cellContent = ( ); if ( isCommissioner && !isPicked && isCurrent && onForceAutopick && onForceManualPick ) { const slot = draftSlots[actualIndex]; return ( {cellContent} onForceAutopick(pickNumber, slot.team.id) } > Force Auto Pick onForceManualPick(pickNumber, slot.team.id) } > Force Manual Pick ); } return cellContent; })}
); })}
); }