"use client" import { useRouter } from "next/navigation" import { ResourcePage } from "@/shared/data-view/resource-page" import { ColumnHeader } from "@/shared/data-view/table-view" import FormDialog from "@/shared/components/form-dialog" import { InvoiceForm } from "@/modules/invoices/invoice-form" import { INVOICE_ROUTES } from "@garage/api" import type { InvoicesClient } from "@garage/api" type InvoiceItem = { id: number subject?: string invoice_number?: string customer_name?: string status?: string invoice_date?: string due_date?: string created_at?: string } export default function InvoicesPage() { const router = useRouter() return ( pageTitle="Invoices" routeKey={INVOICE_ROUTES.INDEX} getClient={(api) => api.invoices} onRowClick={(row) => router.push(`/sales/invoice/${(row as any).id}`)} headerProps={({ selectedItem, invalidateQuery }) => ({ actions: ( {(resourceId) => ( )} ), })} columns={({ actionsColumn }) => [ { accessorKey: "subject", header: ({ column }) => , }, { accessorKey: "invoice_number", header: ({ column }) => , }, { accessorKey: "customer_name", header: ({ column }) => , }, { accessorKey: "status", header: ({ column }) => , cell: ({ row }) => { const item = row.original as unknown as InvoiceItem const status = item.status const colorMap: Record = { draft: "text-muted-foreground", open: "text-blue-600", paid: "text-green-600", overdue: "text-red-600", void: "text-gray-400", } return ( {status ? status.charAt(0).toUpperCase() + status.slice(1) : "—"} ) }, }, { accessorKey: "invoice_date", header: ({ column }) => , }, { accessorKey: "due_date", header: ({ column }) => , }, actionsColumn(), ]} /> ) }