'use client' import { cn } from '@/lib/utils' import { CheckCircle, Circle, Clock, XCircle, Trophy } from 'lucide-react' interface TimelineItem { status: string label: string date: Date | string | null completed: boolean isTerminal?: boolean } interface StatusTrackerProps { timeline: TimelineItem[] currentStatus: string className?: string } export function StatusTracker({ timeline, currentStatus, className, }: StatusTrackerProps) { const formatDate = (date: Date | string | null) => { if (!date) return null const d = typeof date === 'string' ? new Date(date) : date return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', }) } return (
{timeline.map((item, index) => { const isCompleted = item.completed const isCurrent = isCompleted && !timeline[index + 1]?.completed const isPending = !isCompleted const isRejected = item.status === 'REJECTED' && item.isTerminal const isWinner = item.status === 'WINNER' && isCompleted return (
{/* Vertical line */} {index < timeline.length - 1 && (
)} {/* Icon */}
{isRejected ? (
) : isWinner ? (
) : isCompleted ? (
{isCurrent ? ( ) : ( )}
) : (
)}
{/* Content */}

{item.label}

{isCurrent && !isRejected && !isWinner && ( Current )} {isRejected && ( Final )} {isWinner && ( Winner )}
{item.date && (

{formatDate(item.date)}

)} {isPending && !isCurrent && !isRejected && (

Pending

)}
) })}
) } // Compact horizontal version interface StatusBarProps { status: string statuses: { value: string; label: string }[] className?: string } export function StatusBar({ status, statuses, className }: StatusBarProps) { const currentIndex = statuses.findIndex((s) => s.value === status) return (
{statuses.map((s, index) => { const isCompleted = index <= currentIndex const isCurrent = index === currentIndex return (
{index > 0 && (
)}
{isCompleted && !isCurrent && ( )} {s.label}
) })}
) }