- 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.
85 lines
3.0 KiB
TypeScript
85 lines
3.0 KiB
TypeScript
import { RowActions } from '@/components/row-actions';
|
|
import type { ColumnDef } from '@tanstack/react-table';
|
|
import { Key, Pencil, Trash2 } from 'lucide-react';
|
|
|
|
export type Lecturer = {
|
|
id: number;
|
|
username: string;
|
|
email: string;
|
|
profile: { full_name: string } | null;
|
|
lecturer: { lecturer_number: string; department: { name: string } | null } | null;
|
|
};
|
|
|
|
type CreateColumnsParams = {
|
|
handleEdit: (lecturer: Lecturer) => void;
|
|
handleDeleteClick: (lecturer: Lecturer) => void;
|
|
handleResetPassword: (lecturer: Lecturer) => void;
|
|
};
|
|
|
|
export function createLecturerColumns(
|
|
params: CreateColumnsParams,
|
|
): ColumnDef<Lecturer>[] {
|
|
const { handleEdit, handleDeleteClick, handleResetPassword } = params;
|
|
|
|
return [
|
|
{
|
|
accessorKey: 'lecturer.lecturer_number',
|
|
header: () => <span>NIDN</span>,
|
|
cell: ({ row }) => row.original.lecturer?.lecturer_number ?? '-',
|
|
},
|
|
{
|
|
accessorKey: 'profile.full_name',
|
|
header: () => <span>Nama Lengkap</span>,
|
|
cell: ({ row }) => row.original.profile?.full_name ?? '-',
|
|
},
|
|
{
|
|
id: 'account',
|
|
header: () => <span>Akun</span>,
|
|
cell: ({ row }) => (
|
|
<div className="flex flex-col">
|
|
<span>{row.original.username}</span>
|
|
<span className="text-sm text-muted-foreground">{row.original.email}</span>
|
|
</div>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: 'lecturer.department.name',
|
|
header: () => <span>Jurusan</span>,
|
|
cell: ({ row }) => row.original.lecturer?.department?.name ?? '-',
|
|
},
|
|
{
|
|
id: 'actions',
|
|
header: () => <span className="block text-center">Aksi</span>,
|
|
meta: {
|
|
className: 'w-[100px] text-center',
|
|
headerClassName: 'w-[100px] text-center',
|
|
},
|
|
cell: ({ row }) => {
|
|
const lecturer = row.original;
|
|
|
|
return (
|
|
<RowActions
|
|
actions={[
|
|
{
|
|
label: 'Edit',
|
|
icon: <Pencil className="h-4 w-4" />,
|
|
onClick: () => handleEdit(lecturer),
|
|
},
|
|
{
|
|
label: 'Reset Password',
|
|
icon: <Key className="h-4 w-4" />,
|
|
onClick: () => handleResetPassword(lecturer),
|
|
},
|
|
{
|
|
label: 'Hapus',
|
|
icon: <Trash2 className="h-4 w-4 text-destructive" />,
|
|
onClick: () => handleDeleteClick(lecturer),
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
},
|
|
},
|
|
];
|
|
}
|