Started to update the exam to work with Zustand for the history review

This commit is contained in:
Tiago Ribeiro
2023-05-08 10:44:16 +01:00
parent 4b5c99c654
commit 1813de499d
6 changed files with 88 additions and 8 deletions

View File

@@ -1,6 +1,25 @@
import {Module} from "@/interfaces";
import {Exam} from "@/interfaces/exam";
import {Stat} from "@/interfaces/user";
import {getExamsBySession} from "@/utils/stats";
import {create} from "zustand";
const useExamStore = create((set) => ({}));
export interface ExamState {
exams: Exam[];
stats: Stat[];
showSolutions: boolean;
setStats: (stats: Stat[]) => void;
setExams: (exams: Exam[]) => void;
setShowSolutions: (showSolutions: boolean) => void;
}
const useExamStore = create<ExamState>((set) => ({
exams: [],
stats: [],
showSolutions: false,
setStats: (stats: Stat[]) => set(() => ({stats})),
setExams: (exams: Exam[]) => set(() => ({exams})),
setShowSolutions: (showSolutions: boolean) => set(() => ({showSolutions})),
}));
export default useExamStore;