"use client" import { CheckCircle2, Circle, Clock, Package, Truck, Flag } from "lucide-react" import { motion } from "framer-motion" interface OrderTimelineProps { status: string; orderDate: Date | string; paidAt?: Date | string; completedAt?: Date | string; } const steps = [ { status: "unpaid", label: "Ordered", icon: Clock }, { status: "paid", label: "Paid", icon: CheckCircle2 }, { status: "acknowledged", label: "Processing", icon: Package }, { status: "shipped", label: "Shipped", icon: Truck }, { status: "completed", label: "Completed", icon: Flag }, ] export default function OrderTimeline({ status, orderDate, paidAt }: OrderTimelineProps) { const currentStatusIndex = steps.findIndex(step => step.status === status || (status === "confirming" && step.status === "unpaid") || (status === "acknowledged" && step.status === "paid") // Processed is after paid ); // If status is "confirming", it's basically "unpaid" for the timeline // If status is "acknowledged", it's "Processing" const getStepStatus = (index: number) => { // Basic logic to determine if a step is completed, current, or pending let effectiveIndex = currentStatusIndex; if (status === "confirming") effectiveIndex = 0; if (status === "paid") effectiveIndex = 1; if (status === "acknowledged") effectiveIndex = 2; if (status === "shipped") effectiveIndex = 3; if (status === "completed") effectiveIndex = 4; if (index < effectiveIndex) return "completed"; if (index === effectiveIndex) return "current"; return "pending"; }; return (
{/* Connector Line */}
s.status === status)) / (steps.length - 1)) * 100}%` }} transition={{ duration: 1, ease: "easeInOut" }} />
{steps.map((step, index) => { const stepStatus = getStepStatus(index); const Icon = step.icon; return (

{step.label}

); })}
) }