import type { ColumnDef } from '@tanstack/react-table'; import { Pencil, Trash2 } from 'lucide-react'; import { RowActions } from '@/components/row-actions'; export type Customer = { id: number; name: string; phone_number: string | null; address: string | null; }; type CreateColumnsParams = { handleEdit: (customer: Customer) => void; handleDeleteClick: (customer: Customer) => void; }; export function createCustomerColumns( params: CreateColumnsParams, ): ColumnDef[] { const { handleEdit, handleDeleteClick } = params; return [ { accessorKey: 'name', header: () => Nama, cell: ({ row }) => ( {row.getValue('name') as string} ), }, { accessorKey: 'phone_number', header: () => No. Telepon, cell: ({ row }) => ( {(row.getValue('phone_number') as string) ?? '-'} ), }, { accessorKey: 'address', header: () => Alamat, cell: ({ row }) => ( {(row.getValue('address') as string) ?? '-'} ), }, { id: 'actions', header: () => Aksi, meta: { className: 'w-[100px] text-center', headerClassName: 'w-[100px] text-center', }, cell: ({ row }) => { const customer = row.original; return ( , onClick: () => handleEdit(customer), }, { label: 'Hapus', icon: ( ), onClick: () => handleDeleteClick(customer), }, ]} /> ); }, }, ]; }