instanciate all workflows configured for an exam author based on different entities.
This commit is contained in:
@@ -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."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user