Browse Source

fix(business flow): resolve issues with exiting exam and duplicate feedback prompt

Fix bug preventing exit from exam process
Resolve issue where feedback dialog appears unexpectedly on second entry to exam from worklist in half-exposure study
dengdx 2 days ago
parent
commit
0743006a52
1 changed files with 18 additions and 7 deletions
  1. 18 7
      src/states/businessFlowMiddlewareLogic.ts

+ 18 - 7
src/states/businessFlowMiddlewareLogic.ts

@@ -8,9 +8,9 @@ let continueBusinessFlow = '';
 const businessFlowMiddlewareLogic: Middleware =
   (store) => (next) => (action: PayloadAction<string>) => {
     //const result = next(action);
-    console.log(
-      `[businessFlowMiddleware] Action dispatched: ${action.type} ${action.payload}`
-    );
+    // console.log(
+    //   `[businessFlowMiddleware] Action dispatched: ${action.type} ${action.payload}`
+    // );
     if (action.type !== setBusinessFlow.type) {
       return next(action); // Only handle setBusinessFlow actions
     }
@@ -40,12 +40,23 @@ const businessFlowMiddlewareLogic: Middleware =
         unprepare();
       }
     }
-    if (isExitingExam(action.payload, currentKey)) {
+    if (
+      isExitingExam(action.payload, currentKey) &&
+      action.payload !== 'exitExamCompleted' &&
+      action.payload !== 'exitExamSuspended'
+    ) {
+      console.log(
+        `[businessFlowMiddleware] Exiting exam flow to go to : ${action.payload}`
+      );
       const exposureStatus = store.getState().bodyPositionList.exposureStatus;
+      console.log(
+        `[businessFlowMiddleware] Exposure status: ${exposureStatus}`
+      );
       if (exposureStatus === 'Half Exposed') {
-        store.dispatch(setFeedbackOpen(true));
+        store.dispatch(setFeedbackOpen(true)); //显示反馈框
         // store.dispatch({ type: 'SET_CONTINUE_BUSINESS_FLOW', payload: currentKey });
         continueBusinessFlow = action.payload; // 保存退出检查时,要去哪个业务流程
+        return; //阻止退出exam
       } else if (exposureStatus === 'Fully Exposed') {
         // Notify backend
         console.log(
@@ -65,14 +76,14 @@ const businessFlowMiddlewareLogic: Middleware =
         `[businessFlowMiddleware] Notifying backend for ${action.payload}`
       );
       // todo 把所有未曝光的体位从study删除掉--服务端和slice。
-      return next({ ...action, type: continueBusinessFlow });
+      return next({ ...action, payload: continueBusinessFlow });
     }
     if (action.payload === 'exitExamSuspended') {
       // Notify backend with different interfaces for completed and suspended 暂时不通知后端
       console.log(
         `[businessFlowMiddleware] Notifying backend for ${action.payload}`
       );
-      return next({ ...action, type: continueBusinessFlow });
+      return next({ ...action, payload: continueBusinessFlow });
     }
     next(action);
   };