|
@@ -1,14 +1,20 @@
|
|
|
-import { Middleware } from '@reduxjs/toolkit';
|
|
|
+import { Action, Middleware } from '@reduxjs/toolkit';
|
|
|
import prepare from '../domain/exam/prepare';
|
|
|
-import { BusinessFlowState } from './BusinessFlowSlice';
|
|
|
+import { BusinessFlowState, setBusinessFlow } from './BusinessFlowSlice';
|
|
|
|
|
|
const businessFlowMiddlewareLogic: Middleware =
|
|
|
- (store) => (next) => (action) => {
|
|
|
+ (store) => (next) => (action: Action) => {
|
|
|
const result = next(action);
|
|
|
-
|
|
|
+ console.log(`[businessFlowMiddleware] Action dispatched: ${action.type}`);
|
|
|
+ if (action.type !== setBusinessFlow.type) {
|
|
|
+ return result; // Only handle setBusinessFlow actions
|
|
|
+ }
|
|
|
const state = store.getState().BusinessFlow as BusinessFlowState;
|
|
|
const currentKey = state.currentKey;
|
|
|
console.log(`[businessFlowMiddleware] currentKey: ${currentKey}`);
|
|
|
+ console.log(
|
|
|
+ `[businessFlowMiddleware] Current business flow is now: ${state.currentKey} ; Last key was: ${state.lastKey}`
|
|
|
+ );
|
|
|
if (currentKey === 'exam') {
|
|
|
prepare();
|
|
|
}
|