import type { ColumnDef } from '@tanstack/react-table'; import { Eye, Pencil, Trash2 } from 'lucide-react'; import { RowActions } from '@/components/row-actions'; import type { AcademicAdvisingLog } from '@/types/academic-advising-log'; export type { AcademicAdvisingLog } from '@/types/academic-advising-log'; type CreateColumnsParams = { handleView: (log: AcademicAdvisingLog) => void; handleEdit: (log: AcademicAdvisingLog) => void; handleDeleteClick: (log: AcademicAdvisingLog) => void; canUpdate: boolean; canDelete: boolean; }; export function createAcademicAdvisingLogColumns( params: CreateColumnsParams, ): ColumnDef[] { const { handleView, handleEdit, handleDeleteClick, canUpdate, canDelete } = params; const columns: ColumnDef[] = [ { accessorKey: 'students', header: () => Mahasiswa, cell: ({ row }) => { const students = row.original.students; if (students.length === 0) { return -; } const visible = students.slice(0, 2); const remaining = students.length - visible.length; return (
{visible.map((student) => (

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

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

))} {remaining > 0 && (

+{remaining} mahasiswa lainnya

)}
); }, }, { accessorKey: 'lecturer.user.profile.full_name', header: () => Dosen Wali, cell: ({ row }) => { const lecturer = row.original.lecturer; return (

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

{lecturer?.lecturer_number}

); }, }, { accessorKey: 'topic', header: () => Topik, cell: ({ row }) => row.original.topic ?? '-', }, ]; columns.push({ id: 'actions', header: () => Aksi, meta: { className: 'w-[100px] text-center', headerClassName: 'w-[100px] text-center', }, cell: ({ row }) => ( , onClick: () => handleView(row.original), }, { label: 'Edit', icon: , show: canUpdate, onClick: () => handleEdit(row.original), }, { label: 'Hapus', icon: ( ), show: canDelete, onClick: () => handleDeleteClick(row.original), }, ]} /> ), }); return columns; }