import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import { Link } from '@inertiajs/react'; import { ColumnDef } from '@tanstack/react-table'; import { format } from 'date-fns'; import { AlertCircle, CheckCircle, Clock, Eye, MoreVertical, Pencil } from 'lucide-react'; import AssignmentForm from './forms/assignment-form'; const AssignmentTableColumn = (slug: string, translate: LanguageTranslations, enrollmentsCount: number): ColumnDef[] => { const { table } = translate; return [ { accessorKey: 'title', header: 'Assignment Details', cell: ({ row }) => { const assignment = row.original; return (

{assignment.title}

Total: {assignment.total_mark} Pass: {assignment.pass_mark} Retakes: {assignment.retake}
); }, }, { accessorKey: 'deadline', header: 'Deadline', cell: ({ row }) => { const deadline = row.getValue('deadline') as string; const isExpired = new Date() > new Date(deadline); return (
{isExpired ? ( ) : ( )}

{format(new Date(deadline), 'MMM dd, yyyy')}

{format(new Date(deadline), 'hh:mm a')}

{isExpired && ( Expired )}
); }, }, { accessorKey: 'late_submission', header: () =>
Late Submission
, cell: ({ row }) => { const assignment = row.original; const lateAllowed = assignment.late_submission; return (
{lateAllowed ? 'Allowed' : 'Not Allowed'} {lateAllowed && assignment.late_deadline && (
Until: {format(new Date(assignment.late_deadline), 'MMM dd')}
)}
); }, }, { accessorKey: 'submissions', header: () =>
Submissions
, cell: ({ row }) => { const assignment = row.original; const totalSubmissions = assignment.submissions?.length || 0; const gradedCount = assignment.submissions?.filter((s) => s.status === 'graded').length || 0; const pendingCount = totalSubmissions - gradedCount; return (
{totalSubmissions} of {enrollmentsCount} {/*
{totalSubmissions}
✓ {gradedCount} {pendingCount > 0 && ⏳ {pendingCount}}
*/}
); }, }, { id: 'actions', header: () =>
{table.action}
, cell: ({ row }) => { const assignment = row.original; return (
View Submissions e.preventDefault()} className="flex w-full cursor-pointer items-center gap-2"> Update Assignment } />
); }, }, ]; }; export default AssignmentTableColumn;