implement initialization of approval workflows on exam creation.
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user