Corrected the behaviour of the exam after the timer has ended
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import useExamStore from "@/stores/examStore";
|
||||
import {useEffect, useState} from "react";
|
||||
import {motion} from "framer-motion";
|
||||
import { useEffect, useState } from "react";
|
||||
import { motion } from "framer-motion";
|
||||
import TimerEndedModal from "../TimerEndedModal";
|
||||
import clsx from "clsx";
|
||||
import {BsStopwatch} from "react-icons/bs";
|
||||
import { BsStopwatch } from "react-icons/bs";
|
||||
|
||||
interface Props {
|
||||
minTimer: number;
|
||||
@@ -11,13 +11,13 @@ interface Props {
|
||||
standalone?: boolean;
|
||||
}
|
||||
|
||||
const Timer: React.FC<Props> = ({minTimer, disableTimer, standalone = false}) => {
|
||||
const Timer: React.FC<Props> = ({ minTimer, disableTimer, standalone = false }) => {
|
||||
const [timer, setTimer] = useState(minTimer * 60);
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const [warningMode, setWarningMode] = useState(false);
|
||||
|
||||
const setHasExamEnded = useExamStore((state) => state.setHasExamEnded);
|
||||
const {timeSpent} = useExamStore((state) => state);
|
||||
const { timeSpent } = useExamStore((state) => state);
|
||||
|
||||
useEffect(() => setTimer((prev) => prev - timeSpent), [timeSpent]);
|
||||
|
||||
@@ -54,9 +54,9 @@ const Timer: React.FC<Props> = ({minTimer, disableTimer, standalone = false}) =>
|
||||
standalone ? "top-10" : "top-4",
|
||||
warningMode && !disableTimer && "bg-mti-red-light text-mti-gray-seasalt",
|
||||
)}
|
||||
initial={{scale: warningMode && !disableTimer ? 0.8 : 1}}
|
||||
animate={{scale: warningMode && !disableTimer ? 1.1 : 1}}
|
||||
transition={{repeat: Infinity, repeatType: "reverse", duration: 0.5, ease: "easeInOut"}}>
|
||||
initial={{ scale: warningMode && !disableTimer ? 0.8 : 1 }}
|
||||
animate={{ scale: warningMode && !disableTimer ? 1.1 : 1 }}
|
||||
transition={{ repeat: Infinity, repeatType: "reverse", duration: 0.5, ease: "easeInOut" }}>
|
||||
<BsStopwatch className="w-6 h-6" />
|
||||
<span className="text-lg font-bold w-12">
|
||||
{timer > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user