|
@@ -2,11 +2,13 @@ import { Middleware, PayloadAction } from '@reduxjs/toolkit';
|
|
|
import prepare, { unprepare } from '../domain/exam/prepare';
|
|
|
import { BusinessFlowState, setBusinessFlow } from './BusinessFlowSlice';
|
|
|
import { setFeedbackOpen } from './exam/largeScreenSlice';
|
|
|
+import { suspendOrCompleteStudy } from '@/API/patient/workActions';
|
|
|
+import { RootState } from './store';
|
|
|
|
|
|
let continueBusinessFlow = '';
|
|
|
|
|
|
const businessFlowMiddlewareLogic: Middleware =
|
|
|
- (store) => (next) => (action: PayloadAction<string>) => {
|
|
|
+ (store) => (next) => async (action: PayloadAction<string>) => {
|
|
|
//const result = next(action);
|
|
|
// console.log(
|
|
|
// `[businessFlowMiddleware] Action dispatched: ${action.type} ${action.payload}`
|
|
@@ -81,7 +83,16 @@ const businessFlowMiddlewareLogic: Middleware =
|
|
|
return next({ ...action, payload: continueBusinessFlow });
|
|
|
}
|
|
|
if (action.payload === 'exitExamSuspended') {
|
|
|
- // Notify backend with different interfaces for completed and suspended 暂时不通知后端
|
|
|
+ // Notify backend with different interfaces for completed and suspended
|
|
|
+ const studyId =
|
|
|
+ (store.getState() as RootState)?.bodyPositionList?.selectedBodyPosition
|
|
|
+ ?.work?.StudyID ?? '';
|
|
|
+ if (!studyId) {
|
|
|
+ console.error(
|
|
|
+ '[businessFlowMiddleware] No study ID found for the selected body position.'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ await suspendOrCompleteStudy(studyId, 'InProgress');
|
|
|
console.log(
|
|
|
`[businessFlowMiddleware] Notifying backend for ${action.payload}`
|
|
|
);
|