import { useEffect } from "react"; import { useNavigate, useParams } from "react-router-dom"; import { useExamStatus } from "@/hooks/queries/useExamSession"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; export default function ExamStatus() { const { examId: examIdParam } = useParams(); const examId = Number(examIdParam); const navigate = useNavigate(); const { data, isLoading, isFetching } = useExamStatus(examId, true); useEffect(() => { if (!data) return; const s = (data.status ?? "").toLowerCase(); if (data.scores_available || s.includes("complete") || s.includes("released")) { navigate(`/student/exam/${examId}/results`, { replace: true }); } }, [data, examId, navigate]); if (isLoading && !data) { return (

Loading status…

); } const status = (data?.status ?? "").toLowerCase(); let view: "scoring" | "partial" | "manual" | "generic" = "generic"; if (status.includes("scoring") || status === "processing") view = "scoring"; else if (status.includes("manual") || status.includes("approval") || status.includes("under_review")) view = "manual"; else if ( status.includes("partial") || status.includes("pending_ws") || status.includes("lr_scored") || (status.includes("listening") && status.includes("reading") && status.includes("pending")) ) view = "partial"; return (
{view === "scoring" ? (
Scores are being calculated This page refreshes every few seconds. {isFetching ? "Checking…" : "Waiting for next update…"} ) : null} {view === "partial" ? ( Partial results Listening and Reading are scored; Writing and Speaking are still pending review.
Listening Band 7.5
Reading Band 8.0
Writing Pending Review
Speaking Pending Review
) : null} {view === "manual" ? ( Results under review Your institution will release Writing and Speaking results after approval. ) : null} {view === "generic" ? ( Status {data?.status ?? "Unknown"} ) : null}
); }