instanciate all workflows configured for an exam author based on different entities.

This commit is contained in:
Joao Correia
2025-02-05 12:37:53 +00:00
parent f4c7961caa
commit 6692c201e4
9 changed files with 129 additions and 67 deletions

View File

@@ -144,23 +144,31 @@ const WritingSettings: React.FC = () => {
const requestBody = await (async () => {
const handledExam = await getExamById("writing", result.data.id);
return {
examAuthor: handledExam?.createdBy ?? "Unknown Author",
examEntities: handledExam?.entities ?? [],
examId: handledExam?.id ?? "Unknown ID",
examModule: "writing"
};
})();
await axios.post(`/api/approval-workflows`, requestBody)
.then(() => {
toast.success(`Approval Workflow for exam has been created`);
await axios
.post(`/api/approval-workflows`, requestBody)
.then((response) => {
if (response.status === 200) {
toast.success(`Approval Workflows for exam have been successfully created`);
} else if (response.status === 207) {
toast.warning(
`Approval Workflows were partially created. Exam author might not have a configured workflow for all its entities.`
);
}
})
.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.");
if (reason.response?.status === 404) {
toast.error("No configured workflow found for examAuthor for any of its entities.");
} else {
toast.error(
"Something went wrong while creating approval workflow, please try again later."
);
}
});