1 | import { createAction } from "redux-actions";
|
2 |
|
3 | import { TOAST_DURATION, TOAST_HIDE, TOAST_SHOW } from "../constants/toast";
|
4 |
|
5 | const showToast = createAction(
|
6 | TOAST_SHOW,
|
7 | (message, type, buttonLabel, url) => ({ buttonLabel, message, type, url })
|
8 | );
|
9 | const hideToast = createAction(TOAST_HIDE);
|
10 |
|
11 | export 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 |
|
21 | export const hideToastMessage = () => dispatch => {
|
22 | dispatch(hideToast());
|
23 | };
|