"use client"; import type { ColumnDef } from "@tanstack/react-table"; import { DataTable } from "~/components/data/data-table"; const formatDate = (date: Date) => { return new Intl.DateTimeFormat("en-US", { year: "numeric", month: "short", day: "numeric", }).format(new Date(date)); }; const formatCurrency = (amount: number) => { return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", }).format(amount); }; // Type for invoice item data interface InvoiceItem { id: string; invoiceId: string; date: Date; description: string; hours: number; rate: number; amount: number; position: number; createdAt: Date; } interface InvoiceItemsTableProps { items: InvoiceItem[]; } const columns: ColumnDef[] = [ { accessorKey: "date", header: "Date", cell: ({ row }) => formatDate(row.getValue("date")), }, { accessorKey: "description", header: "Description", cell: ({ row }) => (
{row.getValue("description")}
), }, { accessorKey: "hours", header: "Hours", cell: ({ row }) => (
{row.getValue("hours")}
), }, { accessorKey: "rate", header: "Rate", cell: ({ row }) => (
{formatCurrency(row.getValue("rate"))}
), }, { accessorKey: "amount", header: "Amount", cell: ({ row }) => (
{formatCurrency(row.getValue("amount"))}
), }, ]; export function InvoiceItemsTable({ items }: InvoiceItemsTableProps) { return ( ); }