Revamped the whole Solutions stuff with Zustand
This commit is contained in:
@@ -1,25 +1,28 @@
|
||||
import {Module} from "@/interfaces";
|
||||
import {Exam} from "@/interfaces/exam";
|
||||
import {Exam, UserSolution} from "@/interfaces/exam";
|
||||
import {Stat} from "@/interfaces/user";
|
||||
import {getExamsBySession} from "@/utils/stats";
|
||||
import {create} from "zustand";
|
||||
|
||||
export interface ExamState {
|
||||
exams: Exam[];
|
||||
stats: Stat[];
|
||||
userSolutions: UserSolution[];
|
||||
showSolutions: boolean;
|
||||
setStats: (stats: Stat[]) => void;
|
||||
selectedModules: Module[];
|
||||
setUserSolutions: (userSolutions: UserSolution[]) => void;
|
||||
setExams: (exams: Exam[]) => void;
|
||||
setShowSolutions: (showSolutions: boolean) => void;
|
||||
setSelectedModules: (modules: Module[]) => void;
|
||||
}
|
||||
|
||||
const useExamStore = create<ExamState>((set) => ({
|
||||
exams: [],
|
||||
stats: [],
|
||||
userSolutions: [],
|
||||
showSolutions: false,
|
||||
setStats: (stats: Stat[]) => set(() => ({stats})),
|
||||
selectedModules: [],
|
||||
setUserSolutions: (userSolutions: UserSolution[]) => set(() => ({userSolutions})),
|
||||
setExams: (exams: Exam[]) => set(() => ({exams})),
|
||||
setShowSolutions: (showSolutions: boolean) => set(() => ({showSolutions})),
|
||||
setSelectedModules: (modules: Module[]) => set(() => ({selectedModules: modules})),
|
||||
}));
|
||||
|
||||
export default useExamStore;
|
||||
|
||||
Reference in New Issue
Block a user