import type { ColumnDef } from '@tanstack/react-table'; import { Check, Eye, X } from 'lucide-react'; import { RowActions } from '@/components/row-actions'; import { Badge } from '@/components/ui/badge'; import { show } from '@/routes/admin/manage/course-registrations'; import type { CourseRegistrationSubmission } from '@/types/course-registration'; import { RegistrationStatusLabels } from '@/types/course-registration'; export type { CourseRegistrationSubmission } from '@/types/course-registration'; type CreateColumnsParams = { handleApprove: (submission: CourseRegistrationSubmission) => void; handleRejectClick: (submission: CourseRegistrationSubmission) => void; }; export function createCourseRegistrationColumns( params: CreateColumnsParams, ): ColumnDef[] { const { handleApprove, handleRejectClick } = params; return [ { id: 'student', header: () => Mahasiswa, cell: ({ row }) => { const student = row.original.student; return (

{student?.user?.profile?.full_name ?? 'N/A'}

{student?.student_number} ·{' '} {student?.department?.name ?? '-'}

); }, }, { id: 'semester', header: () => Semester, meta: { className: 'w-[100px] text-center', headerClassName: 'w-[100px] text-center', }, cell: ({ row }) => row.original.student?.current_semester ?? '-', }, { id: 'count', header: () => Jumlah, meta: { className: 'w-[100px] text-center', headerClassName: 'w-[100px] text-center', }, cell: ({ row }) => row.original.course_registrations.length, }, { accessorKey: 'status', header: () => Status, meta: { className: 'w-[140px] text-center', headerClassName: 'w-[140px] text-center', }, cell: ({ row }) => { const status = row.original.status; return (
{RegistrationStatusLabels[status]}
); }, }, { id: 'actions', header: () => Aksi, meta: { className: 'w-[130px] text-center', headerClassName: 'w-[130px] text-center', }, cell: ({ row }) => { const submission = row.original; return ( , href: show.url(submission.id), }, { label: 'Setujui', icon: , iconClassName: 'text-primary', show: submission.status === 'submitted', onClick: () => handleApprove(submission), }, { label: 'Tolak', icon: , iconClassName: 'text-destructive', show: submission.status === 'submitted', onClick: () => handleRejectClick(submission), }, ]} /> ); }, }, ]; }