import {infoButtonStyle} from "@/constants/buttonStyles"; import {Module} from "@/interfaces"; import {User} from "@/interfaces/user"; import useExamStore from "@/stores/examStore"; import {getExam, getExamById} from "@/utils/exams"; import {MODULE_ARRAY} from "@/utils/moduleUtils"; import {writingMarking} from "@/utils/score"; import {Menu} from "@headlessui/react"; import axios from "axios"; import clsx from "clsx"; import {capitalize} from "lodash"; import {useRouter} from "next/router"; import {useEffect, useState} from "react"; import {BsBook, BsChevronDown, BsHeadphones, BsMegaphone, BsPen, BsQuestionSquare} from "react-icons/bs"; import {toast} from "react-toastify"; import Button from "./Low/Button"; import ModuleLevelSelector from "./Medium/ModuleLevelSelector"; interface Props { user: User; onFinish: () => void; } export default function Diagnostic({onFinish}: Props) { const [focus, setFocus] = useState<"academic" | "general">(); const [levels, setLevels] = useState({reading: -1, listening: -1, writing: -1, speaking: -1, level: 0}); const [desiredLevels, setDesiredLevels] = useState({reading: 9, listening: 9, writing: 9, speaking: 9, level: 9}); const router = useRouter(); const setExams = useExamStore((state) => state.setExams); const setSelectedModules = useExamStore((state) => state.setSelectedModules); const isNextDisabled = () => { if (!focus) return true; return Object.values(levels).includes(-1); }; const selectExam = () => { const examPromises = MODULE_ARRAY.map((module) => getExam(module, true, "partial")); Promise.all(examPromises).then((exams) => { if (exams.every((x) => !!x)) { setExams(exams.map((x) => x!)); setSelectedModules(exams.map((x) => x!.module)); router.push("/exam"); } }); }; const updateUser = (callback: () => void) => { axios .patch("/api/users/update", { focus, levels: Object.values(levels).includes(-1) ? {reading: 0, listening: 0, writing: 0, speaking: 0, level: 0} : levels, desiredLevels, isFirstLogin: false, }) .then(callback) .catch(() => { toast.error("Something went wrong, please try again later!", {toastId: "user-update-error"}); }); }; return (

What is your current focus?

What is your current IELTS level?

What is your desired IELTS level?

); }