@lonelyplanet/dotcom-core
Version:
This package is meant to house some of our more common UI and shared libs across dotcom applications.
24 lines (19 loc) • 610 B
text/typescript
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());
};