import { ColumnDef } from '@tanstack/react-table'; import { Expense } from '@/types'; import { DataTableColumnHeader } from '@/components/data-table-column-header'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; import { Button } from '@/components/ui/button'; import { Pencil, Trash2, ImagePlus } from 'lucide-react'; interface ColumnProps { onEdit: (expense: Expense) => void; onDelete: (expense: Expense) => void; onPreviewImage: (url: string) => void; } const formatCurrency = (amount: number) => { return new Intl.NumberFormat('id-ID', { style: 'currency', currency: 'IDR', minimumFractionDigits: 0, }).format(amount); }; export const getColumns = ({ onEdit, onDelete, onPreviewImage }: ColumnProps): ColumnDef[] => [ { accessorKey: "proof_url", header: "Bukti", cell: ({ row }) => { const url = row.original.proof_url; return url ? ( ) : (
); }, meta: { title: "Bukti" }, }, { accessorKey: "user.name", header: ({ column }) => ( ), cell: ({ row }) => row.original.user?.name, meta: { title: "Pegawai" }, }, { accessorKey: "name", header: ({ column }) => ( ), meta: { title: "Nama" }, }, { accessorKey: "amount", header: ({ column }) => ( ), cell: ({ row }) => formatCurrency(row.original.amount), meta: { title: "Nominal" }, }, { accessorKey: "created_at", header: ({ column }) => ( ), cell: ({ row }) => new Date(row.original.created_at).toLocaleDateString('id-ID', { day: '2-digit', month: 'long', year: 'numeric' }), meta: { title: "Tanggal" }, }, { id: "actions", header: "Aksi", cell: ({ row }) => { const expense = row.original; return (

Ubah

Hapus

); }, meta: { title: "Aksi" }, }, ];