import { createAction } from "redux-actions"; import { TOAST_DURATION, TOAST_HIDE, TOAST_SHOW } from "../constants/toast"; const showToast = createAction( TOAST_SHOW, (message, type, buttonLabel, url) => ({ buttonLabel, message, type, url }) ); const hideToast = createAction(TOAST_HIDE); export const showToastMessage = ( message, type = "success", buttonLabel = "", url = "" ) => dispatch => { dispatch(showToast(message, type, buttonLabel, url)); setTimeout(() => dispatch(hideToast()), TOAST_DURATION); }; export const hideToastMessage = () => dispatch => { dispatch(hideToast()); };