"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 (
All time
Outstanding balance
All payments
No payment history
) : ({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" && ( )}