UNPKG

@shopgate/pwa-common-commerce

Version:

Commerce library for the Shopgate Connect PWA.

11 lines 1.94 kB
var _excluded=["fetchInventory"];function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import{RECEIVE_PRODUCTS}from"../constants";/** * Creates the dispatched RECEIVE_PRODUCTS action object. * @param {Object} payload The action payload. * @param {string} payload.hash The store hash. * @param {Object} payload.params The criteria of the products received. * @param {Object} payload.products The data of the received products. * @param {boolean} payload.cached If the result should be cached. * @param {boolean} [payload.fetchInventory=true] If the inventory needs to be fetched after * products where received. * @return {Object} The RECEIVE_PRODUCTS action. */var receiveProducts=function receiveProducts(payload){var _payload$fetchInvento=payload.fetchInventory,fetchInventory=_payload$fetchInvento===void 0?true:_payload$fetchInvento,rest=_objectWithoutProperties(payload,_excluded);return _extends({type:RECEIVE_PRODUCTS},rest,{fetchInventory:fetchInventory});};export default receiveProducts;