import type { ColumnDef } from '@tanstack/react-table'; import { ArrowUpDown, Pencil, Trash2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; 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 [ { id: 'no', header: () => No, cell: ({ row }) => ( {row.index + 1} ), meta: { className: 'w-[50px] text-center', headerClassName: 'w-[50px] text-center', }, }, { accessorKey: 'name', header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue('name') as string} ), }, { accessorKey: 'phone_number', header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue('phone_number') as string ?? '-'} ), }, { accessorKey: 'address', header: ({ column }) => ( ), 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 (
Edit Hapus
); }, }, ]; }