"use client" import { ResourcePage } from "@/shared/data-view/resource-page" import { ColumnHeader } from "@/shared/data-view/table-view" import FormDialog from "@/shared/components/form-dialog" import { PaymentReceivedForm } from "@/modules/payment-received/payment-received-form" import { PAYMENT_ROUTES } from "@garage/api" import { BadgeDollarSignIcon, CalendarIcon, CreditCardIcon, HashIcon, UserIcon, ClipboardListIcon, } from "lucide-react" type PaymentReceivedItem = { id: number payment_number?: string customer_name?: string job_card_name?: string job_card_number?: string payment_mode_name?: string amount_received?: string | number payment_date?: string note?: string status?: string created_at?: string } export default function PaymentReceivedPage() { return ( ; destroy(id: string): Promise }> pageTitle="Payments Received" routeKey={PAYMENT_ROUTES.RECEIVED} getClient={(api) => ({ list: (query?: any) => api.payments.listReceived(query), destroy: (id: string) => api.payments.destroyReceived(id), })} headerProps={({ invalidateQuery }) => ({ actions: ( {(resourceId) => ( )} ), })} columns={({ actionsColumn }) => [ { accessorKey: "payment_number", header: ({ column }) => , cell: ({ row }) => { const item = row.original as unknown as PaymentReceivedItem return (
{item.payment_number || "—"}
) }, }, { accessorKey: "customer_name", header: ({ column }) => , cell: ({ row }) => { const item = row.original as unknown as PaymentReceivedItem return (
{item.customer_name || "—"}
) }, }, { accessorKey: "job_card_name", header: ({ column }) => , cell: ({ row }) => { const item = row.original as unknown as PaymentReceivedItem const label = item.job_card_number || item.job_card_name return (
{label || "—"}
) }, }, { accessorKey: "amount_received", header: ({ column }) => , cell: ({ row }) => { const item = row.original as unknown as PaymentReceivedItem const amount = item.amount_received ? Number(item.amount_received).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2, }) : "—" return (
{amount}
) }, }, { accessorKey: "payment_mode_name", header: ({ column }) => , cell: ({ row }) => { const item = row.original as unknown as PaymentReceivedItem return (
{item.payment_mode_name || "—"}
) }, }, { accessorKey: "payment_date", header: ({ column }) => , cell: ({ row }) => { const item = row.original as unknown as PaymentReceivedItem const formatted = item.payment_date ? new Date(item.payment_date).toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric", }) : "—" return (
{formatted}
) }, }, { accessorKey: "note", header: () => Note, enableSorting: false, cell: ({ row }) => { const item = row.original as unknown as PaymentReceivedItem const note = item.note if (!note) return return ( {note} ) }, }, actionsColumn(), ]} /> ) }