import { memo, useMemo } from "react"; import { DraftPickCell } from "~/components/draft/DraftPickCell"; interface MiniDraftGridProps { draftSlots: Array<{ id: string; draftOrder: number; team: { id: string; name: string; logoUrl?: string | null; }; }>; draftGrid: Array< Array<{ pickNumber: number; round: number; pickInRound: number; teamId: string; pick?: { participant: { name: string; }; sport: { name: string; }; }; }> >; currentPick: number; currentRound: number; ownerMap?: Record; } export const MiniDraftGrid = memo(function MiniDraftGrid({ draftSlots, draftGrid, currentPick, currentRound, ownerMap = {}, }: MiniDraftGridProps) { const roundsToShow = useMemo(() => { if (currentRound <= 1) return [0, 1]; return [currentRound - 2, currentRound - 1]; }, [currentRound]); if (draftGrid.length === 0) return null; return (
{draftSlots.map((slot) => (
{ownerMap[slot.team.id] || slot.team.name}
))}
{roundsToShow.map((roundIndex) => { if (roundIndex >= draftGrid.length) return null; const roundPicks = draftGrid[roundIndex]; const round = roundIndex + 1; const isEvenRound = round % 2 === 0; const displayPicks = isEvenRound ? [...roundPicks].toReversed() : roundPicks; return (
R{round}
{displayPicks.map((cell) => { const isCurrent = cell.pickNumber === currentPick; const isPicked = !!cell.pick; const cellState = isPicked ? "picked" : isCurrent ? "current" : "upcoming"; return ( ); })}
); })}
); });