Added sound effects to the exam generation

This commit is contained in:
Tiago Ribeiro
2023-11-29 20:26:48 +00:00
parent 1f0e5f4a08
commit a3864eb7d3
6 changed files with 28 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ import Input from "@/components/Low/Input";
import {WritingExam} from "@/interfaces/exam";
import useExamStore from "@/stores/examStore";
import {getExamById} from "@/utils/exams";
import {playSound} from "@/utils/sound";
import {Tab} from "@headlessui/react";
import axios from "axios";
import clsx from "clsx";
@@ -18,7 +19,10 @@ const TaskTab = ({task, index, setTask}: {task?: string; index: number; setTask:
setIsLoading(true);
axios
.get(`/api/exam/writing/generate/writing_task${index}_general`)
.then((result) => setTask(result.data.question))
.then((result) => {
playSound("check");
setTask(result.data.question);
})
.catch((error) => {
console.log(error);
toast.error("Something went wrong!");
@@ -132,6 +136,7 @@ const WritingGeneration = () => {
.post(`/api/exam/writing`, exam)
.then((result) => {
console.log(`Generated Exam ID: ${result.data.id}`);
playSound("sent");
toast.success("This new exam has been generated successfully! Check the ID in our browser's console.");
setResultingExam(result.data);