generated from muhtadeetaron/nextjs-template
feat(nav): add flow-guarding for exam result screens
This commit is contained in:
@ -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}`
|
||||
|
||||
Reference in New Issue
Block a user