@lonelyplanet/dotcom-core
Version:
This package is meant to house some of our more common UI and shared libs across dotcom applications.
17 lines (16 loc) • 842 B
JavaScript
import { createAction } from "redux-actions";
import { TOAST_DURATION, TOAST_HIDE, TOAST_SHOW } from "../constants/toast";
var showToast = createAction(TOAST_SHOW, function (message, type, buttonLabel, url) { return ({ buttonLabel: buttonLabel, message: message, type: type, url: url }); });
var hideToast = createAction(TOAST_HIDE);
export var showToastMessage = function (message, type, buttonLabel, url) {
if (type === void 0) { type = "success"; }
if (buttonLabel === void 0) { buttonLabel = ""; }
if (url === void 0) { url = ""; }
return function (dispatch) {
dispatch(showToast(message, type, buttonLabel, url));
setTimeout(function () { return dispatch(hideToast()); }, TOAST_DURATION);
};
};
export var hideToastMessage = function () { return function (dispatch) {
dispatch(hideToast());
}; };