import type { ColumnDef } from '@tanstack/react-table';
import { format } from 'date-fns';
import type { AcademicAdvisingLog } from '@/types/academic-advising-log';

export const advisingLogColumns: ColumnDef<AcademicAdvisingLog>[] = [
    {
        accessorKey: 'student.student_number',
        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>
            );
        },
    },
    {
        accessorKey: 'topic',
        header: () => <span>Topik</span>,
        cell: ({ row }) => row.original.topic || '-',
    },
    {
        accessorKey: 'notes',
        header: () => <span>Catatan</span>,
        cell: ({ row }) => (
            <p className="line-clamp-2 max-w-sm text-muted-foreground">
                {row.original.notes || '-'}
            </p>
        ),
    },
    {
        accessorKey: 'session_date',
        header: () => <span>Tanggal Sesi</span>,
        cell: ({ row }) => {
            const sessionDate = row.original.session_date;

            return sessionDate
                ? format(new Date(sessionDate), 'd MMM yyyy, HH:mm')
                : '-';
        },
    },
];
