Added a Scroll To Top function

This commit is contained in:
Tiago Ribeiro
2024-02-05 17:59:46 +00:00
parent f6166ca9e1
commit 8baa25c445
8 changed files with 354 additions and 393 deletions

View File

@@ -5,17 +5,35 @@ import {create} from "zustand";
export interface ExamState {
exams: Exam[];
userSolutions: UserSolution[];
showSolutions: boolean;
hasExamEnded: boolean;
selectedModules: Module[];
assignment?: Assignment;
setHasExamEnded: (hasExamEnded: boolean) => void;
setUserSolutions: (userSolutions: UserSolution[]) => void;
setExams: (exams: Exam[]) => void;
userSolutions: UserSolution[];
setUserSolutions: (userSolutions: UserSolution[]) => void;
showSolutions: boolean;
setShowSolutions: (showSolutions: boolean) => void;
hasExamEnded: boolean;
setHasExamEnded: (hasExamEnded: boolean) => void;
selectedModules: Module[];
setSelectedModules: (modules: Module[]) => void;
assignment?: Assignment;
setAssignment: (assignment: Assignment) => void;
timeSpent: number;
setTimeSpent: (timeSpent: number) => void;
sessionId: string;
setSessionId: (sessionId: string) => void;
moduleIndex: number;
setModuleIndex: (moduleIndex: number) => void;
exam?: Exam;
setExam: (exam?: Exam) => void;
reset: () => void;
}
@@ -26,16 +44,26 @@ export const initialState = {
selectedModules: [],
hasExamEnded: false,
assignment: undefined,
timeSpent: 0,
sessionId: "",
exam: undefined,
moduleIndex: 0,
};
const useExamStore = create<ExamState>((set) => ({
...initialState,
setUserSolutions: (userSolutions: UserSolution[]) => set(() => ({userSolutions})),
setExams: (exams: Exam[]) => set(() => ({exams})),
setShowSolutions: (showSolutions: boolean) => set(() => ({showSolutions})),
setSelectedModules: (modules: Module[]) => set(() => ({selectedModules: modules})),
setHasExamEnded: (hasExamEnded: boolean) => set(() => ({hasExamEnded})),
setAssignment: (assignment: Assignment) => set(() => ({assignment})),
setTimeSpent: (timeSpent) => set(() => ({timeSpent})),
setSessionId: (sessionId: string) => set(() => ({sessionId})),
setExam: (exam?: Exam) => set(() => ({exam})),
setModuleIndex: (moduleIndex: number) => set(() => ({moduleIndex})),
reset: () => set(() => initialState),
}));