import { RowActions } from '@/components/row-actions'; import type { ColumnDef } from '@tanstack/react-table'; import { Key, Pencil, Trash2 } from 'lucide-react'; export type Student = { id: number; username: string; email: string; profile: { full_name: string } | null; student: { student_number: string; department: { name: string } | null; enrollment_year: number; status: string | null } | null; }; type CreateColumnsParams = { handleEdit: (student: Student) => void; handleDeleteClick: (student: Student) => void; handleResetPassword: (student: Student) => void; }; export function createStudentColumns( params: CreateColumnsParams, ): ColumnDef[] { const { handleEdit, handleDeleteClick, handleResetPassword } = params; return [ { accessorKey: 'student.student_number', header: () => NIM, cell: ({ row }) => row.original.student?.student_number ?? '-', }, { accessorKey: 'profile.full_name', header: () => Nama Lengkap, cell: ({ row }) => row.original.profile?.full_name ?? '-', }, { id: 'account', header: () => Akun, cell: ({ row }) => (
{row.original.username} {row.original.email}
), }, { accessorKey: 'student.department.name', header: () => Jurusan, cell: ({ row }) => row.original.student?.department?.name ?? '-', }, { accessorKey: 'student.enrollment_year', header: () => Angkatan, cell: ({ row }) => row.original.student?.enrollment_year ?? '-', }, { accessorKey: 'student.status', header: () => Status, cell: ({ row }) => row.original.student?.status ?? '-', }, { id: 'actions', header: () => Aksi, meta: { className: 'w-[100px] text-center', headerClassName: 'w-[100px] text-center', }, cell: ({ row }) => { const student = row.original; return ( , onClick: () => handleEdit(student), }, { label: 'Reset Password', icon: , onClick: () => handleResetPassword(student), }, { label: 'Hapus', icon: , onClick: () => handleDeleteClick(student), }, ]} /> ); }, }, ]; }