19 lines
466 B
JavaScript
Raw Normal View History

2020-03-14 13:31:29 -04:00
// import { showAlertForError } from '../actions/alerts';
2019-07-02 03:10:25 -04:00
const defaultFailSuffix = 'FAIL';
export default function errorsMiddleware() {
return ({ dispatch }) => next => action => {
2020-11-25 15:22:37 -06:00
// : todo : use skipAlert!
2019-07-02 03:10:25 -04:00
if (action.type && !action.skipAlert) {
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
if (action.type.match(isFail)) {
2020-03-14 13:31:29 -04:00
// dispatch(showAlertForError(action.error));
2019-07-02 03:10:25 -04:00
}
}
return next(action);
};
};