import { ColumnHeader } from "@/shared/data-view/table-view"
import { Money } from "@/shared/components/money"
import type { ColumnDef } from "@tanstack/react-table"

/** Core expense-item columns shared between the expense items page and selector dialogs. */
export const expenseItemColumns = {
    name: {
        accessorKey: "item_name",
        header: ({ column }) => <ColumnHeader column={column} title="Item Name" />,
        cell: ({ row }) => {
            const r = row.original as any
            return <span className="font-medium">{r.item_name || "—"}</span>
        },
    },
    purchasePrice: {
        accessorKey: "purchase_price",
        header: ({ column }) => <ColumnHeader column={column} title="Purchase Price" />,
        cell: ({ row }) => {
            const val = (row.original as any).purchase_price
            return val != null ? <Money value={val} /> : "—"
        },
    },
    chartOfAccount: {
        accessorKey: "purchase_chart_of_account",
        header: ({ column }) => <ColumnHeader column={column} title="Chart of Account" />,
        cell: ({ row }) => (row.original as any).purchase_chart_of_account || "—",
    },
} satisfies Record<string, ColumnDef<any, any>>
