'use client' import { trpc } from '@/lib/trpc/client' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Skeleton } from '@/components/ui/skeleton' import { CheckCircle2, Circle, Clock } from 'lucide-react' import { toast } from 'sonner' interface ApplicantCompetitionTimelineProps { competitionId: string } const statusIcons: Record = { completed: CheckCircle2, current: Clock, upcoming: Circle, } const statusColors: Record = { completed: 'text-emerald-600', current: 'text-brand-blue', upcoming: 'text-muted-foreground', } const statusBgColors: Record = { completed: 'bg-emerald-50', current: 'bg-brand-blue/10', upcoming: 'bg-muted', } export function ApplicantCompetitionTimeline({ competitionId }: ApplicantCompetitionTimelineProps) { const { data: competition, isLoading } = trpc.competition.getById.useQuery( { id: competitionId }, { enabled: !!competitionId } ) if (isLoading) { return (
{[1, 2, 3].map((i) => ( ))}
) } if (!competition || !competition.rounds || competition.rounds.length === 0) { return ( Competition Timeline

No rounds available

) } const rounds = competition.rounds || [] const currentRoundIndex = rounds.findIndex(r => r.status === 'ROUND_ACTIVE') return ( Competition Timeline
{/* Vertical connecting line */}
{rounds.map((round, index) => { const isActive = round.status === 'ROUND_ACTIVE' const isCompleted = index < currentRoundIndex || round.status === 'ROUND_CLOSED' || round.status === 'ROUND_ARCHIVED' const isCurrent = index === currentRoundIndex || isActive const status = isCompleted ? 'completed' : isCurrent ? 'current' : 'upcoming' const Icon = statusIcons[status] return (
{/* Icon */}
{/* Content */}

{round.name}

{status === 'completed' && 'Completed'} {status === 'current' && 'In Progress'} {status === 'upcoming' && 'Upcoming'}
{round.windowOpenAt && round.windowCloseAt && (

Opens: {new Date(round.windowOpenAt).toLocaleDateString()}

Closes: {new Date(round.windowCloseAt).toLocaleDateString()}

)}
) })}
) }