@shopgate/pwa-common-commerce 7.6.0-beta.3 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,11 +12,6 @@ import{createSelector}from'reselect';import uniq from'lodash/uniq';import{getPro
12
12
  * @param {Object} state The global state.
13
13
  * @return {Object|null}
14
14
  */export var getFavoritesProducts=createSelector(getFavoritesState,function(state){if(!state.products){return null;}return state.products;});export var getFavoritesDefaultList=createSelector(getFavoritesLists,function(lists){return lists[0];});export var hasMultipleFavoritesList=createSelector(getFavoritesLists,function(lists){return lists.length>1;});/**
15
- * A selector that gets the id of the favorites list by the given name
16
- * @param {Object} state The current application state.
17
- * @param {Object} props The component props.
18
- * @returns {string} the id of the favorites list
19
- */export var getFavoritesListIdByName=createSelector(getFavoritesLists,function(state,props){return props.listName;},function(favLists,listName){var _ref=favLists.find(function(list){return list.name===listName;})||{},id=_ref.id;return id;});/**
20
15
  * @param {Object} state The global state.
21
16
  * @returns {Array}
22
17
  * @deprecated
@@ -24,16 +19,11 @@ import{createSelector}from'reselect';import uniq from'lodash/uniq';import{getPro
24
19
  * @param {Object} state The global state.
25
20
  * @deprecated
26
21
  */export var getFavorites=createSelector(getFavoritesProductsIds,getProducts,function(productIds,products){return productIds.filter(function(id){return!!products[id]&&products[id].productData;}).map(function(id){return products[id].productData;});});/**
27
- * Creates a selector that selects all ids that belong
28
- * to the given favorite list.
29
- * @param {Function} getListCode Selects the list code.
30
- * @returns {Function}
31
- */export var makeGetFavoritesIdsByList=function makeGetFavoritesIdsByList(getListCode){return createSelector(getFavoritesProducts,getListCode,function(favProducts,listId){var _favProducts$byList$l;var ids=((_favProducts$byList$l=favProducts.byList[listId])===null||_favProducts$byList$l===void 0?void 0:_favProducts$byList$l.ids)||[];return ids;});};/**
32
22
  * Creates a selector that selects all products that belong
33
23
  * to the given favorite list.
34
24
  * @param {Function} getListCode Selects the list code.
35
25
  * @returns {Function}
36
- */export var makeGetFavorites=function makeGetFavorites(getListCode){var getFavoritesIdsByList=makeGetFavoritesIdsByList(getListCode);return createSelector(getFavoritesIdsByList,getProducts,function(ids,products){return ids.filter(function(id){return!!products[id]&&products[id].productData;}).map(function(id){return products[id].productData;});});};/**
26
+ */export var makeGetFavorites=function makeGetFavorites(getListCode){return createSelector(getFavoritesProducts,getListCode,getProducts,function(favProducts,listId,products){var _favProducts$byList$l;var ids=((_favProducts$byList$l=favProducts.byList[listId])===null||_favProducts$byList$l===void 0?void 0:_favProducts$byList$l.ids)||[];return ids.filter(function(id){return!!products[id]&&products[id].productData;}).map(function(id){return products[id].productData;});});};/**
37
27
  * True when favorites where not yet fetched for the first time.
38
28
  * @param {Object} state The global state.
39
29
  * @returns {boolean}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/pwa-common-commerce",
3
- "version": "7.6.0-beta.3",
3
+ "version": "7.6.0",
4
4
  "description": "Commerce library for the Shopgate Connect PWA.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -19,8 +19,8 @@
19
19
  "reselect": "^3.0.1"
20
20
  },
21
21
  "devDependencies": {
22
- "@shopgate/pwa-common": "7.6.0-beta.3",
23
- "@shopgate/pwa-core": "7.6.0-beta.3",
22
+ "@shopgate/pwa-common": "7.6.0",
23
+ "@shopgate/pwa-core": "7.6.0",
24
24
  "lodash": "^4.17.4",
25
25
  "react": "~16.12.0",
26
26
  "react-dom": "~16.12.0"
@@ -1,4 +1,4 @@
1
- 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);}import{getProductDataById}from'@shopgate/engage/product/selectors/product';import{shouldFetchData}from'@shopgate/pwa-common/helpers/redux';import fetchProducts from"./fetchProducts";/**
1
+ 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);}import{shouldFetchData}from'@shopgate/pwa-common/helpers/redux';import fetchProducts from"./fetchProducts";/**
2
2
  * Retrieves products by id from the store.
3
3
  * @param {Array} productIds The product id's to request.
4
4
  * @param {string} [componentId=null] A unique id for the component that is using this action.
@@ -7,4 +7,5 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
7
7
  * @return {Function} A Redux Thunk
8
8
  */var fetchProductsById=function fetchProductsById(productIds){var componentId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var cached=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var includeFulfillment=arguments.length>3&&arguments[3]!==undefined?arguments[3]:true;return function(dispatch,getState){var state=getState();var products=state.product.productsById;// Filter out only the products that are not yet available in the store.
9
9
  var missingIds=productIds.filter(function(id){return shouldFetchData(products[id]);});// Then only perform a pipeline request if there are products missing.
10
- if(!missingIds.length){var productsById=productIds.map(function(id){return getProductDataById(state,{productId:id});});var totalProductCount=productsById.length;return{products:productsById,totalProductCount:totalProductCount};}return dispatch(fetchProducts(_extends({},componentId&&{id:componentId},{cached:cached,params:{productIds:missingIds},includeFulfillment:includeFulfillment,includeFilters:false,includeSort:false})));};};export default fetchProductsById;
10
+ if(!missingIds.length){return;}// eslint-disable-next-line consistent-return
11
+ return dispatch(fetchProducts(_extends({},componentId&&{id:componentId},{cached:cached,params:{productIds:missingIds},includeFulfillment:includeFulfillment,includeFilters:false,includeSort:false})));};};export default fetchProductsById;