@shopgate/engage
Version:
Shopgate's ENGAGE library.
10 lines • 3.57 kB
JavaScript
import{connect}from'react-redux';import _showModal from'@shopgate/pwa-common/actions/modal/showModal';import{getBaseProduct,getProduct}from'@shopgate/pwa-common-commerce/product/selectors/product';import _addProductsToCart from'@shopgate/pwa-common-commerce/cart/actions/addProductsToCart';import _updateProductsInCart from'@shopgate/pwa-common-commerce/cart/actions/updateProductsInCart';import{getCartProducts,getActiveFulfillmentSlot,getActiveFulfillmentSlotLocationCode}from'@shopgate/engage/cart/cart.selectors';import{makeGetFulfillmentPaths,makeGetEnabledFulfillmentMethods,getShopSettings}from'@shopgate/engage/core/config';import{getRestrictMultiLocationOrders,getFulfillmentSchedulingEnabled}from'@shopgate/engage/core';import{selectLocation as _selectLocation,storeFormInput as _storeFormInput}from"../action-creators";import{getFilteredLocations,makeGetLocationInventory,makeGetLocationsForProduct,getPreferredLocation,getUserFormInput,getProductFulfillmentMethods,getIsFetching}from"../selectors";import{submitReservation as _submitReservation}from"../actions";/**
* @returns {Function}
*/function makeMapStateToProps(){/* eslint-disable require-jsdoc */var getProductCode=function getProductCode(_,props){return props.variantId||props.productId||null;};/* eslint-enable require-jsdoc */var getInventory=makeGetLocationInventory(function(state,props){var _getPreferredLocation;return((_getPreferredLocation=getPreferredLocation(state,props))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code)||null;},getProductCode);var getProductLocations=makeGetLocationsForProduct(getProductCode);var getFulfillmentPaths=makeGetFulfillmentPaths();var getEnabledFulfillmentMethods=makeGetEnabledFulfillmentMethods();/**
* @param {Object} state The application state.
* @param {Object} props The component props.
* @returns {Object}
*/return function(state,props){return{locations:props.noProduct?getFilteredLocations(state,props):getProductLocations(state,props),baseProduct:getBaseProduct(state,props),product:getProduct(state,props),location:getPreferredLocation(state,props),inventory:getInventory(state,props),userInput:getUserFormInput(state),fulfillmentPaths:getFulfillmentPaths(state),fulfillmentMethods:getProductFulfillmentMethods(state,props),enabledFulfillmentMethods:getEnabledFulfillmentMethods(state,props),shopSettings:getShopSettings(state),isFetching:getIsFetching(state),restrictMultiLocationOrders:getRestrictMultiLocationOrders(state),cartProducts:getCartProducts(state),fulfillmentSchedulingEnabled:getFulfillmentSchedulingEnabled(state),activeFulfillmentSlot:getActiveFulfillmentSlot(state),activeFulfillmentSlotLocationCode:getActiveFulfillmentSlotLocationCode(state)};};}/**
* @param {Function} dispatch The dispatch function.
* @returns {Object}
*/var mapDispatchToProps=function mapDispatchToProps(dispatch){return{selectLocation:function selectLocation(){return dispatch(_selectLocation.apply(void 0,arguments));},submitReservation:function submitReservation(){return dispatch(_submitReservation.apply(void 0,arguments));},storeFormInput:function storeFormInput(){return dispatch(_storeFormInput.apply(void 0,arguments));},addProductsToCart:function addProductsToCart(){return dispatch(_addProductsToCart.apply(void 0,arguments));},updateProductsInCart:function updateProductsInCart(){return dispatch(_updateProductsInCart.apply(void 0,arguments));},showModal:function showModal(){return dispatch(_showModal.apply(void 0,arguments));}};};export default connect(makeMapStateToProps,mapDispatchToProps);