25 lines
797 B
JavaScript
25 lines
797 B
JavaScript
|
import { GET_MODE, FETCH_MODE_SUCCESS, FETCH_MODE_ERROR } from '../actions/mode';
|
||
|
import { showSpinner, hideSpinner, setPreLaunch, setInternal } from '../actions/ui';
|
||
|
import { apiRequest } from '../actions/api';
|
||
|
|
||
|
export const getModeFlow = ({ dispatch }) => next => action => {
|
||
|
next(action);
|
||
|
|
||
|
if (action.type === GET_MODE) {
|
||
|
dispatch(apiRequest('GET', '/mode/', null, FETCH_MODE_SUCCESS, FETCH_MODE_ERROR));
|
||
|
dispatch(showSpinner());
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export const processModeCollection = ({ dispatch }) => next => action => {
|
||
|
next(action);
|
||
|
|
||
|
if (action.type === FETCH_MODE_SUCCESS) {
|
||
|
dispatch(setPreLaunch(action.payload.mode === 'minimal'));
|
||
|
dispatch(setInternal(action.payload.mode === 'internal'));
|
||
|
dispatch(hideSpinner());
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export const modeMdl = [getModeFlow, processModeCollection];
|