import moment from "moment"; import React, { useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useNavigate } from "react-router-dom"; import { setQuestions } from "@redux/quizSlice"; import { apiRequest } from "@api/request"; import { useNotification } from "@hooks/useNotification"; import StarRating from "@components/StarRating/StarRating"; import accempt from "assets/images/quiz/accempt.png"; import iconTomer from "assets/images/quiz/timer.png"; export const QuizPassingInformation = ({ setStartTest, uuid, timer }) => { const { restart, pause, hours, minutes, seconds, isRunning } = timer; const navigate = useNavigate(); const { showNotification } = useNotification(); const dispatch = useDispatch(); const startTesting = () => { apiRequest(`/question/get-questions?uuid=${uuid}`) .then((res) => { if (res.status === 400) { dispatch(setQuestions(null)); showNotification({ show: true, text: res?.message || "", type: "error" }); return; } dispatch(setQuestions(res)); setStartTest(true); restart( moment() .add(res[0]?.time_limit.split(":")[0], "hours") .add(res[0]?.time_limit.split(":")[1], "minutes") .add(res[0]?.time_limit.split(":")[2], "seconds"), true ); }) .catch((e) => { dispatch(setQuestions(null)); }); }; const checkTest = () => apiRequest( `user-questionnaire/questionnaire-completed?user_questionnaire_uuid=${uuid}` ); const completeTest = () => apiRequest("/user-questionnaire/questionnaire-completed", { method: "POST" }); const finishQuiz = async () => { Promise.all([checkTest, completeTest]) .then(function () { pause(); }) .catch((e) => { console.log(e); }); }; return (
Junior
разработчик
{isRunning && (
Время на прохождение теста:
{hours.toString().padStart(2, "0") + ":" + minutes.toString().padStart(2, "0") + ":" + seconds.toString().padStart(2, "0")} секунд
)} {!isRunning && (
Попыток прохождения:
1 попытка
)}
{!isRunning && ( )}
{isRunning && ( )}
); };