dstpabuaran.com/resources/js/pages/admin/roles/columns.tsx
Yoga Pangestu d91ec8869e refactor: replace tooltip buttons with row actions component in supplier and role columns
feat: implement delete confirmation dialog component for better UX

refactor: update supplier and role index pages to utilize new form dialog and delete confirm dialog components

feat: add reusable form dialog component for creating and editing entities

feat: introduce filter popover component for enhanced filtering options in data tables

feat: create image preview button component for displaying images with modal preview

feat: add page header component for consistent page layout

feat: implement row actions component for handling actions on table rows

feat: add status badge component for displaying entity statuses

feat: create toggle status component for easily toggling entity states

feat: implement draft save hook for auto-saving form data

feat: add server table hook for managing server-side pagination and filtering

feat: create utility functions for formatting dates and numbers

feat: add constants for month names and measurement units
2026-08-02 23:40:12 +07:00

78 lines
2.4 KiB
TypeScript

import type { ColumnDef } from '@tanstack/react-table';
import { Pencil, Trash2 } from 'lucide-react';
import { RowActions } from '@/components/row-actions';
export type Role = {
id: number;
name: string;
permissions_count: number;
};
type CreateColumnsParams = {
handleEdit: (role: Role) => void;
handleDeleteClick: (role: Role) => void;
};
export function createRoleColumns(
params: CreateColumnsParams,
): ColumnDef<Role>[] {
const { handleEdit, handleDeleteClick } = params;
return [
{
accessorKey: 'name',
header: () => <span>Nama Role</span>,
cell: ({ row }) => (
<span className="font-medium">
{row.getValue('name') as string}
</span>
),
},
{
accessorKey: 'permissions_count',
header: () => (
<span className="block text-center">Jumlah Permission</span>
),
meta: {
className: 'w-[180px] text-center',
headerClassName: 'w-[180px] text-center',
},
cell: ({ row }) => (
<span className="inline-flex items-center rounded-md bg-muted px-2 py-1 text-xs font-medium">
{row.getValue('permissions_count') as number} permission
</span>
),
},
{
id: 'actions',
header: () => <span className="block text-center">Aksi</span>,
meta: {
className: 'w-[100px] text-center',
headerClassName: 'w-[100px] text-center',
},
cell: ({ row }) => {
const role = row.original;
return (
<RowActions
actions={[
{
label: 'Edit',
icon: <Pencil className="h-4 w-4" />,
onClick: () => handleEdit(role),
},
{
label: 'Hapus',
icon: (
<Trash2 className="h-4 w-4 text-destructive" />
),
onClick: () => handleDeleteClick(role),
},
]}
/>
);
},
},
];
}