From 14e2702aca1fbeae33befe2e9bce2ba2c5d9071d Mon Sep 17 00:00:00 2001 From: Joao Correia Date: Thu, 20 Feb 2025 10:40:31 +0000 Subject: [PATCH] add error message and stop loading if something went wrong while loading exam in approval workflow --- src/lib/createWorkflowsOnExamCreation.ts | 2 +- src/pages/approval-workflows/[id]/index.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/createWorkflowsOnExamCreation.ts b/src/lib/createWorkflowsOnExamCreation.ts index e2a791af..0f8e1c53 100644 --- a/src/lib/createWorkflowsOnExamCreation.ts +++ b/src/lib/createWorkflowsOnExamCreation.ts @@ -72,7 +72,7 @@ export async function createApprovalWorkflowOnExamCreation(examAuthor: string, e if (totalCount === 0) { // current behaviour: if no workflow was found skip approval process await db.collection(examModule).updateOne( { id: examId }, - { $set: { id: examId, isDiagnostic: false }}, + { $set: { id: examId, access: "private" }}, { upsert: true } ); } diff --git a/src/pages/approval-workflows/[id]/index.tsx b/src/pages/approval-workflows/[id]/index.tsx index 2b512ba0..dfbedc0f 100644 --- a/src/pages/approval-workflows/[id]/index.tsx +++ b/src/pages/approval-workflows/[id]/index.tsx @@ -261,7 +261,7 @@ export default function Home({ user, initialWorkflow, id, workflowAssignees, wor const exam = await getExamById(examModule, examId.trim()); if (!exam) { toast.error( - "Unknown Exam ID! Please make sure you selected the right module and entered the right exam ID", + "Something went wrong while fetching exam!", { toastId: "invalid-exam-id" } ); setViewExamIsLoading(false); @@ -272,6 +272,13 @@ export default function Home({ user, initialWorkflow, id, workflowAssignees, wor payload: { exams: [exam], modules: [examModule] }, }); router.push("/exam"); + } else { + toast.error( + "Something went wrong while fetching exam!", + { toastId: "invalid-exam-id" } + ); + setViewExamIsLoading(false); + return; } }