import type { ColumnDef } from '@tanstack/react-table'; import { Pencil, Trash2 } from 'lucide-react'; import { RowActions } from '@/components/row-actions'; import { Badge } from '@/components/ui/badge'; import type { Department } from '@/types/department'; export type { Department } from '@/types/department'; type CreateColumnsParams = { handleEdit: (department: Department) => void; handleDeleteClick: (department: Department) => void; canUpdate: boolean; canDelete: boolean; }; export function createDepartmentColumns( params: CreateColumnsParams, ): ColumnDef[] { const { handleEdit, handleDeleteClick, canUpdate, canDelete } = params; return [ { accessorKey: 'code', header: () => Kode, cell: ({ row }) => ( {row.getValue('code') as string} ), }, { accessorKey: 'name', header: () => Nama, cell: ({ row }) => {row.getValue('name') as string}, }, { accessorKey: 'degree_level', header: () => Jenjang, meta: { className: 'w-[100px] text-center', headerClassName: 'w-[100px] text-center', }, cell: ({ row }) => { const degreeLevel = row.getValue('degree_level') as string | null; return (
{degreeLevel ? ( {degreeLevel} ) : ( - )}
); }, }, { id: 'actions', header: () => Aksi, meta: { className: 'w-[100px] text-center', headerClassName: 'w-[100px] text-center', }, cell: ({ row }) => { const department = row.original; return ( , show: canUpdate, onClick: () => handleEdit(department), }, { label: 'Hapus', icon: ( ), show: canDelete, onClick: () => handleDeleteClick(department), }, ]} /> ); }, }, ]; }