'use client'
import { cn } from '@/lib/utils'
import { CheckCircle, Circle, Clock } from 'lucide-react'
interface TimelineItem {
status: string
label: string
date: Date | string | null
completed: 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
return (
{/* Vertical line */}
{index < timeline.length - 1 && (
)}
{/* Icon */}
{isCompleted ? (
{isCurrent ? (
) : (
)}
) : (
)}
{/* Content */}
{item.label}
{isCurrent && (
Current
)}
{item.date && (
{formatDate(item.date)}
)}
{isPending && !isCurrent && (
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}
)
})}
)
}