"use client" import { ColumnDef } from "@tanstack/react-table" import { Checkbox } from "@/shared/components/ui/checkbox" import { Badge, type BadgeProps } from "@/shared/components/ui/badge" import { cn, formatDate } from "@/shared/lib/utils" import { Exam } from "../types" import { ExamActions } from "./exam-actions" export const examColumns: ColumnDef[] = [ { id: "select", header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Select row" /> ), enableSorting: false, enableHiding: false, size: 36, }, { accessorKey: "title", header: "Exam Info", cell: ({ row }) => (
{row.original.title} {row.original.tags && row.original.tags.length > 0 && (
{row.original.tags.slice(0, 2).map((t, idx) => ( {t} ))} {row.original.tags.length > 2 && ( +{row.original.tags.length - 2} )}
)}
{row.original.subject} {row.original.grade}
), }, { accessorKey: "status", header: "Status", cell: ({ row }) => { const status = row.original.status // Use 'default' as base for published/success to ensure type safety, // but override with className below const variant: BadgeProps["variant"] = status === "published" ? "default" : status === "archived" ? "secondary" : "outline" return ( {status} ) }, }, { id: "stats", header: "Stats", cell: ({ row }) => (
{row.original.questionCount} Qs {row.original.totalScore} Pts
{row.original.durationMin} min
), }, { accessorKey: "difficulty", header: "Difficulty", cell: ({ row }) => { const diff = row.original.difficulty return (
{[1, 2, 3, 4, 5].map((level) => (
))}
{diff === 1 ? "Easy" : diff === 2 ? "Easy-Med" : diff === 3 ? "Medium" : diff === 4 ? "Med-Hard" : "Hard"}
) }, }, { id: "dates", header: "Date", cell: ({ row }) => { const scheduled = row.original.scheduledAt const created = row.original.createdAt return (
{scheduled ? ( <> Scheduled {formatDate(scheduled)} ) : ( <> Created {formatDate(created)} )}
) }, }, { id: "actions", cell: ({ row }) => , }, ]