"use client"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { CreditCard, Download } from "lucide-react"; type Payment = { id: string; amount: number; method: string; status: string; transactionId: string | null; paidAt: Date | null; createdAt: Date; appointment: { date: Date; timeSlot: string; service: { name: string; }; dentist: { name: string; }; }; }; type PaymentHistoryProps = { payments: Payment[]; }; export function PaymentHistory({ payments }: PaymentHistoryProps) { const getStatusBadge = (status: string) => { const variants: Record< string, "default" | "secondary" | "destructive" | "outline" > = { paid: "default", pending: "secondary", failed: "destructive", refunded: "outline", }; return ( {status.toUpperCase()} ); }; const getMethodIcon = () => { return ; }; const totalPaid = payments .filter((p) => p.status === "paid") .reduce((sum, p) => sum + p.amount, 0); const pendingAmount = payments .filter((p) => p.status === "pending") .reduce((sum, p) => sum + p.amount, 0); return (
{/* Summary Cards */}
Total Paid
₱{totalPaid.toFixed(2)}

All time

Pending Payments
₱{pendingAmount.toFixed(2)}

Outstanding balance

Total Transactions
{payments.length}

All payments

{/* Payment List */} Transaction History All your payment transactions {payments.length === 0 ? (

No payment history

) : (
{payments.map((payment) => (
{getMethodIcon()}

{payment.appointment.service.name}

Dr. {payment.appointment.dentist.name}

{new Date( payment.appointment.date ).toLocaleDateString()}{" "} at {payment.appointment.timeSlot}

{payment.paidAt ? `Paid on ${new Date(payment.paidAt).toLocaleDateString()}` : `Created on ${new Date(payment.createdAt).toLocaleDateString()}`}

{payment.transactionId && (

• ID: {payment.transactionId}

)}

₱{payment.amount.toFixed(2)}

{getStatusBadge(payment.status)} {payment.status === "pending" && ( )} {payment.status === "paid" && ( )}
))}
)}
); }