'use client' import Link from 'next/link' import type { Route } from 'next' import { Badge } from '@/components/ui/badge' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { cn } from '@/lib/utils' import { format } from 'date-fns' import { roundTypeConfig as sharedRoundTypeConfig, roundStatusConfig as sharedRoundStatusConfig, } from '@/lib/round-config' const roundTypeColors: Record = Object.fromEntries( Object.entries(sharedRoundTypeConfig).map(([k, v]) => [k, `${v.badgeClass} ${v.cardBorder}`]) ) const roundStatusConfig: Record = Object.fromEntries( Object.entries(sharedRoundStatusConfig).map(([k, v]) => [k, { icon: v.timelineIcon, color: v.timelineIconColor }]) ) type RoundSummary = { id: string name: string slug: string roundType: string status: string sortOrder: number windowOpenAt: Date | string | null windowCloseAt: Date | string | null } export function CompetitionTimeline({ rounds, }: { competitionId?: string rounds: RoundSummary[] }) { if (rounds.length === 0) { return ( No rounds configured yet. Add rounds to see the competition timeline. ) } return ( Round Timeline {/* Desktop: horizontal timeline */}
{rounds.map((round, index) => { const statusCfg = roundStatusConfig[round.status] ?? roundStatusConfig.ROUND_DRAFT const StatusIcon = statusCfg.icon const isLast = index === rounds.length - 1 return (

{round.name}

{round.roundType.replace('_', ' ')} {round.windowOpenAt && (

{format(new Date(round.windowOpenAt), 'MMM d')} {round.windowCloseAt && ( <> - {format(new Date(round.windowCloseAt), 'MMM d')} )}

)} {!isLast && (
)}
) })}
{/* Mobile: vertical timeline */}
{rounds.map((round, index) => { const statusCfg = roundStatusConfig[round.status] ?? roundStatusConfig.ROUND_DRAFT const StatusIcon = statusCfg.icon const isLast = index === rounds.length - 1 return (
{!isLast &&
}

{round.name}

{round.roundType.replace('_', ' ')}
{round.windowOpenAt && (

{format(new Date(round.windowOpenAt), 'MMM d, yyyy')} {round.windowCloseAt && ( <> - {format(new Date(round.windowCloseAt), 'MMM d, yyyy')} )}

)}
) })}
) }