UNPKG

@shopgate/pwa-common

Version:

Common library for the Shopgate Connect PWA.

6 lines 638 B
import{mutable}from"../../helpers/redux";import{removeModal}from"../../action-creators/modal";import promiseMap from"./promiseMap";/** * Closes an open modal and resolves the mapped promise. * @param {number} id A modal id. * @param {boolean} confirmed A flag whether the modal was confirmed or not. * @returns {Function} A redux thunk. */function closeModal(id){var confirmed=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return function(dispatch){var promise=promiseMap.get(id);if(promise){promise.resolve(confirmed);}dispatch(removeModal(id));};}/** @mixes {MutableFunction} */export default mutable(closeModal);