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 {ReadingExam, ReadingPart} from "@/interfaces/exam";
import useExamStore from "@/stores/examStore";
import {getExamById} from "@/utils/exams";
import {playSound} from "@/utils/sound";
import {convertCamelCaseToReadable} from "@/utils/string";
import {Tab} from "@headlessui/react";
import axios from "axios";
@@ -25,7 +26,10 @@ const PartTab = ({part, types, index, setPart}: {part?: ReadingPart; types: stri
setIsLoading(true);
axios
.get(`/api/exam/reading/generate/reading_passage_${index}${topic || types ? `?${url.toString()}` : ""}`)
.then((result) => setPart(result.data))
.then((result) => {
playSound("check");
setPart(result.data);
})
.catch((error) => {
console.log(error);
toast.error("Something went wrong!");
@@ -136,6 +140,7 @@ const ReadingGeneration = () => {
axios
.post(`/api/exam/reading`, exam)
.then((result) => {
playSound("sent");
console.log(`Generated Exam ID: ${result.data.id}`);
toast.success("This new exam has been generated successfully! Check the ID in our browser's console.");
setResultingExam(result.data);