feat(nav): add flow-guarding for exam result screens

This commit is contained in:
shafin-r
2025-09-01 17:53:44 +06:00
parent 5fd76bc0ec
commit 3b2488054c
5 changed files with 123 additions and 20 deletions

View File

@ -13,7 +13,6 @@ import {
import DestructibleAlert from "@/components/DestructibleAlert";
import BackgroundWrapper from "@/components/BackgroundWrapper";
import { API_URL, getToken } from "@/lib/auth";
import { useExam } from "@/context/ExamContext";
import { Test } from "@/types/exam";
import { Metadata } from "@/types/exam";
import { useExamStore } from "@/stores/examStore";
@ -21,7 +20,7 @@ import { useExamStore } from "@/stores/examStore";
function PretestPageContent() {
const router = useRouter();
const searchParams = useSearchParams();
const { startExam } = useExamStore();
const [examData, setExamData] = useState<Test>();
// Get params from URL search params
@ -35,6 +34,7 @@ function PretestPageContent() {
const [metadata, setMetadata] = useState<Metadata | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string>();
const { setStatus } = useExamStore();
useEffect(() => {
async function fetchQuestions() {
@ -123,6 +123,7 @@ function PretestPageContent() {
function handleStartExam() {
if (!examData) return;
setStatus("in-progress");
router.push(
`/exam/${id}?type=${type}&test_id=${metadata?.test_id}&attempt_id=${metadata?.attempt_id}`