import type { ColumnDef } from '@tanstack/react-table';
import { Eye } from 'lucide-react';
import { RowActions } from '@/components/row-actions';
import { show } from '@/routes/admin/manage/course-registrations';
import type { CourseRegistrationRow } from '@/types/course-registration';

export type { CourseRegistrationRow } from '@/types/course-registration';

export function createCourseRegistrationColumns(): ColumnDef<CourseRegistrationRow>[] {
    return [
        {
            id: 'student',
            header: () => <span>Mahasiswa</span>,
            cell: ({ row }) => {
                const student = row.original.student;

                return (
                    <div>
                        <p className="font-medium">
                            {student?.user?.profile?.full_name ?? 'N/A'}
                        </p>
                        <p className="text-xs text-muted-foreground">
                            {student?.student_number}
                        </p>
                    </div>
                );
            },
        },
        {
            id: 'actions',
            header: () => <span className="block text-center">Aksi</span>,
            meta: {
                className: 'w-[80px] text-center',
                headerClassName: 'w-[80px] text-center',
            },
            cell: ({ row }) => (
                <RowActions
                    actions={[
                        {
                            label: 'Lihat Detail',
                            icon: <Eye className="h-4 w-4" />,
                            href: show.url(row.original.student_id),
                        },
                    ]}
                />
            ),
        },
    ];
}
