Made it so when the timer ends, the module ends
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {Module} from "@/interfaces";
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import {moduleLabels} from "@/utils/moduleUtils";
|
||||
import {ReactNode, useEffect, useState} from "react";
|
||||
import {BsBook, BsHeadphones, BsMegaphone, BsPen, BsStopwatch} from "react-icons/bs";
|
||||
@@ -15,6 +16,7 @@ interface Props {
|
||||
|
||||
export default function ModuleTitle({minTimer, module, label, exerciseIndex, totalExercises, disableTimer = false}: Props) {
|
||||
const [timer, setTimer] = useState(minTimer * 60);
|
||||
const setHasExamEnded = useExamStore((state) => state.setHasExamEnded);
|
||||
|
||||
useEffect(() => {
|
||||
if (!disableTimer) {
|
||||
@@ -26,6 +28,10 @@ export default function ModuleTitle({minTimer, module, label, exerciseIndex, tot
|
||||
}
|
||||
}, [disableTimer, minTimer]);
|
||||
|
||||
useEffect(() => {
|
||||
if (timer <= 0) setHasExamEnded(true);
|
||||
}, [setHasExamEnded, timer]);
|
||||
|
||||
const moduleIcon: {[key in Module]: ReactNode} = {
|
||||
reading: <BsBook className="text-ielts-reading w-6 h-6" />,
|
||||
listening: <BsHeadphones className="text-ielts-listening w-6 h-6" />,
|
||||
|
||||
Reference in New Issue
Block a user