implement initialization of approval workflows on exam creation.

This commit is contained in:
Joao Correia
2025-02-04 22:04:58 +00:00
parent d3385caaf8
commit de15eb5ee1
12 changed files with 175 additions and 20 deletions

View File

@@ -11,6 +11,7 @@ import openDetachedTab from "@/utils/popout";
import axios from "axios";
import { playSound } from "@/utils/sound";
import SpeakingComponents from "./components";
import { getExamById } from "@/utils/exams";
export interface Avatar {
name: string;
@@ -194,6 +195,28 @@ const SpeakingSettings: React.FC = () => {
Array.from(urlMap.values()).forEach(url => {
URL.revokeObjectURL(url);
});
const requestBody = await (async () => {
const handledExam = await getExamById("speaking", result.data.id);
return {
examAuthor: handledExam?.createdBy ?? "Unknown Author",
examId: handledExam?.id ?? "Unknown ID",
examModule: "speaking"
};
})();
await axios.post(`/api/approval-workflows`, requestBody)
.then(() => {
toast.success(`Approval Workflow for exam has been created`);
})
.catch((reason) => {
if (reason.response.status === 404) {
toast.error("No configured workflow found for examAuthor.");
}
else {
toast.error("Something went wrong while creating approval workflow, please try again later.");
}
});
} catch (error: any) {
toast.error(