diff --git a/react/src/reducers/errors.js b/react/src/reducers/errors.js new file mode 100644 index 0000000..812888b --- /dev/null +++ b/react/src/reducers/errors.js @@ -0,0 +1,24 @@ +import { SERVICE_ERROR } from '../actions/actionCreators'; + +export function Errors(state = { + errors: {}, +}, action) { + switch (action.type) { + case SERVICE_ERROR: + let _errors = Object.assign({}, state); + + if (_errors[action.apiMethod]) { + _errors[action.apiMethod]++; + } else { + _errors[action.apiMethod] = 1; + } + + return Object.assign({}, state, { + errors: _errors, + }); + default: + return state; + } +} + +export default Errors;