import React from "react"; import { CheckCircle, Clock, AlertCircle, XCircle, StopCircle, } from "lucide-react"; import type { Debt } from "../lib/supabase"; interface DebtTimelineProps { debt: Debt; } const timelineSteps = [ { key: "received", label: "Email Received", icon: CheckCircle }, { key: "negotiating", label: "Negotiating", icon: Clock }, { key: "settled", label: "Settled", icon: CheckCircle }, ]; const statusIcons = { received: CheckCircle, negotiating: Clock, settled: CheckCircle, failed: XCircle, opted_out: StopCircle, }; const statusColors = { received: "text-blue-600 dark:text-blue-400", negotiating: "text-yellow-600 dark:text-yellow-400", settled: "text-green-600 dark:text-green-400", failed: "text-red-600 dark:text-red-400", opted_out: "text-gray-600 dark:text-gray-400", }; export function DebtTimeline({ debt }: DebtTimelineProps) { const currentStepIndex = timelineSteps.findIndex( (step) => step.key === debt.status ); return (

Progress Timeline

{timelineSteps.map((step, index) => { const isCompleted = index <= currentStepIndex; const isActive = index === currentStepIndex; const Icon = step.icon; return (
{step.label}
{isActive && (
{debt.status === "received" && "Processing email and generating response..."} {debt.status === "negotiating" && "Response generated, waiting for creditor reply"} {debt.status === "settled" && "Payment plan agreed upon"}
)}
{isActive && (
{new Date(debt.updated_at).toLocaleDateString()}
)}
); })} {/* Special cases for failed and opted_out */} {(debt.status === "failed" || debt.status === "opted_out") && (
{React.createElement(statusIcons[debt.status], { className: "h-4 w-4", })}
{debt.status === "failed" ? "Negotiation Failed" : "Opted Out"}
{debt.status === "failed" ? "Creditor declined the negotiation proposal" : "User requested to stop communication"}
{new Date(debt.updated_at).toLocaleDateString()}
)}
); }