Made it so the levels are update also when the user starts a diagnostics exam
This commit is contained in:
@@ -45,19 +45,10 @@ export default function Diagnostic({onFinish}: Props) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateUser = () => {
|
const updateUser = (callback: () => void) => {
|
||||||
axios
|
axios
|
||||||
.post("/api/users/update", {focus, levels, isFirstLogin: false})
|
.post("/api/users/update", {focus, levels, isFirstLogin: false})
|
||||||
.then(onFinish)
|
.then(callback)
|
||||||
.catch(() => {
|
|
||||||
toast.error("Something went wrong, please try again later!", {toastId: "user-update-error"});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const onPerformDiagnosis = async () => {
|
|
||||||
axios
|
|
||||||
.post("/api/users/update", {focus, isFirstLogin: false})
|
|
||||||
.then(selectExam)
|
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
toast.error("Something went wrong, please try again later!", {toastId: "user-update-error"});
|
toast.error("Something went wrong, please try again later!", {toastId: "user-update-error"});
|
||||||
});
|
});
|
||||||
@@ -103,7 +94,7 @@ export default function Diagnostic({onFinish}: Props) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={updateUser}
|
onClick={() => updateUser(onFinish)}
|
||||||
className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)}
|
className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)}
|
||||||
disabled={!Object.keys(levels).every((module) => BAND_SCORES[module as Module].includes(levels[module as keyof typeof levels]))}>
|
disabled={!Object.keys(levels).every((module) => BAND_SCORES[module as Module].includes(levels[module as keyof typeof levels]))}>
|
||||||
Next
|
Next
|
||||||
@@ -119,7 +110,7 @@ export default function Diagnostic({onFinish}: Props) {
|
|||||||
<button onClick={() => setIsInsert(true)} className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)}>
|
<button onClick={() => setIsInsert(true)} className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)}>
|
||||||
Insert my IELTS level
|
Insert my IELTS level
|
||||||
</button>
|
</button>
|
||||||
<button onClick={onPerformDiagnosis} className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)}>
|
<button onClick={() => updateUser(selectExam)} className={clsx("btn btn-wide gap-4 relative text-white", infoButtonStyle)}>
|
||||||
Perform a Diagnosis Test
|
Perform a Diagnosis Test
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user