UNPKG

610 BPlain TextView Raw
1import { createAction } from "redux-actions";
2
3import { TOAST_DURATION, TOAST_HIDE, TOAST_SHOW } from "../constants/toast";
4
5const showToast = createAction(
6 TOAST_SHOW,
7 (message, type, buttonLabel, url) => ({ buttonLabel, message, type, url })
8);
9const hideToast = createAction(TOAST_HIDE);
10
11export const showToastMessage = (
12 message,
13 type = "success",
14 buttonLabel = "",
15 url = ""
16) => dispatch => {
17 dispatch(showToast(message, type, buttonLabel, url));
18 setTimeout(() => dispatch(hideToast()), TOAST_DURATION);
19};
20
21export const hideToastMessage = () => dispatch => {
22 dispatch(hideToast());
23};