import { Suspense } from "react" import { ClipboardList } from "lucide-react" import { QuestionDataTable } from "@/modules/questions/components/question-data-table" import { columns } from "@/modules/questions/components/question-columns" import { QuestionFilters } from "@/modules/questions/components/question-filters" import { CreateQuestionButton } from "@/modules/questions/components/create-question-button" import { EmptyState } from "@/shared/components/ui/empty-state" import { Skeleton } from "@/shared/components/ui/skeleton" import { getQuestions } from "@/modules/questions/data-access" import type { QuestionType } from "@/modules/questions/types" type SearchParams = { [key: string]: string | string[] | undefined } const getParam = (params: SearchParams, key: string) => { const v = params[key] return Array.isArray(v) ? v[0] : v } async function QuestionBankResults({ searchParams }: { searchParams: Promise }) { const params = await searchParams const q = getParam(params, "q") const type = getParam(params, "type") const difficulty = getParam(params, "difficulty") const questionType: QuestionType | undefined = type === "single_choice" || type === "multiple_choice" || type === "text" || type === "judgment" || type === "composite" ? type : undefined const { data: questions } = await getQuestions({ q: q || undefined, type: questionType, difficulty: difficulty && difficulty !== "all" ? Number(difficulty) : undefined, pageSize: 200, }) const hasFilters = Boolean(q || (type && type !== "all") || (difficulty && difficulty !== "all")) if (questions.length === 0) { return ( ) } return (
) } function QuestionBankResultsFallback() { return (
{Array.from({ length: 6 }).map((_, idx) => ( ))}
) } export default async function QuestionBankPage({ searchParams, }: { searchParams: Promise }) { return (

Question Bank

Manage your question repository for exams and assignments.

}> }>
) }