"use client" import { CrudResource } 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_RECEIVED_ROUTES, PaymentReceivedClient } from "@garage/api" import { BadgeDollarSignIcon, CalendarIcon, ChevronDown, CreditCardIcon, HashIcon, } from "lucide-react" import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card" import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/shared/components/ui/collapsible" import { Button } from "@/shared/components/ui/button" import { useJobCard } from "./job-card-context" import { formatDate, formatCurrency } from "@/shared/utils/formatters" export default function JobCardPaymentsReceived() { const jobCard = useJobCard() return (
Payments Received
extraParams={{ job_card_id: jobCard?.id }} routeKey={PAYMENT_RECEIVED_ROUTES.INDEX} getClient={(api) => api.paymentReceived} tableHeader={({ invalidateQuery }) =>
{(resourceId) => ( )}
} columns={({ actionsColumn }) => [ { accessorKey: "payment_number", header: ({ column }) => , cell: ({ row }) => { const item = row.original return (
{item.payment_number || "—"}
) }, }, { accessorKey: "amount_received", header: ({ column }) => , cell: ({ row }) => { const item = row.original return (
{formatCurrency(item.amount_received)}
) }, }, { accessorKey: "payment_mode", header: ({ column }) => , cell: ({ row }) => { const item = row.original as any return (
{(item.payment_mode?.title) || "—"}
) }, }, { accessorKey: "payment_date", header: ({ column }) => , cell: ({ row }) => { const item = row.original return (
{formatDate(item.payment_date)}
) }, }, { accessorKey: "note", header: () => Note, enableSorting: false, cell: ({ row }) => { const item = row.original const note = item.note if (!note) return return ( {note} ) }, }, actionsColumn(), ]} />
) }