'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 { CheckCircle2, Circle, Clock } from 'lucide-react' const roundTypeColors: Record = { INTAKE: 'bg-gray-100 text-gray-700 border-gray-300', FILTERING: 'bg-amber-100 text-amber-700 border-amber-300', EVALUATION: 'bg-blue-100 text-blue-700 border-blue-300', SUBMISSION: 'bg-purple-100 text-purple-700 border-purple-300', MENTORING: 'bg-teal-100 text-teal-700 border-teal-300', LIVE_FINAL: 'bg-red-100 text-red-700 border-red-300', DELIBERATION: 'bg-indigo-100 text-indigo-700 border-indigo-300', } const roundStatusConfig: Record = { ROUND_DRAFT: { icon: Circle, color: 'text-gray-400' }, ROUND_ACTIVE: { icon: Clock, color: 'text-emerald-500' }, ROUND_CLOSED: { icon: CheckCircle2, color: 'text-blue-500' }, ROUND_ARCHIVED: { icon: CheckCircle2, color: 'text-gray-400' }, } 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')} )}

)}
) })}
) }