import { ActionIcon, Badge, Menu, Text } from '@mantine/core'; import { IconDotsVertical, IconRefresh, IconUserCheck } from '@tabler/icons-react'; import type { TFunction } from 'i18next'; import type { AdvancedColumn } from '@ema-platform/ui'; import { LICENSE_PERMISSIONS, RequirePermission } from '@ema-platform/auth'; import type { AttendanceStatus, ExamRegistration } from '../../types/exam'; const ATTENDANCE_COLOR: Record = { REGISTERED: 'gray', PRESENT: 'teal', LATE: 'yellow', ABSENT: 'red', WITHDRAWN: 'orange', DISQUALIFIED: 'red', }; export const candidateName = (registration: ExamRegistration) => [ registration.profile?.firstName, registration.profile?.middleName, registration.profile?.lastName, ] .filter(Boolean) .join(' ') || registration.profileId.slice(0, 8); export function examCandidateColumns( t: TFunction, handlers: { onRecord: (registration: ExamRegistration) => void; onRegrade: (registration: ExamRegistration) => void; regrading?: string | null; }, ): AdvancedColumn[] { return [ { header: t('exam.candidates.admission'), cell: ({ row }) => ( {row.original.admissionNumber} ), }, { header: t('exam.candidates.name'), cell: ({ row }) => {candidateName(row.original)}, }, { header: t('exam.candidates.attempt'), cell: ({ row }) => ( {row.original.kind === 'RETAKE' ? t('exam.candidates.retake', { n: row.original.attemptNumber }) : t('exam.candidates.firstSitting')} ), }, { header: t('exam.candidates.attendance'), cell: ({ row }) => ( {t(`exam.attendance.${row.original.attendanceStatus}`)} ), }, { header: t('exam.candidates.remark'), cell: ({ row }) => ( {row.original.attendanceRemark ?? '—'} ), }, { header: '', label: t('exam.candidates.record'), align: 'right', cell: ({ row }) => { const attemptStatus = row.original.attempt?.status; const canRegrade = attemptStatus === 'SUBMITTED' || attemptStatus === 'EXPIRED'; return ( } onClick={() => handlers.onRecord(row.original)} > {t('exam.candidates.record')} {canRegrade && ( } onClick={() => handlers.onRegrade(row.original)} > {t('exam.candidates.regrade')} )} ); }, }, ]; }