Redux changes and refactoring

This commit is contained in:
Scott E. Graves
2019-06-07 16:32:18 -05:00
parent 5c931bb66d
commit 7f3e90773e
9 changed files with 158 additions and 69 deletions

View File

@@ -0,0 +1,26 @@
import {createReducer} from 'redux-starter-kit';
import {CLEAR_ERROR, SET_ERROR_INFO} from '../actions/error_actions';
export const errorReducer = createReducer({
DisplayError: false,
ErrorCritical: false,
ErrorStack: [],
}, {
[CLEAR_ERROR]: state => {
const errorStack = (state.ErrorStack.length > 0) ? state.ErrorStack.slice(1) : [];
return {
...state,
DisplayError: (errorStack.length > 0),
ErrorStack: errorStack,
}
},
[SET_ERROR_INFO]: (state, action) => {
const errorStack = [action.payload.msg, ...state.ErrorStack];
return {
...state,
DisplayError: true,
ErrorCritical: state.ErrorCritical || action.payload.critical,
ErrorStack: errorStack,
}
}
});