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

@ -7,10 +7,14 @@ import { ExamResult } from "@/types/exam";
// Result type (based on your API response)
type ExamStatus = "not-started" | "in-progress" | "finished";
interface ExamState {
test: Test | null;
answers: Answer[];
result: ExamResult | null;
status: ExamStatus;
setStatus: (status: ExamStatus) => void;
startExam: (testType: string, testId: string) => Promise<Test | null>;
setAnswer: (questionIndex: number, answer: Answer) => void;
@ -23,6 +27,8 @@ export const useExamStore = create<ExamState>((set, get) => ({
test: null,
answers: [],
result: null,
status: "not-started",
setStatus: (status) => set({ status }),
// start exam
startExam: async (testType: string, testId: string) => {