@shopgate/pwa-common-commerce 7.30.0-alpha.7 → 7.30.0-alpha.8

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.
Files changed (315) hide show
  1. package/cart/action-creators/addCouponsToCart.js +9 -2
  2. package/cart/action-creators/addProductsToCart.js +9 -2
  3. package/cart/action-creators/deleteCouponsFromCart.js +9 -2
  4. package/cart/action-creators/deleteProductsFromCart.js +9 -2
  5. package/cart/action-creators/errorAddCouponsToCart.js +10 -2
  6. package/cart/action-creators/errorAddProductsToCart.js +10 -2
  7. package/cart/action-creators/errorCart.js +8 -2
  8. package/cart/action-creators/errorDeleteCouponsFromCart.js +10 -2
  9. package/cart/action-creators/errorDeleteProductsFromCart.js +10 -2
  10. package/cart/action-creators/errorUpdateProductsInCart.js +10 -2
  11. package/cart/action-creators/receiveCart.js +9 -2
  12. package/cart/action-creators/requestCart.js +8 -2
  13. package/cart/action-creators/setCartProductPendingCount.js +9 -2
  14. package/cart/action-creators/setCouponFieldError.js +9 -2
  15. package/cart/action-creators/setCouponFieldValue.js +9 -2
  16. package/cart/action-creators/setFulfillmentSlot.js +9 -2
  17. package/cart/action-creators/successAddCouponsToCart.js +10 -2
  18. package/cart/action-creators/successAddProductsToCart.js +8 -2
  19. package/cart/action-creators/successDeleteCouponsFromCart.js +8 -2
  20. package/cart/action-creators/successDeleteProductsFromCart.js +8 -2
  21. package/cart/action-creators/successUpdateProductsInCart.js +8 -2
  22. package/cart/action-creators/updateProductsInCart.js +9 -2
  23. package/cart/actions/addCouponsToCart.js +52 -8
  24. package/cart/actions/addProductsToCart.js +80 -11
  25. package/cart/actions/deleteCouponsFromCart.js +39 -6
  26. package/cart/actions/deleteProductsFromCart.js +38 -6
  27. package/cart/actions/fetchCart.js +52 -8
  28. package/cart/actions/updateProductsInCart.js +44 -6
  29. package/cart/constants/PipelineErrors.js +6 -1
  30. package/cart/constants/Pipelines.js +6 -1
  31. package/cart/constants/Portals.js +85 -1
  32. package/cart/constants/index.js +39 -2
  33. package/cart/helpers/config.js +47 -2
  34. package/cart/helpers/createPipelineErrorList.js +30 -4
  35. package/cart/helpers/fulfillmentSlots.js +37 -4
  36. package/cart/helpers/index.js +14 -3
  37. package/cart/helpers/quantity.js +23 -4
  38. package/cart/helpers/shipping.js +57 -2
  39. package/cart/helpers/tax.js +26 -2
  40. package/cart/index.js +25 -5
  41. package/cart/mock.js +130 -1
  42. package/cart/reducers/couponField.js +30 -2
  43. package/cart/reducers/data.js +98 -6
  44. package/cart/reducers/index.js +7 -1
  45. package/cart/selectors/index.js +181 -31
  46. package/cart/selectors/spec.js +189 -2
  47. package/cart/streams/index.js +176 -29
  48. package/cart/subscriptions/index.js +307 -30
  49. package/category/action-creators/errorCategory.js +10 -2
  50. package/category/action-creators/errorCategoryChildren.js +9 -2
  51. package/category/action-creators/errorRootCategories.js +8 -2
  52. package/category/action-creators/receiveCategory.js +12 -2
  53. package/category/action-creators/receiveCategoryChildren.js +10 -2
  54. package/category/action-creators/receiveRootCategories.js +9 -2
  55. package/category/action-creators/requestCategory.js +9 -2
  56. package/category/action-creators/requestCategoryChildren.js +9 -2
  57. package/category/action-creators/requestRootCategories.js +8 -2
  58. package/category/actions/fetchCategory.js +47 -5
  59. package/category/actions/fetchCategoryChildren.js +30 -2
  60. package/category/actions/fetchCategoryOrRootCategories.js +16 -2
  61. package/category/actions/fetchCategoryProducts.js +36 -2
  62. package/category/actions/fetchRootCategories.js +31 -2
  63. package/category/actions/getCategory.js +10 -2
  64. package/category/constants/Pipelines.js +3 -1
  65. package/category/constants/Portals.js +56 -3
  66. package/category/constants/index.js +17 -2
  67. package/category/helpers/index.js +27 -3
  68. package/category/index.js +19 -5
  69. package/category/mock.js +176 -1
  70. package/category/reducers/categoriesById.js +65 -3
  71. package/category/reducers/childrenByCategoryId.js +55 -4
  72. package/category/reducers/helpers/handleCategoryCollection.js +24 -3
  73. package/category/reducers/helpers/handleReceivedCategories.js +3 -1
  74. package/category/reducers/index.js +12 -2
  75. package/category/reducers/rootCategories.js +31 -2
  76. package/category/selectors/index.js +115 -16
  77. package/category/streams/index.js +82 -4
  78. package/category/subscriptions/index.js +96 -3
  79. package/checkout/action-creators/successCheckout.js +9 -2
  80. package/checkout/actions/fetchCheckoutUrl.js +28 -3
  81. package/checkout/constants/Pipelines.js +1 -1
  82. package/checkout/constants/index.js +3 -2
  83. package/checkout/index.js +11 -4
  84. package/checkout/selectors/index.js +7 -2
  85. package/checkout/streams/index.js +8 -2
  86. package/checkout/subscriptions/index.js +35 -6
  87. package/favorites/action-creators/index.js +206 -24
  88. package/favorites/actions/addFavorites.js +41 -3
  89. package/favorites/actions/addFavoritesList.js +27 -2
  90. package/favorites/actions/fetchFavoriteIds.js +49 -5
  91. package/favorites/actions/fetchFavorites.js +60 -5
  92. package/favorites/actions/fetchFavoritesList.js +47 -3
  93. package/favorites/actions/fetchFavoritesListsWithItems.js +32 -3
  94. package/favorites/actions/getFavorites.js +6 -2
  95. package/favorites/actions/removeFavorites.js +32 -3
  96. package/favorites/actions/removeFavoritesList.js +24 -2
  97. package/favorites/actions/toggleFavorites.js +68 -10
  98. package/favorites/actions/updateFavorites.js +39 -3
  99. package/favorites/actions/updateFavoritesList.js +26 -2
  100. package/favorites/constants/Pipelines.js +9 -1
  101. package/favorites/constants/Portals.js +32 -4
  102. package/favorites/constants/index.js +37 -5
  103. package/favorites/index.js +14 -4
  104. package/favorites/mock.js +89 -4
  105. package/favorites/reducers/index.js +7 -1
  106. package/favorites/reducers/lists.js +74 -2
  107. package/favorites/reducers/products.js +231 -24
  108. package/favorites/selectors/index.js +188 -24
  109. package/favorites/streams/index.js +135 -23
  110. package/favorites/streams/spec.js +517 -8
  111. package/favorites/subscriptions/index.js +260 -25
  112. package/favorites/subscriptions/spec.js +701 -28
  113. package/filter/action-creators/errorFilters.js +9 -2
  114. package/filter/action-creators/index.js +4 -1
  115. package/filter/action-creators/receiveFilters.js +10 -2
  116. package/filter/action-creators/requestFilters.js +9 -2
  117. package/filter/action-creators/updateFilters.js +8 -2
  118. package/filter/actions/fetchFilters.js +46 -3
  119. package/filter/actions/getFilters.js +6 -2
  120. package/filter/actions/helpers/buildFilterParams.js +34 -2
  121. package/filter/actions/helpers/buildRequestFilters.js +35 -2
  122. package/filter/actions/helpers/processFilters.js +10 -2
  123. package/filter/actions/helpers/processParams.js +26 -2
  124. package/filter/constants/Pipelines.js +1 -1
  125. package/filter/constants/Portals.js +39 -3
  126. package/filter/constants/index.js +8 -1
  127. package/filter/index.js +12 -4
  128. package/filter/reducers/helpers/enrichFilters.js +11 -3
  129. package/filter/reducers/index.js +5 -1
  130. package/filter/reducers/resultsByHash.js +43 -3
  131. package/filter/selectors/index.js +47 -6
  132. package/filter/streams/index.js +30 -1
  133. package/filter/subscriptions/index.js +34 -2
  134. package/market/constants/Portals.js +22 -4
  135. package/market/constants/index.js +2 -1
  136. package/market/helpers/showReturnPolicy.js +3 -1
  137. package/market/helpers/showTaxDisclaimer.js +3 -1
  138. package/market/index.js +6 -2
  139. package/orders/constants.js +2 -1
  140. package/package.json +3 -3
  141. package/product/action-creators/deleteProductsByIds.js +10 -2
  142. package/product/action-creators/errorProduct.js +10 -2
  143. package/product/action-creators/errorProductDescription.js +10 -2
  144. package/product/action-creators/errorProductImages.js +10 -2
  145. package/product/action-creators/errorProductMedia.js +10 -2
  146. package/product/action-creators/errorProductOptions.js +10 -2
  147. package/product/action-creators/errorProductProperties.js +10 -2
  148. package/product/action-creators/errorProductRelations.js +9 -2
  149. package/product/action-creators/errorProductShipping.js +10 -2
  150. package/product/action-creators/errorProductVariants.js +10 -2
  151. package/product/action-creators/errorProducts.js +9 -2
  152. package/product/action-creators/expireProductById.js +10 -2
  153. package/product/action-creators/expireProductData.js +11 -2
  154. package/product/action-creators/expireProductsByHash.js +9 -2
  155. package/product/action-creators/productNotAvailable.js +10 -2
  156. package/product/action-creators/provideProduct.js +9 -2
  157. package/product/action-creators/receiveProduct.js +10 -2
  158. package/product/action-creators/receiveProductCached.js +9 -2
  159. package/product/action-creators/receiveProductDescription.js +10 -2
  160. package/product/action-creators/receiveProductImages.js +10 -2
  161. package/product/action-creators/receiveProductMedia.js +10 -2
  162. package/product/action-creators/receiveProductOptions.js +10 -2
  163. package/product/action-creators/receiveProductProperties.js +10 -2
  164. package/product/action-creators/receiveProductRelations.js +12 -2
  165. package/product/action-creators/receiveProductShipping.js +10 -2
  166. package/product/action-creators/receiveProductVariants.js +10 -2
  167. package/product/action-creators/receiveProducts.js +16 -2
  168. package/product/action-creators/receiveProductsCached.js +9 -2
  169. package/product/action-creators/refreshExpiredPDPData.js +8 -2
  170. package/product/action-creators/requestProduct.js +10 -2
  171. package/product/action-creators/requestProductDescription.js +9 -2
  172. package/product/action-creators/requestProductImages.js +9 -2
  173. package/product/action-creators/requestProductMedia.js +9 -2
  174. package/product/action-creators/requestProductOptions.js +9 -2
  175. package/product/action-creators/requestProductProperties.js +9 -2
  176. package/product/action-creators/requestProductRelations.js +10 -2
  177. package/product/action-creators/requestProductShipping.js +9 -2
  178. package/product/action-creators/requestProductVariants.js +9 -2
  179. package/product/action-creators/requestProducts.js +9 -2
  180. package/product/action-creators/setProductId.js +9 -2
  181. package/product/action-creators/setProductQuantity.js +9 -2
  182. package/product/action-creators/setProductVariantId.js +9 -2
  183. package/product/actions/changeSortOrder.js +21 -2
  184. package/product/actions/fetchHighlightProducts.js +18 -2
  185. package/product/actions/fetchLiveshoppingProducts.js +14 -2
  186. package/product/actions/fetchProduct.js +52 -3
  187. package/product/actions/fetchProductDescription.js +30 -2
  188. package/product/actions/fetchProductImages.js +31 -2
  189. package/product/actions/fetchProductMedia.js +35 -2
  190. package/product/actions/fetchProductOptions.js +31 -2
  191. package/product/actions/fetchProductProperties.js +30 -2
  192. package/product/actions/fetchProductRelations.js +63 -2
  193. package/product/actions/fetchProductShipping.js +31 -2
  194. package/product/actions/fetchProductVariants.js +31 -2
  195. package/product/actions/fetchProducts.js +189 -17
  196. package/product/actions/fetchProductsById.js +68 -8
  197. package/product/actions/fetchProductsByQuery.js +102 -18
  198. package/product/actions/getHighlightProducts.js +6 -2
  199. package/product/actions/getLiveshoppingProducts.js +6 -2
  200. package/product/actions/getProduct.js +6 -2
  201. package/product/actions/getProductDescription.js +6 -2
  202. package/product/actions/getProductImages.js +6 -2
  203. package/product/actions/getProductOptions.js +6 -2
  204. package/product/actions/getProductProperties.js +6 -2
  205. package/product/actions/getProductRelations.js +6 -2
  206. package/product/actions/getProductShipping.js +6 -2
  207. package/product/actions/getProductVariants.js +6 -2
  208. package/product/actions/getProducts.js +6 -2
  209. package/product/actions/getProductsById.js +6 -2
  210. package/product/actions/getProductsByQuery.js +6 -2
  211. package/product/actions/processProductFlags.js +35 -3
  212. package/product/actions/updateMetadata.js +17 -2
  213. package/product/collections/ProductImageFormats.js +48 -8
  214. package/product/collections/index.js +1 -1
  215. package/product/constants/Pipelines.js +12 -1
  216. package/product/constants/Portals.js +200 -33
  217. package/product/constants/index.js +90 -18
  218. package/product/helpers/index.js +61 -8
  219. package/product/index.js +36 -6
  220. package/product/mock.js +1002 -2
  221. package/product/reducers/descriptionsByProductId.js +54 -5
  222. package/product/reducers/helpers/formatOptions.js +17 -2
  223. package/product/reducers/helpers/handleProductCollection.js +19 -2
  224. package/product/reducers/imagesByProductId.js +51 -4
  225. package/product/reducers/index.js +23 -1
  226. package/product/reducers/mediaByProductId.js +55 -3
  227. package/product/reducers/optionsByProductId.js +41 -2
  228. package/product/reducers/productRelationsByHash.js +43 -2
  229. package/product/reducers/productsById.js +122 -7
  230. package/product/reducers/propertiesByProductId.js +48 -2
  231. package/product/reducers/resultsByHash.js +125 -9
  232. package/product/reducers/shippingByProductId.js +37 -2
  233. package/product/reducers/variantsByProductId.js +56 -2
  234. package/product/selectors/options.js +90 -13
  235. package/product/selectors/page.js +62 -13
  236. package/product/selectors/price.js +81 -18
  237. package/product/selectors/product.js +549 -59
  238. package/product/selectors/product.mock.js +327 -12
  239. package/product/selectors/relations.js +35 -5
  240. package/product/selectors/variants.js +91 -15
  241. package/product/streams/index.js +167 -13
  242. package/product/subscriptions/index.js +210 -4
  243. package/reviews/action-creators/errorProductReviews.js +9 -2
  244. package/reviews/action-creators/errorReviews.js +9 -2
  245. package/reviews/action-creators/errorSubmitReview.js +9 -2
  246. package/reviews/action-creators/errorUserReview.js +9 -2
  247. package/reviews/action-creators/flushUserReview.js +8 -2
  248. package/reviews/action-creators/receiveProductReviews.js +11 -2
  249. package/reviews/action-creators/receiveReviews.js +12 -2
  250. package/reviews/action-creators/receiveSubmitReview.js +9 -2
  251. package/reviews/action-creators/receiveUserReview.js +10 -2
  252. package/reviews/action-creators/requestProductReviews.js +10 -2
  253. package/reviews/action-creators/requestReviews.js +9 -2
  254. package/reviews/action-creators/requestSubmitReview.js +9 -2
  255. package/reviews/action-creators/requestUserReview.js +9 -2
  256. package/reviews/action-creators/resetSubmittedReview.js +9 -2
  257. package/reviews/action-creators/spec.js +40 -1
  258. package/reviews/actions/fetchProductReviews.js +37 -2
  259. package/reviews/actions/fetchReviews.js +38 -2
  260. package/reviews/actions/fetchUserReview.js +31 -2
  261. package/reviews/actions/flushUserReview.js +5 -1
  262. package/reviews/actions/getProductReviews.js +6 -2
  263. package/reviews/actions/getUserReview.js +6 -2
  264. package/reviews/actions/spec.js +241 -4
  265. package/reviews/actions/submitReview.js +63 -3
  266. package/reviews/constants/Pipelines.js +4 -1
  267. package/reviews/constants/Portals.js +4 -1
  268. package/reviews/constants/index.js +26 -7
  269. package/reviews/index.js +15 -4
  270. package/reviews/mock.js +172 -11
  271. package/reviews/reducers/index.js +11 -1
  272. package/reviews/reducers/mock.js +14 -2
  273. package/reviews/reducers/reviewsByHash.js +52 -6
  274. package/reviews/reducers/reviewsById.js +27 -2
  275. package/reviews/reducers/reviewsByProductId.js +47 -2
  276. package/reviews/reducers/spec.js +211 -2
  277. package/reviews/reducers/userReviewsByProductId.js +68 -2
  278. package/reviews/selectors/index.js +123 -19
  279. package/reviews/selectors/mock.js +100 -1
  280. package/reviews/selectors/spec.js +100 -1
  281. package/reviews/streams/index.js +37 -5
  282. package/reviews/streams/spec.js +25 -1
  283. package/reviews/subscriptions/index.js +27 -2
  284. package/scanner/action-creators/errorHandleScanner.js +11 -2
  285. package/scanner/action-creators/scannerFinished.js +11 -2
  286. package/scanner/action-creators/startScanner.js +8 -2
  287. package/scanner/action-creators/successHandleScanner.js +11 -2
  288. package/scanner/actions/handleBarCode.js +22 -2
  289. package/scanner/actions/handleNoResults.js +23 -2
  290. package/scanner/actions/handleQrCode.js +116 -6
  291. package/scanner/actions/handleSearch.js +33 -2
  292. package/scanner/constants/Portals.js +22 -1
  293. package/scanner/constants/index.js +17 -1
  294. package/scanner/helpers/index.js +115 -5
  295. package/scanner/index.js +19 -5
  296. package/scanner/streams/index.js +36 -1
  297. package/scanner/subscriptions/index.js +78 -8
  298. package/search/action-creators/errorSearchResults.js +10 -2
  299. package/search/action-creators/receiveSearchResults.js +11 -2
  300. package/search/action-creators/receiveSearchSuggestions.js +10 -2
  301. package/search/action-creators/requestSearchResults.js +10 -2
  302. package/search/action-creators/requestSearchSuggestions.js +9 -2
  303. package/search/actions/fetchSearchResults.js +66 -8
  304. package/search/actions/fetchSearchSuggestions.js +36 -2
  305. package/search/constants/Pipelines.js +1 -1
  306. package/search/constants/Portals.js +9 -2
  307. package/search/constants/index.js +10 -2
  308. package/search/helpers/index.js +5 -2
  309. package/search/helpers/removeHighlightingPlaceholders.js +4 -1
  310. package/search/helpers/spec.js +19 -1
  311. package/search/index.js +17 -5
  312. package/search/reducers/index.js +38 -2
  313. package/search/selectors/index.js +23 -4
  314. package/search/streams/index.js +51 -3
  315. package/search/subscriptions/index.js +132 -5
@@ -1,4 +1,9 @@
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{ITEMS_PER_LOAD}from'@shopgate/pwa-common/constants/DisplayOptions';import{getSortOrder}from'@shopgate/pwa-common/selectors/history';import{mutable}from'@shopgate/pwa-common/helpers/redux';import fetchProducts from"../../product/actions/fetchProducts";/**
1
+ import { ITEMS_PER_LOAD } from '@shopgate/pwa-common/constants/DisplayOptions';
2
+ import { getSortOrder } from '@shopgate/pwa-common/selectors/history';
3
+ import { mutable } from '@shopgate/pwa-common/helpers/redux';
4
+ import fetchProducts from "../../product/actions/fetchProducts";
5
+
6
+ /**
2
7
  * Retrieves category products by a category id.
3
8
  * @param {string} categoryId The category id to requests products for.
4
9
  * @param {Object} [filters=null] The filters.
@@ -9,4 +14,33 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
9
14
  * @param {null|number} [cachedTime=null] The cache TTL.
10
15
  * @param {Object} params additional params.
11
16
  * @return {Function} The dispatched action.
12
- */var fetchCategoryProducts=function fetchCategoryProducts(_ref){var categoryId=_ref.categoryId,_ref$filters=_ref.filters,filters=_ref$filters===void 0?null:_ref$filters,_ref$offset=_ref.offset,offset=_ref$offset===void 0?0:_ref$offset,_ref$limit=_ref.limit,limit=_ref$limit===void 0?ITEMS_PER_LOAD:_ref$limit,sort=_ref.sort,_ref$cached=_ref.cached,cached=_ref$cached===void 0?true:_ref$cached,_ref$cachedTime=_ref.cachedTime,cachedTime=_ref$cachedTime===void 0?null:_ref$cachedTime,params=_ref.params;return function(dispatch,getState){var sortOrder=sort||getSortOrder(getState(),{categoryId:categoryId});return dispatch(fetchProducts({cached:cached,cachedTime:cachedTime,params:_extends({categoryId:categoryId,offset:offset,limit:limit,sort:sortOrder},params),filters:filters}));};};/** @mixes {MutableFunction} */export default mutable(fetchCategoryProducts);
17
+ */
18
+ const fetchCategoryProducts = ({
19
+ categoryId,
20
+ filters = null,
21
+ offset = 0,
22
+ limit = ITEMS_PER_LOAD,
23
+ sort,
24
+ cached = true,
25
+ cachedTime = null,
26
+ params
27
+ }) => (dispatch, getState) => {
28
+ const sortOrder = sort || getSortOrder(getState(), {
29
+ categoryId
30
+ });
31
+ return dispatch(fetchProducts({
32
+ cached,
33
+ cachedTime,
34
+ params: {
35
+ categoryId,
36
+ offset,
37
+ limit,
38
+ sort: sortOrder,
39
+ ...params
40
+ },
41
+ filters
42
+ }));
43
+ };
44
+
45
+ /** @mixes {MutableFunction} */
46
+ export default mutable(fetchCategoryProducts);
@@ -1,4 +1,33 @@
1
- import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{shouldFetchData,mutable}from'@shopgate/pwa-common/helpers/redux';import{SHOPGATE_CATALOG_GET_ROOT_CATEGORIES}from"../constants/Pipelines";import requestRootCategories from"../action-creators/requestRootCategories";import receiveRootCategories from"../action-creators/receiveRootCategories";import errorRootCategories from"../action-creators/errorRootCategories";/**
1
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
2
+ import { shouldFetchData, mutable } from '@shopgate/pwa-common/helpers/redux';
3
+ import { SHOPGATE_CATALOG_GET_ROOT_CATEGORIES } from "../constants/Pipelines";
4
+ import requestRootCategories from "../action-creators/requestRootCategories";
5
+ import receiveRootCategories from "../action-creators/receiveRootCategories";
6
+ import errorRootCategories from "../action-creators/errorRootCategories";
7
+
8
+ /**
2
9
  * Retrieves the root categories from store.
3
10
  * @return {Function} The dispatched action.
4
- */function fetchRootCategories(){return function(dispatch,getState){var state=getState();var rootCategories=state.category.rootCategories;if(!shouldFetchData(rootCategories,'categories')){return Promise.resolve(null);}dispatch(requestRootCategories());var request=new PipelineRequest(SHOPGATE_CATALOG_GET_ROOT_CATEGORIES).dispatch();request.then(function(result){dispatch(receiveRootCategories(result.categories));})["catch"](function(){dispatch(errorRootCategories());});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchRootCategories);
11
+ */
12
+ function fetchRootCategories() {
13
+ return (dispatch, getState) => {
14
+ const state = getState();
15
+ const {
16
+ rootCategories
17
+ } = state.category;
18
+ if (!shouldFetchData(rootCategories, 'categories')) {
19
+ return Promise.resolve(null);
20
+ }
21
+ dispatch(requestRootCategories());
22
+ const request = new PipelineRequest(SHOPGATE_CATALOG_GET_ROOT_CATEGORIES).dispatch();
23
+ request.then(result => {
24
+ dispatch(receiveRootCategories(result.categories));
25
+ }).catch(() => {
26
+ dispatch(errorRootCategories());
27
+ });
28
+ return request;
29
+ };
30
+ }
31
+
32
+ /** @mixes {MutableFunction} */
33
+ export default mutable(fetchRootCategories);
@@ -1,6 +1,14 @@
1
- import{logDeprecationMessage}from'@shopgate/pwa-core/helpers';import fetchCategoryOrRootCategories from"./fetchCategoryOrRootCategories";/**
1
+ import { logDeprecationMessage } from '@shopgate/pwa-core/helpers';
2
+ import fetchCategoryOrRootCategories from "./fetchCategoryOrRootCategories";
3
+
4
+ /**
2
5
  * Deprecation fallback for the fetchCategoryOrRootCategories action
3
6
  * @deprecated
4
7
  * @param {string} categoryId The category ID.
5
8
  * @return {Function} The dispatched action.
6
- */var getCategory=function getCategory(categoryId){logDeprecationMessage('The fetch action getCategory will be removed in future versions due naming conflict with getCategory selector. Please use fetchCategoryOrRootCategories as a replacement');return fetchCategoryOrRootCategories(categoryId);};export default getCategory;
9
+ */
10
+ const getCategory = categoryId => {
11
+ logDeprecationMessage('The fetch action getCategory will be removed in future versions due naming conflict with getCategory selector. Please use fetchCategoryOrRootCategories as a replacement');
12
+ return fetchCategoryOrRootCategories(categoryId);
13
+ };
14
+ export default getCategory;
@@ -1 +1,3 @@
1
- export var SHOPGATE_CATALOG_GET_CATEGORY='shopgate.catalog.getCategory';export var SHOPGATE_CATALOG_GET_CATEGORY_CHILDREN='shopgate.catalog.getCategoryChildren';export var SHOPGATE_CATALOG_GET_ROOT_CATEGORIES='shopgate.catalog.getRootCategories';
1
+ export const SHOPGATE_CATALOG_GET_CATEGORY = 'shopgate.catalog.getCategory';
2
+ export const SHOPGATE_CATALOG_GET_CATEGORY_CHILDREN = 'shopgate.catalog.getCategoryChildren';
3
+ export const SHOPGATE_CATALOG_GET_ROOT_CATEGORIES = 'shopgate.catalog.getRootCategories';
@@ -1,4 +1,57 @@
1
1
  // FEATURES
2
- var CATEGORY='category';var PRODUCT='product';var NAV_MENU='nav-menu';// CONTENTS
3
- var LIST='list';var ITEM='item';var IMAGE='image';var PRICE='price';var DISCOUNT='discount';var FAVORITES_BUTTON='favorites-button';var NAME='name';var MANUFACTURER='manufacturer';var AVAILABILITY='availability';var CATEGORIES='categories';// POSITIONS
4
- var BEFORE='before';var AFTER='after';var INSIDE='inside';export var CATEGORY_LIST="".concat(CATEGORY,".").concat(LIST);export var CATEGORY_LIST_BEFORE="".concat(CATEGORY,".").concat(LIST,".").concat(BEFORE);export var CATEGORY_LIST_AFTER="".concat(CATEGORY,".").concat(LIST,".").concat(AFTER);export var CATEGORY_ITEM="".concat(CATEGORY,".").concat(ITEM);export var PRODUCT_LIST="".concat(PRODUCT,".").concat(LIST);export var PRODUCT_LIST_BEFORE="".concat(PRODUCT,".").concat(LIST,".").concat(BEFORE);export var PRODUCT_LIST_AFTER="".concat(PRODUCT,".").concat(LIST,".").concat(AFTER);export var PRODUCT_ITEM_BEFORE="".concat(PRODUCT,".").concat(ITEM,".").concat(BEFORE);export var PRODUCT_ITEM="".concat(PRODUCT,".").concat(ITEM);export var PRODUCT_ITEM_AFTER="".concat(PRODUCT,".").concat(ITEM,".").concat(AFTER);export var PRODUCT_ITEM_IMAGE_BEFORE="".concat(PRODUCT,"-").concat(ITEM,".").concat(IMAGE,".").concat(BEFORE);export var PRODUCT_ITEM_IMAGE="".concat(PRODUCT,"-").concat(ITEM,".").concat(IMAGE);export var PRODUCT_ITEM_IMAGE_AFTER="".concat(PRODUCT,"-").concat(ITEM,".").concat(IMAGE,".").concat(AFTER);export var PRODUCT_ITEM_DISCOUNT_BEFORE="".concat(PRODUCT,"-").concat(ITEM,".").concat(DISCOUNT,".").concat(BEFORE);export var PRODUCT_ITEM_DISCOUNT="".concat(PRODUCT,"-").concat(ITEM,".").concat(DISCOUNT);export var PRODUCT_ITEM_DISCOUNT_AFTER="".concat(PRODUCT,"-").concat(ITEM,".").concat(DISCOUNT,".").concat(AFTER);export var PRODUCT_ITEM_FAVORITES_BUTTON_BEFORE="".concat(PRODUCT,"-").concat(ITEM,".").concat(FAVORITES_BUTTON,".").concat(BEFORE);export var PRODUCT_ITEM_FAVORITES_BUTTON="".concat(PRODUCT,"-").concat(ITEM,".").concat(FAVORITES_BUTTON);export var PRODUCT_ITEM_FAVORITES_BUTTON_AFTER="".concat(PRODUCT,"-").concat(ITEM,".").concat(FAVORITES_BUTTON,".").concat(AFTER);export var PRODUCT_ITEM_NAME_BEFORE="".concat(PRODUCT,"-").concat(ITEM,".").concat(NAME,".").concat(BEFORE);export var PRODUCT_ITEM_NAME="".concat(PRODUCT,"-").concat(ITEM,".").concat(NAME);export var PRODUCT_ITEM_NAME_AFTER="".concat(PRODUCT,"-").concat(ITEM,".").concat(NAME,".").concat(AFTER);export var PRODUCT_ITEM_PRICE_BEFORE="".concat(PRODUCT,"-").concat(ITEM,".").concat(PRICE,".").concat(BEFORE);export var PRODUCT_ITEM_PRICE_INSIDE_BEFORE="".concat(PRODUCT,"-").concat(ITEM,"-").concat(INSIDE,".").concat(PRICE,".").concat(BEFORE);export var PRODUCT_ITEM_PRICE="".concat(PRODUCT,"-").concat(ITEM,".").concat(PRICE);export var PRODUCT_ITEM_PRICE_INSIDE_AFTER="".concat(PRODUCT,"-").concat(ITEM,"-").concat(INSIDE,".").concat(PRICE,".").concat(AFTER);export var PRODUCT_ITEM_PRICE_AFTER="".concat(PRODUCT,"-").concat(ITEM,".").concat(PRICE,".").concat(AFTER);export var PRODUCT_ITEM_MANUFACTURER_BEFORE="".concat(PRODUCT,"-").concat(ITEM,".").concat(MANUFACTURER,".").concat(BEFORE);export var PRODUCT_ITEM_MANUFACTURER="".concat(PRODUCT,"-").concat(ITEM,".").concat(MANUFACTURER);export var PRODUCT_ITEM_MANUFACTURER_AFTER="".concat(PRODUCT,"-").concat(ITEM,".").concat(MANUFACTURER,".").concat(AFTER);export var PRODUCT_ITEM_AVAILABILITY_BEFORE="".concat(PRODUCT,"-").concat(ITEM,".").concat(AVAILABILITY,".").concat(BEFORE);export var PRODUCT_ITEM_AVAILABILITY="".concat(PRODUCT,"-").concat(ITEM,".").concat(AVAILABILITY);export var PRODUCT_ITEM_AVAILABILITY_AFTER="".concat(PRODUCT,"-").concat(ITEM,".").concat(AVAILABILITY,".").concat(AFTER);export var NAV_MENU_CATEGORIES_BEFORE="".concat(NAV_MENU,".").concat(CATEGORIES,".").concat(BEFORE);export var NAV_MENU_CATEGORIES="".concat(NAV_MENU,".").concat(CATEGORIES);export var NAV_MENU_CATEGORIES_AFTER="".concat(NAV_MENU,".").concat(CATEGORIES,".").concat(AFTER);
2
+ const CATEGORY = 'category';
3
+ const PRODUCT = 'product';
4
+ const NAV_MENU = 'nav-menu';
5
+
6
+ // CONTENTS
7
+ const LIST = 'list';
8
+ const ITEM = 'item';
9
+ const IMAGE = 'image';
10
+ const PRICE = 'price';
11
+ const DISCOUNT = 'discount';
12
+ const FAVORITES_BUTTON = 'favorites-button';
13
+ const NAME = 'name';
14
+ const MANUFACTURER = 'manufacturer';
15
+ const AVAILABILITY = 'availability';
16
+ const CATEGORIES = 'categories';
17
+
18
+ // POSITIONS
19
+ const BEFORE = 'before';
20
+ const AFTER = 'after';
21
+ const INSIDE = 'inside';
22
+ export const CATEGORY_LIST = `${CATEGORY}.${LIST}`;
23
+ export const CATEGORY_LIST_BEFORE = `${CATEGORY}.${LIST}.${BEFORE}`;
24
+ export const CATEGORY_LIST_AFTER = `${CATEGORY}.${LIST}.${AFTER}`;
25
+ export const CATEGORY_ITEM = `${CATEGORY}.${ITEM}`;
26
+ export const PRODUCT_LIST = `${PRODUCT}.${LIST}`;
27
+ export const PRODUCT_LIST_BEFORE = `${PRODUCT}.${LIST}.${BEFORE}`;
28
+ export const PRODUCT_LIST_AFTER = `${PRODUCT}.${LIST}.${AFTER}`;
29
+ export const PRODUCT_ITEM_BEFORE = `${PRODUCT}.${ITEM}.${BEFORE}`;
30
+ export const PRODUCT_ITEM = `${PRODUCT}.${ITEM}`;
31
+ export const PRODUCT_ITEM_AFTER = `${PRODUCT}.${ITEM}.${AFTER}`;
32
+ export const PRODUCT_ITEM_IMAGE_BEFORE = `${PRODUCT}-${ITEM}.${IMAGE}.${BEFORE}`;
33
+ export const PRODUCT_ITEM_IMAGE = `${PRODUCT}-${ITEM}.${IMAGE}`;
34
+ export const PRODUCT_ITEM_IMAGE_AFTER = `${PRODUCT}-${ITEM}.${IMAGE}.${AFTER}`;
35
+ export const PRODUCT_ITEM_DISCOUNT_BEFORE = `${PRODUCT}-${ITEM}.${DISCOUNT}.${BEFORE}`;
36
+ export const PRODUCT_ITEM_DISCOUNT = `${PRODUCT}-${ITEM}.${DISCOUNT}`;
37
+ export const PRODUCT_ITEM_DISCOUNT_AFTER = `${PRODUCT}-${ITEM}.${DISCOUNT}.${AFTER}`;
38
+ export const PRODUCT_ITEM_FAVORITES_BUTTON_BEFORE = `${PRODUCT}-${ITEM}.${FAVORITES_BUTTON}.${BEFORE}`;
39
+ export const PRODUCT_ITEM_FAVORITES_BUTTON = `${PRODUCT}-${ITEM}.${FAVORITES_BUTTON}`;
40
+ export const PRODUCT_ITEM_FAVORITES_BUTTON_AFTER = `${PRODUCT}-${ITEM}.${FAVORITES_BUTTON}.${AFTER}`;
41
+ export const PRODUCT_ITEM_NAME_BEFORE = `${PRODUCT}-${ITEM}.${NAME}.${BEFORE}`;
42
+ export const PRODUCT_ITEM_NAME = `${PRODUCT}-${ITEM}.${NAME}`;
43
+ export const PRODUCT_ITEM_NAME_AFTER = `${PRODUCT}-${ITEM}.${NAME}.${AFTER}`;
44
+ export const PRODUCT_ITEM_PRICE_BEFORE = `${PRODUCT}-${ITEM}.${PRICE}.${BEFORE}`;
45
+ export const PRODUCT_ITEM_PRICE_INSIDE_BEFORE = `${PRODUCT}-${ITEM}-${INSIDE}.${PRICE}.${BEFORE}`;
46
+ export const PRODUCT_ITEM_PRICE = `${PRODUCT}-${ITEM}.${PRICE}`;
47
+ export const PRODUCT_ITEM_PRICE_INSIDE_AFTER = `${PRODUCT}-${ITEM}-${INSIDE}.${PRICE}.${AFTER}`;
48
+ export const PRODUCT_ITEM_PRICE_AFTER = `${PRODUCT}-${ITEM}.${PRICE}.${AFTER}`;
49
+ export const PRODUCT_ITEM_MANUFACTURER_BEFORE = `${PRODUCT}-${ITEM}.${MANUFACTURER}.${BEFORE}`;
50
+ export const PRODUCT_ITEM_MANUFACTURER = `${PRODUCT}-${ITEM}.${MANUFACTURER}`;
51
+ export const PRODUCT_ITEM_MANUFACTURER_AFTER = `${PRODUCT}-${ITEM}.${MANUFACTURER}.${AFTER}`;
52
+ export const PRODUCT_ITEM_AVAILABILITY_BEFORE = `${PRODUCT}-${ITEM}.${AVAILABILITY}.${BEFORE}`;
53
+ export const PRODUCT_ITEM_AVAILABILITY = `${PRODUCT}-${ITEM}.${AVAILABILITY}`;
54
+ export const PRODUCT_ITEM_AVAILABILITY_AFTER = `${PRODUCT}-${ITEM}.${AVAILABILITY}.${AFTER}`;
55
+ export const NAV_MENU_CATEGORIES_BEFORE = `${NAV_MENU}.${CATEGORIES}.${BEFORE}`;
56
+ export const NAV_MENU_CATEGORIES = `${NAV_MENU}.${CATEGORIES}`;
57
+ export const NAV_MENU_CATEGORIES_AFTER = `${NAV_MENU}.${CATEGORIES}.${AFTER}`;
@@ -1,2 +1,17 @@
1
- export var CATEGORY_PATH='/category';export var ROOT_CATEGORY_PATTERN=CATEGORY_PATH;export var CATEGORY_PATTERN="".concat(CATEGORY_PATH,"/:categoryId");export var CATEGORY_FILTER_PATTERN="".concat(CATEGORY_PATH,"/:categoryId/filter");export var CATEGORY_ALL_PATTERN="".concat(CATEGORY_PATH,"/:categoryId/all");export var CATEGORY_ALL_FILTER_PATTERN="".concat(CATEGORY_PATH,"/:categoryId/all/filter");export var CATEGORY_LIFETIME=3600000;// 1 hour in milliseconds
2
- export var REQUEST_ROOT_CATEGORIES='REQUEST_ROOT_CATEGORIES';export var RECEIVE_ROOT_CATEGORIES='RECEIVE_ROOT_CATEGORIES';export var ERROR_ROOT_CATEGORIES='ERROR_ROOT_CATEGORIES';export var REQUEST_CATEGORY='REQUEST_CATEGORY';export var RECEIVE_CATEGORY='RECEIVE_CATEGORY';export var ERROR_CATEGORY='ERROR_CATEGORY';export var REQUEST_CATEGORY_CHILDREN='REQUEST_CATEGORY_CHILDREN';export var RECEIVE_CATEGORY_CHILDREN='RECEIVE_CATEGORY_CHILDREN';export var ERROR_CATEGORY_CHILDREN='ERROR_CATEGORY_CHILDREN';
1
+ export const CATEGORY_PATH = '/category';
2
+ export const ROOT_CATEGORY_PATTERN = CATEGORY_PATH;
3
+ export const CATEGORY_PATTERN = `${CATEGORY_PATH}/:categoryId`;
4
+ export const CATEGORY_FILTER_PATTERN = `${CATEGORY_PATH}/:categoryId/filter`;
5
+ export const CATEGORY_ALL_PATTERN = `${CATEGORY_PATH}/:categoryId/all`;
6
+ export const CATEGORY_ALL_FILTER_PATTERN = `${CATEGORY_PATH}/:categoryId/all/filter`;
7
+ export const CATEGORY_LIFETIME = 3600000; // 1 hour in milliseconds
8
+
9
+ export const REQUEST_ROOT_CATEGORIES = 'REQUEST_ROOT_CATEGORIES';
10
+ export const RECEIVE_ROOT_CATEGORIES = 'RECEIVE_ROOT_CATEGORIES';
11
+ export const ERROR_ROOT_CATEGORIES = 'ERROR_ROOT_CATEGORIES';
12
+ export const REQUEST_CATEGORY = 'REQUEST_CATEGORY';
13
+ export const RECEIVE_CATEGORY = 'RECEIVE_CATEGORY';
14
+ export const ERROR_CATEGORY = 'ERROR_CATEGORY';
15
+ export const REQUEST_CATEGORY_CHILDREN = 'REQUEST_CATEGORY_CHILDREN';
16
+ export const RECEIVE_CATEGORY_CHILDREN = 'RECEIVE_CATEGORY_CHILDREN';
17
+ export const ERROR_CATEGORY_CHILDREN = 'ERROR_CATEGORY_CHILDREN';
@@ -1,9 +1,33 @@
1
- import{bin2hex}from'@shopgate/pwa-common/helpers/data';import{i18n}from'@shopgate/engage/core';import{CATEGORY_PATH}from"../constants";/**
1
+ import { bin2hex } from '@shopgate/pwa-common/helpers/data';
2
+ import { i18n } from '@shopgate/engage/core';
3
+ import { CATEGORY_PATH } from "../constants";
4
+
5
+ /**
2
6
  * Generate category route for navigation.
3
7
  * @param {string} id category Id
4
8
  * @returns {string}
5
- */export var getCategoryRoute=function getCategoryRoute(id){return"".concat(CATEGORY_PATH,"/").concat(bin2hex(id));};/**
9
+ */
10
+ export const getCategoryRoute = id => `${CATEGORY_PATH}/${bin2hex(id)}`;
11
+
12
+ /**
6
13
  * Generate filters for show all products.
7
14
  * @param {Object} parentCategory parent category
8
15
  * @returns {Object}
9
- */export var getShowAllProductsFilters=function getShowAllProductsFilters(parentCategory){var filters={categories:{id:'categories',label:i18n.text('filter.label.category'),source:'categories',type:'multiselect',value:[{id:parentCategory?parentCategory.path:null,label:parentCategory?parentCategory.name:null,isHidden:true,useForFetchFilters:true}]}};return filters;};
16
+ */
17
+ export const getShowAllProductsFilters = parentCategory => {
18
+ const filters = {
19
+ categories: {
20
+ id: 'categories',
21
+ label: i18n.text('filter.label.category'),
22
+ source: 'categories',
23
+ type: 'multiselect',
24
+ value: [{
25
+ id: parentCategory ? parentCategory.path : null,
26
+ label: parentCategory ? parentCategory.name : null,
27
+ isHidden: true,
28
+ useForFetchFilters: true
29
+ }]
30
+ }
31
+ };
32
+ return filters;
33
+ };
package/category/index.js CHANGED
@@ -1,6 +1,20 @@
1
1
  // ACTIONS
2
- export{default as fetchCategory}from"./actions/fetchCategory";export{default as fetchCategoryOrRootCategories}from"./actions/fetchCategoryOrRootCategories";export{default as fetchCategoryChildren}from"./actions/fetchCategoryChildren";export{default as fetchCategoryProducts}from"./actions/fetchCategoryProducts";export{default as fetchRootCategories}from"./actions/fetchRootCategories";// CONSTANTS
3
- export*from"./constants/index";export*from"./constants/Pipelines";export*from"./constants/Portals";// SELECTORS
4
- export*from"./selectors";// STREAMS
5
- export*from"./streams";// HELPERS
6
- export*from"./helpers";
2
+ export { default as fetchCategory } from "./actions/fetchCategory";
3
+ export { default as fetchCategoryOrRootCategories } from "./actions/fetchCategoryOrRootCategories";
4
+ export { default as fetchCategoryChildren } from "./actions/fetchCategoryChildren";
5
+ export { default as fetchCategoryProducts } from "./actions/fetchCategoryProducts";
6
+ export { default as fetchRootCategories } from "./actions/fetchRootCategories";
7
+
8
+ // CONSTANTS
9
+ export * from "./constants/index";
10
+ export * from "./constants/Pipelines";
11
+ export * from "./constants/Portals";
12
+
13
+ // SELECTORS
14
+ export * from "./selectors";
15
+
16
+ // STREAMS
17
+ export * from "./streams";
18
+
19
+ // HELPERS
20
+ export * from "./helpers";
package/category/mock.js CHANGED
@@ -1 +1,176 @@
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);}var initialCategoryState={category:{rootCategories:{},categoriesById:{},childrenByCategoryId:{},currentCategoryId:null}};var categoryState={category:{rootCategories:{categories:['men','women'],expires:9999999999999,isFetching:false},categoriesById:{men:{id:'men',name:'Men',parent:{id:null,name:'Default- category'},path:'Men',description:'',imageUrl:'https://shopgate-public.s3.amazonaws.com/categories/24453/1346609@2x.jpg',externalUrl:'http://material-fashion.myshopify.com/collections/men',sort:0,productCount:6,childrenSort:'import',childrenCount:0,children:[],isFetching:false,expires:9999999999999},women:{id:'women',name:'Women',parent:{id:null,name:'Default- category'},path:'Women',description:'',imageUrl:'https://shopgate-public.s3.amazonaws.com/categories/24453/1346610@2x.jpg',externalUrl:'http://material-fashion.myshopify.com/collections/women',sort:0,productCount:6,childrenSort:'import',childrenCount:1,children:[],isFetching:false,expires:9999999999999},test:{id:'test',name:'test',parent:{id:'women',name:'Women'},path:'Default- category=>Women=>test',description:'',imageUrl:null,externalUrl:'',sort:10001,productCount:0,childrenSort:'import',childrenCount:0,children:[],isFetching:false,expires:9999999999999}},childrenByCategoryId:{women:{children:['test'],isFetching:false,expires:9999999999999}},currentCategoryId:null}};var homeRoute={id:'a4bf3a32-0ed8-4138-bb94-098f32f3aeb3',params:{},pathname:'/',pattern:'/',query:{},state:{}};var categoryRouteMock={id:'c8256921-3667-45d0-a0fe-a7a8bb5ed3b8',params:{},pathname:'/category',pattern:'/category',query:{},state:{title:'Categories'}};var childCategoryRouteMock={id:'5a227cfd-c55a-4e9b-9deb-d2ee20154030',params:{categoryId:'776f6d656e'},pathname:'/category/776f6d656e',pattern:'/category/:categoryId',query:{},state:{title:'Women'}};var routerState={router:{routing:false,stack:[_extends({},homeRoute)]}};var uiState={ui:{general:{}}};var emptyState=_extends({},initialCategoryState,{category:_extends({},initialCategoryState.category,{categoriesById:{test:{id:'test',name:'test',parent:{id:'women',name:'Women'},path:'Default- category=>Women=>test',description:'',imageUrl:null,externalUrl:'',sort:10001,productCount:0,childrenSort:'import',childrenCount:0,children:[],isFetching:false,expires:9999999999999}}}),product:{resultsByHash:{}},filter:{activeFilters:null},router:_extends({},routerState.router,{stack:[].concat(routerState.router.stack,[{id:'5a227cfd-c55a-4e9b-9deb-d2ee20154030',params:{categoryId:'74657374'},pathname:'/category/74657374',pattern:'/category/:categoryId',query:{},state:{title:'test'}}])})});export{initialCategoryState,emptyState,categoryState,routerState,categoryRouteMock,childCategoryRouteMock,uiState};
1
+ const initialCategoryState = {
2
+ category: {
3
+ rootCategories: {},
4
+ categoriesById: {},
5
+ childrenByCategoryId: {},
6
+ currentCategoryId: null
7
+ }
8
+ };
9
+ const categoryState = {
10
+ category: {
11
+ rootCategories: {
12
+ categories: ['men', 'women'],
13
+ expires: 9999999999999,
14
+ isFetching: false
15
+ },
16
+ categoriesById: {
17
+ men: {
18
+ id: 'men',
19
+ name: 'Men',
20
+ parent: {
21
+ id: null,
22
+ name: 'Default- category'
23
+ },
24
+ path: 'Men',
25
+ description: '',
26
+ imageUrl: 'https://shopgate-public.s3.amazonaws.com/categories/24453/1346609@2x.jpg',
27
+ externalUrl: 'http://material-fashion.myshopify.com/collections/men',
28
+ sort: 0,
29
+ productCount: 6,
30
+ childrenSort: 'import',
31
+ childrenCount: 0,
32
+ children: [],
33
+ isFetching: false,
34
+ expires: 9999999999999
35
+ },
36
+ women: {
37
+ id: 'women',
38
+ name: 'Women',
39
+ parent: {
40
+ id: null,
41
+ name: 'Default- category'
42
+ },
43
+ path: 'Women',
44
+ description: '',
45
+ imageUrl: 'https://shopgate-public.s3.amazonaws.com/categories/24453/1346610@2x.jpg',
46
+ externalUrl: 'http://material-fashion.myshopify.com/collections/women',
47
+ sort: 0,
48
+ productCount: 6,
49
+ childrenSort: 'import',
50
+ childrenCount: 1,
51
+ children: [],
52
+ isFetching: false,
53
+ expires: 9999999999999
54
+ },
55
+ test: {
56
+ id: 'test',
57
+ name: 'test',
58
+ parent: {
59
+ id: 'women',
60
+ name: 'Women'
61
+ },
62
+ path: 'Default- category=>Women=>test',
63
+ description: '',
64
+ imageUrl: null,
65
+ externalUrl: '',
66
+ sort: 10001,
67
+ productCount: 0,
68
+ childrenSort: 'import',
69
+ childrenCount: 0,
70
+ children: [],
71
+ isFetching: false,
72
+ expires: 9999999999999
73
+ }
74
+ },
75
+ childrenByCategoryId: {
76
+ women: {
77
+ children: ['test'],
78
+ isFetching: false,
79
+ expires: 9999999999999
80
+ }
81
+ },
82
+ currentCategoryId: null
83
+ }
84
+ };
85
+ const homeRoute = {
86
+ id: 'a4bf3a32-0ed8-4138-bb94-098f32f3aeb3',
87
+ params: {},
88
+ pathname: '/',
89
+ pattern: '/',
90
+ query: {},
91
+ state: {}
92
+ };
93
+ const categoryRouteMock = {
94
+ id: 'c8256921-3667-45d0-a0fe-a7a8bb5ed3b8',
95
+ params: {},
96
+ pathname: '/category',
97
+ pattern: '/category',
98
+ query: {},
99
+ state: {
100
+ title: 'Categories'
101
+ }
102
+ };
103
+ const childCategoryRouteMock = {
104
+ id: '5a227cfd-c55a-4e9b-9deb-d2ee20154030',
105
+ params: {
106
+ categoryId: '776f6d656e'
107
+ },
108
+ pathname: '/category/776f6d656e',
109
+ pattern: '/category/:categoryId',
110
+ query: {},
111
+ state: {
112
+ title: 'Women'
113
+ }
114
+ };
115
+ const routerState = {
116
+ router: {
117
+ routing: false,
118
+ stack: [{
119
+ ...homeRoute
120
+ }]
121
+ }
122
+ };
123
+ const uiState = {
124
+ ui: {
125
+ general: {}
126
+ }
127
+ };
128
+ const emptyState = {
129
+ ...initialCategoryState,
130
+ category: {
131
+ ...initialCategoryState.category,
132
+ categoriesById: {
133
+ test: {
134
+ id: 'test',
135
+ name: 'test',
136
+ parent: {
137
+ id: 'women',
138
+ name: 'Women'
139
+ },
140
+ path: 'Default- category=>Women=>test',
141
+ description: '',
142
+ imageUrl: null,
143
+ externalUrl: '',
144
+ sort: 10001,
145
+ productCount: 0,
146
+ childrenSort: 'import',
147
+ childrenCount: 0,
148
+ children: [],
149
+ isFetching: false,
150
+ expires: 9999999999999
151
+ }
152
+ }
153
+ },
154
+ product: {
155
+ resultsByHash: {}
156
+ },
157
+ filter: {
158
+ activeFilters: null
159
+ },
160
+ router: {
161
+ ...routerState.router,
162
+ stack: [...routerState.router.stack, {
163
+ id: '5a227cfd-c55a-4e9b-9deb-d2ee20154030',
164
+ params: {
165
+ categoryId: '74657374'
166
+ },
167
+ pathname: '/category/74657374',
168
+ pattern: '/category/:categoryId',
169
+ query: {},
170
+ state: {
171
+ title: 'test'
172
+ }
173
+ }]
174
+ }
175
+ };
176
+ export { initialCategoryState, emptyState, categoryState, routerState, categoryRouteMock, childCategoryRouteMock, uiState };
@@ -1,7 +1,69 @@
1
- var _excluded=["children"];function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return _typeof(key)==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(_typeof(input)!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(_typeof(res)!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}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;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}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{ENOTFOUND}from'@shopgate/pwa-core/constants/Pipeline';import{CATEGORY_LIFETIME,RECEIVE_ROOT_CATEGORIES,REQUEST_CATEGORY,RECEIVE_CATEGORY,RECEIVE_CATEGORY_CHILDREN,ERROR_CATEGORY}from"../constants";import handleCategoryCollection from"./helpers/handleCategoryCollection";/**
1
+ import { ENOTFOUND } from '@shopgate/pwa-core/constants/Pipeline';
2
+ import { CATEGORY_LIFETIME, RECEIVE_ROOT_CATEGORIES, REQUEST_CATEGORY, RECEIVE_CATEGORY, RECEIVE_CATEGORY_CHILDREN, ERROR_CATEGORY } from "../constants";
3
+ import handleCategoryCollection from "./helpers/handleCategoryCollection";
4
+
5
+ /**
2
6
  * Stores categories by their ID.
3
7
  * @param {Object} [state={}] The current state.
4
8
  * @param {Object} action The action object.
5
9
  * @return {Object} The new state.
6
- */var categoriesById=function categoriesById(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case REQUEST_CATEGORY:return _extends({},state,_defineProperty({},action.categoryId,_extends({},state[action.categoryId],{expires:0,isFetching:true})));case RECEIVE_CATEGORY:{var _action$categoryData2=action.categoryData,ignore=_action$categoryData2.children,categoryData=_objectWithoutProperties(_action$categoryData2,_excluded);return _extends({},state,_defineProperty({},action.categoryId,_extends({},state[action.categoryId],{},categoryData,{expires:Date.now()+CATEGORY_LIFETIME,isFetching:false})),handleCategoryCollection(action.categoryChildren));}case RECEIVE_ROOT_CATEGORIES:return _extends({},state,{},handleCategoryCollection(action.categories));case RECEIVE_CATEGORY_CHILDREN:return _extends({},state,{},handleCategoryCollection(action.categoryChildren));case ERROR_CATEGORY:if(action.errorCode===ENOTFOUND){// Remove the temporary entry from the state when noting was found for the categoryId.
7
- var _action$categoryId2=action.categoryId,_ignore=state[_action$categoryId2],rest=_objectWithoutProperties(state,[_action$categoryId2].map(_toPropertyKey));return rest;}return _extends({},state,_defineProperty({},action.categoryId,_extends({},state[action.categoryId],{isFetching:false})));default:return state;}};export default categoriesById;
10
+ */
11
+ const categoriesById = (state = {}, action) => {
12
+ switch (action.type) {
13
+ case REQUEST_CATEGORY:
14
+ return {
15
+ ...state,
16
+ [action.categoryId]: {
17
+ ...state[action.categoryId],
18
+ expires: 0,
19
+ isFetching: true
20
+ }
21
+ };
22
+ case RECEIVE_CATEGORY:
23
+ {
24
+ const {
25
+ children: ignore,
26
+ ...categoryData
27
+ } = action.categoryData;
28
+ return {
29
+ ...state,
30
+ [action.categoryId]: {
31
+ ...state[action.categoryId],
32
+ ...categoryData,
33
+ expires: Date.now() + CATEGORY_LIFETIME,
34
+ isFetching: false
35
+ },
36
+ ...handleCategoryCollection(action.categoryChildren)
37
+ };
38
+ }
39
+ case RECEIVE_ROOT_CATEGORIES:
40
+ return {
41
+ ...state,
42
+ ...handleCategoryCollection(action.categories)
43
+ };
44
+ case RECEIVE_CATEGORY_CHILDREN:
45
+ return {
46
+ ...state,
47
+ ...handleCategoryCollection(action.categoryChildren)
48
+ };
49
+ case ERROR_CATEGORY:
50
+ if (action.errorCode === ENOTFOUND) {
51
+ // Remove the temporary entry from the state when noting was found for the categoryId.
52
+ const {
53
+ [action.categoryId]: ignore,
54
+ ...rest
55
+ } = state;
56
+ return rest;
57
+ }
58
+ return {
59
+ ...state,
60
+ [action.categoryId]: {
61
+ ...state[action.categoryId],
62
+ isFetching: false
63
+ }
64
+ };
65
+ default:
66
+ return state;
67
+ }
68
+ };
69
+ export default categoriesById;
@@ -1,8 +1,59 @@
1
- function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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;}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return _typeof(key)==="symbol"?key:String(key);}function _toPrimitive(input,hint){if(_typeof(input)!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(_typeof(res)!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}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{ENOTFOUND}from'@shopgate/pwa-core/constants/Pipeline';import{CATEGORY_LIFETIME,REQUEST_CATEGORY,RECEIVE_CATEGORY,REQUEST_CATEGORY_CHILDREN,RECEIVE_CATEGORY_CHILDREN,ERROR_CATEGORY,ERROR_CATEGORY_CHILDREN}from"../constants";/**
1
+ import { ENOTFOUND } from '@shopgate/pwa-core/constants/Pipeline';
2
+ import { CATEGORY_LIFETIME, REQUEST_CATEGORY, RECEIVE_CATEGORY, REQUEST_CATEGORY_CHILDREN, RECEIVE_CATEGORY_CHILDREN, ERROR_CATEGORY, ERROR_CATEGORY_CHILDREN } from "../constants";
3
+
4
+ /**
2
5
  * Stores a collection of child category IDs by their parent's category ID.
3
6
  * @param {Object} [state={}] The current state.
4
7
  * @param {Object} action The action object.
5
8
  * @returns {Object} The new state.
6
- */var childrenByCategoryId=function childrenByCategoryId(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case REQUEST_CATEGORY:case REQUEST_CATEGORY_CHILDREN:return _extends({},state,_defineProperty({},action.categoryId,_extends({},state[action.categoryId],{children:null,isFetching:true,expires:0})));case RECEIVE_CATEGORY:case RECEIVE_CATEGORY_CHILDREN:{var actionChildren=action.categoryChildren;return _extends({},state,_defineProperty({},action.categoryId,_extends({},state[action.categoryId],{// If it has children, append them.
7
- children:actionChildren?action.categoryChildren.map(function(child){return child.id;}):null,isFetching:false,expires:Date.now()+CATEGORY_LIFETIME})));}case ERROR_CATEGORY:case ERROR_CATEGORY_CHILDREN:if(action.errorCode===ENOTFOUND){// Remove the temporary entry from the state when noting was found for the categoryId.
8
- var _action$categoryId2=action.categoryId,ignore=state[_action$categoryId2],rest=_objectWithoutProperties(state,[_action$categoryId2].map(_toPropertyKey));return rest;}return _extends({},state,_defineProperty({},action.categoryId,_extends({},state[action.categoryId],{isFetching:false})));default:return state;}};export default childrenByCategoryId;
9
+ */
10
+ const childrenByCategoryId = (state = {}, action) => {
11
+ switch (action.type) {
12
+ case REQUEST_CATEGORY:
13
+ case REQUEST_CATEGORY_CHILDREN:
14
+ return {
15
+ ...state,
16
+ [action.categoryId]: {
17
+ ...state[action.categoryId],
18
+ children: null,
19
+ isFetching: true,
20
+ expires: 0
21
+ }
22
+ };
23
+ case RECEIVE_CATEGORY:
24
+ case RECEIVE_CATEGORY_CHILDREN:
25
+ {
26
+ const actionChildren = action.categoryChildren;
27
+ return {
28
+ ...state,
29
+ [action.categoryId]: {
30
+ ...state[action.categoryId],
31
+ // If it has children, append them.
32
+ children: actionChildren ? action.categoryChildren.map(child => child.id) : null,
33
+ isFetching: false,
34
+ expires: Date.now() + CATEGORY_LIFETIME
35
+ }
36
+ };
37
+ }
38
+ case ERROR_CATEGORY:
39
+ case ERROR_CATEGORY_CHILDREN:
40
+ if (action.errorCode === ENOTFOUND) {
41
+ // Remove the temporary entry from the state when noting was found for the categoryId.
42
+ const {
43
+ [action.categoryId]: ignore,
44
+ ...rest
45
+ } = state;
46
+ return rest;
47
+ }
48
+ return {
49
+ ...state,
50
+ [action.categoryId]: {
51
+ ...state[action.categoryId],
52
+ isFetching: false
53
+ }
54
+ };
55
+ default:
56
+ return state;
57
+ }
58
+ };
59
+ export default childrenByCategoryId;
@@ -1,6 +1,27 @@
1
- function _objectDestructuringEmpty(obj){if(obj==null)throw new TypeError("Cannot destructure undefined");}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{CATEGORY_LIFETIME}from"../../constants";/**
1
+ import { CATEGORY_LIFETIME } from "../../constants";
2
+
3
+ /**
2
4
  * Builds state entries from a collection of categories.
3
5
  * @param {Array} collection A category collection.
4
6
  * @return {Object} The category entries for the state.
5
- */var handleCategoryCollection=function handleCategoryCollection(collection){var categoryObjects={};// Is used to set them all to the same date because they arrived at the same time.
6
- var expires=Date.now()+CATEGORY_LIFETIME;if(!collection){return categoryObjects;}collection.forEach(function(category){var categoryData=_extends({},(_objectDestructuringEmpty(category),category));categoryObjects[category.id]=_extends({},categoryData,{isFetching:false,expires:expires});});return categoryObjects;};export default handleCategoryCollection;
7
+ */
8
+ const handleCategoryCollection = collection => {
9
+ const categoryObjects = {};
10
+ // Is used to set them all to the same date because they arrived at the same time.
11
+ const expires = Date.now() + CATEGORY_LIFETIME;
12
+ if (!collection) {
13
+ return categoryObjects;
14
+ }
15
+ collection.forEach(category => {
16
+ const {
17
+ ...categoryData
18
+ } = category;
19
+ categoryObjects[category.id] = {
20
+ ...categoryData,
21
+ isFetching: false,
22
+ expires
23
+ };
24
+ });
25
+ return categoryObjects;
26
+ };
27
+ export default handleCategoryCollection;
@@ -2,4 +2,6 @@
2
2
  * Handles the received category id's by mapping to store and returning results.
3
3
  * @param {Array} categories The received categories.
4
4
  * @returns {Array} An array of category objects.
5
- */var handleReceivedCategories=function handleReceivedCategories(categories){return categories.length?categories.map(function(category){return category.id;}):null;};export default handleReceivedCategories;
5
+ */
6
+ const handleReceivedCategories = categories => categories.length ? categories.map(category => category.id) : null;
7
+ export default handleReceivedCategories;