import { format } from "date-fns"; import { ChevronRight, ChessPawn, Hourglass, LayoutGrid } from "lucide-react"; import { Link } from "react-router"; import { formatClockTime } from "~/lib/draft-timer"; import { Button } from "~/components/ui/button"; import { Card, CardContent, CardHeader } from "~/components/ui/card"; import { GradientIcon } from "~/components/ui/GradientIcon"; // ─── Types ──────────────────────────────────────────────────────────────────── export interface DraftInfoCardProps { draftRounds: number; draftTimerMode: "standard" | "chess_clock"; /** Per-pick time for standard; initial bank for chess clock (seconds) */ draftInitialTime: number; /** Bonus seconds added after each pick (chess clock only; ignored in standard) */ draftIncrementTime: number; sportsCount: number; isDraftOrderSet: boolean; /** true when season status is pre_draft or draft */ isDraftOrPreDraft: boolean; draftDateTime?: string | Date | null; draftBoardHref: string; draftRoomHref: string; /** 1-based draft position for the current user; omit or undefined to hide the panel */ userDraftPosition?: number; } // ─── Sub-components ─────────────────────────────────────────────────────────── function InfoPanel({ label, value, sub }: { label: string; value: React.ReactNode; sub?: React.ReactNode }) { return (
{label} {value} {sub && {sub}}
); } // ─── Card variant (pre_draft / draft) ───────────────────────────────────────── function DraftInfoCardVariant({ draftRounds, draftTimerMode, draftInitialTime, draftIncrementTime, sportsCount, isDraftOrderSet, draftDateTime, draftRoomHref, userDraftPosition, }: DraftInfoCardProps) { const flexSpots = Math.max(0, draftRounds - sportsCount); const timerLabel = draftTimerMode === "chess_clock" ? "Chess Clock" : "Standard Timer"; const timerValue = formatClockTime(draftInitialTime); const timerSub = draftTimerMode === "chess_clock" ? `+${formatClockTime(draftIncrementTime)} per pick` : "per pick"; const roundsSub = [ `${sportsCount} sport${sportsCount !== 1 ? "s" : ""}`, flexSpots > 0 ? `${flexSpots} flex` : null, ].filter(Boolean).join(" + "); return (

Draft Info

{isDraftOrderSet && ( )}
{/* Draft Date */} {/* Rounds */} {/* User's Draft Position (only when set) */} {userDraftPosition !== null && userDraftPosition !== undefined && ( )} {/* Timer */} {draftTimerMode === "chess_clock" ? : } {timerValue} } sub={timerSub} />
); } // ─── Helpers ────────────────────────────────────────────────────────────────── /** Converts a seconds value to a short human-readable string, e.g. "1 minute", "10 seconds", "2 hours". */ function formatHumanTime(seconds: number): string { const h = Math.floor(seconds / 3600); const m = Math.floor((seconds % 3600) / 60); const s = seconds % 60; const parts: string[] = []; if (h > 0) parts.push(`${h} hour${h !== 1 ? "s" : ""}`); if (m > 0) parts.push(`${m} minute${m !== 1 ? "s" : ""}`); if (s > 0) parts.push(`${s} second${s !== 1 ? "s" : ""}`); return parts.join(" ") || "0 seconds"; } // ─── Bare variant (active / completed) ──────────────────────────────────────── function DraftInfoBareVariant({ draftRounds, draftTimerMode, draftInitialTime, draftIncrementTime, sportsCount, draftDateTime, draftBoardHref, }: DraftInfoCardProps) { const flexSpots = Math.max(0, draftRounds - sportsCount); return (
Draft
View Draft Board
{/* Mode icon */}
{draftTimerMode === "chess_clock" ? : }
{draftDateTime && (
{format(new Date(draftDateTime), "MMM d, yyyy")} | {format(new Date(draftDateTime), "p")}
)}
{draftRounds} rounds ({sportsCount} sport{sportsCount !== 1 ? "s" : ""} {flexSpots > 0 && ` + ${flexSpots} flex`})
{draftTimerMode === "standard" ? `Standard — ${formatHumanTime(draftInitialTime)}/pick` : `Chess Clock — ${formatHumanTime(draftInitialTime)} + ${formatHumanTime(draftIncrementTime)} increment`}
); } // ─── Public API ─────────────────────────────────────────────────────────────── export function DraftInfoCard(props: DraftInfoCardProps) { if (props.isDraftOrPreDraft) { return ; } return ; }