import { DataTableColumnHeader } from '@/components/data-table-column-header'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/tooltip'; import { usePermission } from '@/hooks/use-permission'; import roleRoutes from '@/routes/system/role'; import type { Role } from '@/types'; import { Link } from '@inertiajs/react'; import type { ColumnDef } from '@tanstack/react-table'; import { Pencil, Trash2 } from 'lucide-react'; interface ColumnProps { onDelete: (role: Role) => void; } export const getColumns = ({ onDelete }: ColumnProps): ColumnDef[] => [ { accessorKey: 'name', header: ({ column }) => ( ), meta: { title: 'Nama' }, }, { accessorKey: 'permissions', header: 'Izin Akses', meta: { title: 'Izin Akses' }, cell: ({ row }) => { const permissions = row.original.permissions || []; if (permissions.length === 0) { return ( Tidak ada izin akses ); } return (
{permissions.map((p) => ( {p.name} ))}
); }, }, { accessorKey: 'guard_name', header: ({ column }) => ( ), meta: { title: 'Guard' }, }, { id: 'actions', header: 'Aksi', cell: ({ row }) => { const role = row.original; const { hasPermission } = usePermission(); return (
{hasPermission('Edit:Role') && (

Ubah

)} {hasPermission('Delete:Role') && (

Hapus

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