From a3a9f976438b88d7b23e71f151f409fdde4aaff9 Mon Sep 17 00:00:00 2001 From: marcinbodnar Date: Thu, 13 Jan 2022 00:34:13 +0100 Subject: [PATCH] feat: add withAlert thunk --- packages/frontend/src/redux/reducers/status/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/frontend/src/redux/reducers/status/index.js b/packages/frontend/src/redux/reducers/status/index.js index 8ca7dd926a..54680b8b94 100644 --- a/packages/frontend/src/redux/reducers/status/index.js +++ b/packages/frontend/src/redux/reducers/status/index.js @@ -2,6 +2,7 @@ import { getRouter } from 'connected-react-router'; import reduceReducers from 'reduce-reducers'; import { handleActions } from 'redux-actions'; +import { showAlert } from '../../../utils/alerts'; import { makeAccountActive } from '../../actions/account'; import { clearLocalAlert, @@ -28,6 +29,14 @@ export const handleClearAlert = () => (dispatch, getState) => { dispatch(clearLocalAlert()); }; +export const withAlert = (action, data) => (dispatch) => dispatch({ + ...action, + meta: { + ...action.meta, + ...showAlert(data) + } +}); + const alertReducer = (state, { error, ready, payload, meta, type }) => { // temporary solution to handle both `showAlert` and `showAlertToolkit`