siakad-itm/resources/js/pages/admin/master/departments/columns.tsx
Yoga Pangestu 2885de2c20 feat: add lecturer and student management pages with CRUD functionality
- Implemented LecturerEdit and LecturerIndex components for managing lecturers.
- Created StudentCreate and StudentEdit components for adding and editing students.
- Developed StudentIndex component for listing students with search and pagination.
- Added department and user types for better type safety.
- Updated routes for lecturers and students, including reset password functionality.
- Removed AppSidebar from dashboard for a cleaner layout.
2026-08-21 14:14:01 +07:00

88 lines
3.0 KiB
TypeScript

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;
};
export function createDepartmentColumns(
params: CreateColumnsParams,
): ColumnDef<Department>[] {
const { handleEdit, handleDeleteClick } = params;
return [
{
accessorKey: 'code',
header: () => <span>Kode</span>,
cell: ({ row }) => (
<span className="font-medium">
{row.getValue('code') as string}
</span>
),
},
{
accessorKey: 'name',
header: () => <span>Nama</span>,
cell: ({ row }) => <span>{row.getValue('name') as string}</span>,
},
{
accessorKey: 'degree_level',
header: () => <span className="block text-center">Jenjang</span>,
meta: {
className: 'w-[100px] text-center',
headerClassName: 'w-[100px] text-center',
},
cell: ({ row }) => {
const degreeLevel = row.getValue('degree_level') as
string | null;
return (
<div className="flex justify-center">
{degreeLevel ? (
<Badge variant="secondary">{degreeLevel}</Badge>
) : (
<span className="text-muted-foreground">-</span>
)}
</div>
);
},
},
{
id: 'actions',
header: () => <span className="block text-center">Aksi</span>,
meta: {
className: 'w-[100px] text-center',
headerClassName: 'w-[100px] text-center',
},
cell: ({ row }) => {
const department = row.original;
return (
<RowActions
actions={[
{
label: 'Edit',
icon: <Pencil className="h-4 w-4" />,
onClick: () => handleEdit(department),
},
{
label: 'Hapus',
icon: (
<Trash2 className="h-4 w-4 text-destructive" />
),
onClick: () => handleDeleteClick(department),
},
]}
/>
);
},
},
];
}