@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,3 +1,13 @@
1
- import{combineReducers}from'redux';import rootCategories from"./rootCategories";import categoriesById from"./categoriesById";import childrenByCategoryId from"./childrenByCategoryId";/**
1
+ import { combineReducers } from 'redux';
2
+ import rootCategories from "./rootCategories";
3
+ import categoriesById from "./categoriesById";
4
+ import childrenByCategoryId from "./childrenByCategoryId";
5
+
6
+ /**
2
7
  * The category reducer.
3
- */export default combineReducers({categoriesById:categoriesById,childrenByCategoryId:childrenByCategoryId,rootCategories:rootCategories});
8
+ */
9
+ export default combineReducers({
10
+ categoriesById,
11
+ childrenByCategoryId,
12
+ rootCategories
13
+ });
@@ -1,7 +1,36 @@
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{CATEGORY_LIFETIME,REQUEST_ROOT_CATEGORIES,RECEIVE_ROOT_CATEGORIES,ERROR_ROOT_CATEGORIES}from"../constants";import handleReceivedCategories from"./helpers/handleReceivedCategories";/**
1
+ import { CATEGORY_LIFETIME, REQUEST_ROOT_CATEGORIES, RECEIVE_ROOT_CATEGORIES, ERROR_ROOT_CATEGORIES } from "../constants";
2
+ import handleReceivedCategories from "./helpers/handleReceivedCategories";
3
+
4
+ /**
2
5
  * Stores a collection of category IDs that represent the
3
6
  * highest level of categories with no parent.
4
7
  * @param {Object} [state={}] The current application state.
5
8
  * @param {Object} action The action object.
6
9
  * @return {Object} The store data.
7
- */var rootCategories=function rootCategories(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case REQUEST_ROOT_CATEGORIES:return _extends({},state,{categories:null,expires:0,isFetching:true});case RECEIVE_ROOT_CATEGORIES:return _extends({},state,{categories:handleReceivedCategories(action.categories),expires:Date.now()+CATEGORY_LIFETIME,isFetching:false});case ERROR_ROOT_CATEGORIES:return _extends({},state,{isFetching:false});default:return state;}};export default rootCategories;
10
+ */
11
+ const rootCategories = (state = {}, action) => {
12
+ switch (action.type) {
13
+ case REQUEST_ROOT_CATEGORIES:
14
+ return {
15
+ ...state,
16
+ categories: null,
17
+ expires: 0,
18
+ isFetching: true
19
+ };
20
+ case RECEIVE_ROOT_CATEGORIES:
21
+ return {
22
+ ...state,
23
+ categories: handleReceivedCategories(action.categories),
24
+ expires: Date.now() + CATEGORY_LIFETIME,
25
+ isFetching: false
26
+ };
27
+ case ERROR_ROOT_CATEGORIES:
28
+ return {
29
+ ...state,
30
+ isFetching: false
31
+ };
32
+ default:
33
+ return state;
34
+ }
35
+ };
36
+ export default rootCategories;
@@ -1,80 +1,160 @@
1
- import{createSelector}from'reselect';import{getCurrentRoute,getCurrentParams}from'@shopgate/pwa-common/selectors/router';import{hex2bin}from'@shopgate/pwa-common/helpers/data';/**
1
+ import { createSelector } from 'reselect';
2
+ import { getCurrentRoute, getCurrentParams } from '@shopgate/pwa-common/selectors/router';
3
+ import { hex2bin } from '@shopgate/pwa-common/helpers/data';
4
+
5
+ /**
2
6
  * Retrieves the category state from the state.
3
7
  * @param {Object} state The application state.
4
8
  * @param {Object} props The component props.
5
9
  * @returns {Object} The category state.
6
- */var getCategoryState=function getCategoryState(state){return state.category;};/**
10
+ */
11
+ const getCategoryState = state => state.category;
12
+
13
+ /**
7
14
  * Retrieves the categoriesById state from the category state.
8
15
  * @param {Object} state The application state.
9
16
  * @param {Object} props The component props.
10
17
  * @returns {Object} The categoriesById state.
11
- */var getCategoriesByIdState=createSelector(getCategoryState,function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return state.categoriesById||{};});/**
18
+ */
19
+ const getCategoriesByIdState = createSelector(getCategoryState, (state = {}) => state.categoriesById || {});
20
+
21
+ /**
12
22
  * Retrieves the childrenByCategoryId state from the category state.
13
23
  * @param {Object} state The application state.
14
24
  * @param {Object} props The component props.
15
25
  * @returns {Object} The childrenByCategoryId state.
16
- */var getChildrenByCategoryIdState=createSelector(getCategoryState,function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return state.childrenByCategoryId||{};});/**
26
+ */
27
+ const getChildrenByCategoryIdState = createSelector(getCategoryState, (state = {}) => state.childrenByCategoryId || {});
28
+
29
+ /**
17
30
  * Retrieves the rootCategories state from the category state.
18
31
  * @param {Object} state The application state.
19
32
  * @returns {Object}
20
- */export var getRootCategoriesState=createSelector(getCategoryState,function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return state.rootCategories||{};});/**
33
+ */
34
+ export const getRootCategoriesState = createSelector(getCategoryState, (state = {}) => state.rootCategories || {});
35
+
36
+ /**
21
37
  * Retrieves a category id either from the selector props, or the params of the active route.
22
38
  * @param {Object} state The application state.
23
39
  * @param {Object} props The component props.
24
40
  * @returns {string|null} The category ID.
25
- */export var getCategoryId=createSelector(function(state){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return props.categoryId;},getCurrentParams,function(categoryId,routeParams){if(typeof categoryId!=='undefined'){return categoryId;}if(!routeParams||!routeParams.categoryId){return null;}return hex2bin(routeParams.categoryId);});/**
41
+ */
42
+ export const getCategoryId = createSelector((state, props = {}) => props.categoryId, getCurrentParams, (categoryId, routeParams) => {
43
+ if (typeof categoryId !== 'undefined') {
44
+ return categoryId;
45
+ }
46
+ if (!routeParams || !routeParams.categoryId) {
47
+ return null;
48
+ }
49
+ return hex2bin(routeParams.categoryId);
50
+ });
51
+
52
+ /**
26
53
  * Retrieves the child categories for a specific parent category from the state.
27
54
  * @param {Object} state The application state.
28
55
  * @param {Object} props The component props.
29
56
  * @returns {Object}
30
- */export var getChildCategoriesForCategory=createSelector(getCategoryId,getChildrenByCategoryIdState,function(categoryId,childCategories){return childCategories[categoryId];});/**
57
+ */
58
+ export const getChildCategoriesForCategory = createSelector(getCategoryId, getChildrenByCategoryIdState, (categoryId, childCategories) => childCategories[categoryId]);
59
+
60
+ /**
31
61
  * Retrieves a category from state.
32
62
  * The category can either be referenced by a categoryId within the props,
33
63
  * or by a categoryId within the params of the active route state.
34
64
  * @param {Object} state The current application state.
35
65
  * @param {Object} props The component props.
36
66
  * @return {Object|null}
37
- */export var getCategory=createSelector(getCategoryId,getCategoriesByIdState,function(categoryId,categoriesById){if(!categoriesById||!categoriesById[categoryId]){return null;}return categoriesById[categoryId];});/**
67
+ */
68
+ export const getCategory = createSelector(getCategoryId, getCategoriesByIdState, (categoryId, categoriesById) => {
69
+ if (!categoriesById || !categoriesById[categoryId]) {
70
+ return null;
71
+ }
72
+ return categoriesById[categoryId];
73
+ });
74
+
75
+ /**
38
76
  * Retrieves the root categories.
39
77
  * @param {Object} state The application state.
40
78
  * @param {Object} props The component props.
41
79
  * @returns {Array}
42
- */export var getRootCategories=createSelector(getRootCategoriesState,getCategoriesByIdState,function(rootCategories,categoriesById){if(Object.keys(rootCategories).length===0){return null;}if(!rootCategories.categories){return null;}return rootCategories.categories.map(function(id){return categoriesById[id];}).filter(Boolean);});/**
80
+ */
81
+ export const getRootCategories = createSelector(getRootCategoriesState, getCategoriesByIdState, (rootCategories, categoriesById) => {
82
+ if (Object.keys(rootCategories).length === 0) {
83
+ return null;
84
+ }
85
+ if (!rootCategories.categories) {
86
+ return null;
87
+ }
88
+ return rootCategories.categories.map(id => categoriesById[id]).filter(Boolean);
89
+ });
90
+
91
+ /**
43
92
  * Retrieves the number of child categories for a category.
44
93
  * The category can either be referenced by a categoryId within the props,
45
94
  * or by a categoryId within the params of the active route state.
46
95
  * @param {Object} state The current application state.
47
96
  * @param {Object} props The component props.
48
97
  * @returns {number|null}
49
- */export var getCategoryChildCount=createSelector(getCategory,function(category){return category?category.childrenCount:null;});/**
98
+ */
99
+ export const getCategoryChildCount = createSelector(getCategory, category => category ? category.childrenCount : null);
100
+
101
+ /**
50
102
  * Determines if a category has child categories.
51
103
  * The category can either be referenced by a categoryId within the props,
52
104
  * or by a categoryId within the params of the active route state.
53
105
  * @param {Object} state The application state.
54
106
  * @param {Object} props The component props.
55
107
  * @returns {boolean}
56
- */export var hasCategoryChildren=createSelector(getCategoryChildCount,function(count){return count>0;});/**
108
+ */
109
+ export const hasCategoryChildren = createSelector(getCategoryChildCount, count => count > 0);
110
+
111
+ /**
57
112
  * Retrieves the child categories of a category.
58
113
  * The category can either be referenced by a categoryId within the props,
59
114
  * or by a categoryId within the params of the active route state.
60
115
  * @param {Object} state The application state.
61
116
  * @param {Object} props The component props.
62
117
  * @returns {Array|null}
63
- */export var getCategoryChildren=createSelector([getChildCategoriesForCategory,getCategoriesByIdState],function(childCategories,categoriesById){if(!childCategories||!childCategories.children){return null;}return childCategories.children.map(function(id){return categoriesById[id];}).filter(Boolean);});export var areCategoryChildrenFetching=createSelector([getChildCategoriesForCategory],function(childCategories){if(!childCategories||!childCategories.isFetching){return false;}return childCategories.isFetching;});/**
118
+ */
119
+ export const getCategoryChildren = createSelector([getChildCategoriesForCategory, getCategoriesByIdState], (childCategories, categoriesById) => {
120
+ if (!childCategories || !childCategories.children) {
121
+ return null;
122
+ }
123
+ return childCategories.children.map(id => categoriesById[id]).filter(Boolean);
124
+ });
125
+ export const areCategoryChildrenFetching = createSelector([getChildCategoriesForCategory], childCategories => {
126
+ if (!childCategories || !childCategories.isFetching) {
127
+ return false;
128
+ }
129
+ return childCategories.isFetching;
130
+ });
131
+
132
+ /**
64
133
  * Retrieves the number of products inside a category.
65
134
  * The category can either be referenced by a categoryId within the props,
66
135
  * or by a categoryId within the params of the active route state.
67
136
  * @param {Object} state The application state.
68
137
  * @param {Object} props The component props.
69
138
  * @returns {number|null}
70
- */export var getCategoryProductCount=createSelector(getCategoriesByIdState,getCategoryId,function(categoriesById,categoryId){if(!categoriesById[categoryId]||!categoriesById[categoryId].productCount&&categoriesById[categoryId].productCount!==0){return null;}return categoriesById[categoryId].productCount;});/**
139
+ */
140
+ export const getCategoryProductCount = createSelector(getCategoriesByIdState, getCategoryId, (categoriesById, categoryId) => {
141
+ if (!categoriesById[categoryId] || !categoriesById[categoryId].productCount && categoriesById[categoryId].productCount !== 0) {
142
+ return null;
143
+ }
144
+ return categoriesById[categoryId].productCount;
145
+ });
146
+
147
+ /**
71
148
  * Determines if a category has products.
72
149
  * The category can either be referenced by a categoryId within the props,
73
150
  * or by a categoryId within the params of the active route state.
74
151
  * @param {Object} state The application state.
75
152
  * @param {Object} props The component props.
76
153
  * @returns {boolean}
77
- */export var hasCategoryProducts=createSelector(getCategoryProductCount,function(count){return count>0;});/**
154
+ */
155
+ export const hasCategoryProducts = createSelector(getCategoryProductCount, count => count > 0);
156
+
157
+ /**
78
158
  * Retrieves the name of a category. When no category can be determined it return the title of
79
159
  * the active route.
80
160
  * The category can either be referenced by a categoryId within the props,
@@ -82,7 +162,26 @@ import{createSelector}from'reselect';import{getCurrentRoute,getCurrentParams}fro
82
162
  * @param {Object} state The application state.
83
163
  * @param {Object} props The component props.
84
164
  * @returns {number|null}
85
- */export var getCategoryName=createSelector(getCurrentRoute,getCategory,function(route,category){if(category){return category.name;}if(route.state.title){return route.state.title;}return null;});/**
165
+ */
166
+ export const getCategoryName = createSelector(getCurrentRoute, getCategory, (route, category) => {
167
+ if (category) {
168
+ return category.name;
169
+ }
170
+ if (route.state.title) {
171
+ return route.state.title;
172
+ }
173
+ return null;
174
+ });
175
+
176
+ /**
86
177
  * Selector mappings for PWA < 6.10
87
178
  * @deprecated
88
- */export var getCategoryById=getCategory;export var getCurrentCategoryId=getCategory;export var getCurrentCategory=getCategory;export var getCurrentCategoryChildCount=getCategoryChildCount;export var getCurrentCategories=getCategoryChildren;export var getChildCategoriesById=getCategoryChildren;export var hasChildren=hasCategoryChildren;export var hasProducts=hasCategoryProducts;
179
+ */
180
+ export const getCategoryById = getCategory;
181
+ export const getCurrentCategoryId = getCategory;
182
+ export const getCurrentCategory = getCategory;
183
+ export const getCurrentCategoryChildCount = getCategoryChildCount;
184
+ export const getCurrentCategories = getCategoryChildren;
185
+ export const getChildCategoriesById = getCategoryChildren;
186
+ export const hasChildren = hasCategoryChildren;
187
+ export const hasProducts = hasCategoryProducts;
@@ -1,10 +1,88 @@
1
- import{main$,routeWillEnter$,routeDidEnter$,routeDidLeave$,routeWillLeave$}from'@shopgate/pwa-common/streams';import{routeDidUpdate$}from'@shopgate/pwa-common/streams/router';import{HISTORY_POP_ACTION}from'@shopgate/pwa-common/constants/ActionTypes';import{filtersDidUpdate$}from'@shopgate/pwa-common-commerce/filter/streams';import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import{hex2bin}from'@shopgate/pwa-common/helpers/data';import{filterWillLeave$}from"../../filter/streams";import{CATEGORY_PATTERN,CATEGORY_ALL_PATTERN,RECEIVE_ROOT_CATEGORIES,ERROR_CATEGORY,RECEIVE_CATEGORY,CATEGORY_PATH}from"../constants";export var categoryWillEnter$=routeWillEnter$.filter(function(_ref){var action=_ref.action;return action.route.pattern===CATEGORY_PATTERN;});export var categoryDidEnter$=routeDidEnter$.filter(function(_ref2){var action=_ref2.action;return action.route.pattern===CATEGORY_PATTERN;});export var categoryDidLeave$=routeDidLeave$.filter(function(_ref3){var action=_ref3.action;return action.route.pattern===CATEGORY_PATTERN;});export var categoryAllWillEnter$=routeWillEnter$.filter(function(_ref4){var action=_ref4.action;return action.route.pattern===CATEGORY_ALL_PATTERN;});export var categoryAllDidEnter$=routeDidEnter$.filter(function(_ref5){var action=_ref5.action;return action.route.pattern===CATEGORY_ALL_PATTERN;});export var categoryAllDidLeave$=routeDidLeave$.filter(function(_ref6){var action=_ref6.action;return action.route.pattern===CATEGORY_ALL_PATTERN;});/**
1
+ import { main$, routeWillEnter$, routeDidEnter$, routeDidLeave$, routeWillLeave$ } from '@shopgate/pwa-common/streams';
2
+ import { routeDidUpdate$ } from '@shopgate/pwa-common/streams/router';
3
+ import { HISTORY_POP_ACTION } from '@shopgate/pwa-common/constants/ActionTypes';
4
+ import { filtersDidUpdate$ } from '@shopgate/pwa-common-commerce/filter/streams';
5
+ import { getCurrentRoute } from '@shopgate/pwa-common/selectors/router';
6
+ import { hex2bin } from '@shopgate/pwa-common/helpers/data';
7
+ import { filterWillLeave$ } from "../../filter/streams";
8
+ import { CATEGORY_PATTERN, CATEGORY_ALL_PATTERN, RECEIVE_ROOT_CATEGORIES, ERROR_CATEGORY, RECEIVE_CATEGORY, CATEGORY_PATH } from "../constants";
9
+ export const categoryWillEnter$ = routeWillEnter$.filter(({
10
+ action
11
+ }) => action.route.pattern === CATEGORY_PATTERN);
12
+ export const categoryDidEnter$ = routeDidEnter$.filter(({
13
+ action
14
+ }) => action.route.pattern === CATEGORY_PATTERN);
15
+ export const categoryDidLeave$ = routeDidLeave$.filter(({
16
+ action
17
+ }) => action.route.pattern === CATEGORY_PATTERN);
18
+ export const categoryAllWillEnter$ = routeWillEnter$.filter(({
19
+ action
20
+ }) => action.route.pattern === CATEGORY_ALL_PATTERN);
21
+ export const categoryAllDidEnter$ = routeDidEnter$.filter(({
22
+ action
23
+ }) => action.route.pattern === CATEGORY_ALL_PATTERN);
24
+ export const categoryAllDidLeave$ = routeDidLeave$.filter(({
25
+ action
26
+ }) => action.route.pattern === CATEGORY_ALL_PATTERN);
27
+
28
+ /**
2
29
  * Gets triggered when the root categories received.
3
- */export var receivedRootCategories$=main$.filter(function(_ref7){var action=_ref7.action;return action.type===RECEIVE_ROOT_CATEGORIES;});/**
30
+ */
31
+ export const receivedRootCategories$ = main$.filter(({
32
+ action
33
+ }) => action.type === RECEIVE_ROOT_CATEGORIES);
34
+
35
+ /**
4
36
  * Gets trigger when category error is dispatched.
5
- */export var categoryError$=main$.filter(function(_ref8){var action=_ref8.action;return action.type===ERROR_CATEGORY;});export var categoryDidBackEnter$=categoryDidEnter$.filter(function(_ref9){var action=_ref9.action;return action.historyAction===HISTORY_POP_ACTION;});export var categoryWillLeave$=routeWillLeave$.filter(function(_ref10){var action=_ref10.action;return action.route.pattern==="".concat(CATEGORY_PATH,"/:categoryId");});/**
37
+ */
38
+ export const categoryError$ = main$.filter(({
39
+ action
40
+ }) => action.type === ERROR_CATEGORY);
41
+ export const categoryDidBackEnter$ = categoryDidEnter$.filter(({
42
+ action
43
+ }) => action.historyAction === HISTORY_POP_ACTION);
44
+ export const categoryWillLeave$ = routeWillLeave$.filter(({
45
+ action
46
+ }) => action.route.pattern === `${CATEGORY_PATH}/:categoryId`);
47
+
48
+ /**
6
49
  * Filters stream state by type.
7
50
  * @param {Object} data The stream data.
8
51
  * @param {string} type The action type to filter.
9
52
  * @returns {boolean}
10
- */var filterDataByType=function filterDataByType(data,type){var action=data.action,getState=data.getState;if(action.type!==type){return false;}if(typeof action.categoryId==='undefined'){return false;}var route=getCurrentRoute(getState());if(!route.params.categoryId){return false;}return action.categoryId===hex2bin(route.params.categoryId);};export var receivedVisibleCategory$=main$.filter(function(data){return filterDataByType(data,RECEIVE_CATEGORY);});export var errorVisibleCategory$=main$.filter(function(data){return filterDataByType(data,ERROR_CATEGORY);});export var categoryFiltersDidUpdate$=filtersDidUpdate$.filter(function(_ref11){var getState=_ref11.getState;var _getCurrentRoute=getCurrentRoute(getState()),pattern=_getCurrentRoute.pattern;return pattern===CATEGORY_PATTERN;});export var categoryDidUpdate$=routeDidUpdate$.filter(function(_ref12){var _action$route;var action=_ref12.action;return(action===null||action===void 0?void 0:(_action$route=action.route)===null||_action$route===void 0?void 0:_action$route.pattern)===CATEGORY_PATTERN;});export var categoryAllDidUpdate$=routeDidUpdate$.filter(function(_ref13){var _action$route2;var action=_ref13.action;return(action===null||action===void 0?void 0:(_action$route2=action.route)===null||_action$route2===void 0?void 0:_action$route2.pattern)===CATEGORY_ALL_PATTERN;});export var categoryFiltersDidUpdateFromFilterPage$=categoryDidUpdate$.switchMap(function(){return filterWillLeave$.first();}).switchMap(function(){return categoryWillEnter$.first();});export var categoryAllFiltersDidUpdateFromFilterPage$=categoryAllDidUpdate$.switchMap(function(){return filterWillLeave$.first();}).switchMap(function(){return categoryAllWillEnter$.first();});
53
+ */
54
+ const filterDataByType = (data, type) => {
55
+ const {
56
+ action,
57
+ getState
58
+ } = data;
59
+ if (action.type !== type) {
60
+ return false;
61
+ }
62
+ if (typeof action.categoryId === 'undefined') {
63
+ return false;
64
+ }
65
+ const route = getCurrentRoute(getState());
66
+ if (!route.params.categoryId) {
67
+ return false;
68
+ }
69
+ return action.categoryId === hex2bin(route.params.categoryId);
70
+ };
71
+ export const receivedVisibleCategory$ = main$.filter(data => filterDataByType(data, RECEIVE_CATEGORY));
72
+ export const errorVisibleCategory$ = main$.filter(data => filterDataByType(data, ERROR_CATEGORY));
73
+ export const categoryFiltersDidUpdate$ = filtersDidUpdate$.filter(({
74
+ getState
75
+ }) => {
76
+ const {
77
+ pattern
78
+ } = getCurrentRoute(getState());
79
+ return pattern === CATEGORY_PATTERN;
80
+ });
81
+ export const categoryDidUpdate$ = routeDidUpdate$.filter(({
82
+ action
83
+ }) => action?.route?.pattern === CATEGORY_PATTERN);
84
+ export const categoryAllDidUpdate$ = routeDidUpdate$.filter(({
85
+ action
86
+ }) => action?.route?.pattern === CATEGORY_ALL_PATTERN);
87
+ export const categoryFiltersDidUpdateFromFilterPage$ = categoryDidUpdate$.switchMap(() => filterWillLeave$.first()).switchMap(() => categoryWillEnter$.first());
88
+ export const categoryAllFiltersDidUpdateFromFilterPage$ = categoryAllDidUpdate$.switchMap(() => filterWillLeave$.first()).switchMap(() => categoryAllWillEnter$.first());
@@ -1,6 +1,99 @@
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{ACTION_PUSH,ACTION_REPLACE}from'@virtuous/conductor';import{buildFetchCategoryProductsParams,getProductsResult}from'@shopgate/engage/product';import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import{historyPop}from'@shopgate/pwa-common/actions/router';import expireProductsByHash from'@shopgate/pwa-common-commerce/product/action-creators/expireProductsByHash';import fetchCategory from'@shopgate/pwa-common-commerce/category/actions/fetchCategory';import fetchCategoryProducts from'@shopgate/pwa-common-commerce/category/actions/fetchCategoryProducts';import fetchFilters from'@shopgate/pwa-common-commerce/filter/actions/fetchFilters';import{hex2bin}from'@shopgate/pwa-common/helpers/data';import{categoryProductsNeedUpdate$}from'@shopgate/engage/category/streams';import{categoryWillEnter$,categoryDidEnter$,errorVisibleCategory$,categoryFiltersDidUpdateFromFilterPage$}from"../streams";/**
1
+ import { ACTION_PUSH, ACTION_REPLACE } from '@virtuous/conductor';
2
+ import { buildFetchCategoryProductsParams, getProductsResult } from '@shopgate/engage/product';
3
+ import { getCurrentRoute } from '@shopgate/pwa-common/selectors/router';
4
+ import { historyPop } from '@shopgate/pwa-common/actions/router';
5
+ import expireProductsByHash from '@shopgate/pwa-common-commerce/product/action-creators/expireProductsByHash';
6
+ import fetchCategory from '@shopgate/pwa-common-commerce/category/actions/fetchCategory';
7
+ import fetchCategoryProducts from '@shopgate/pwa-common-commerce/category/actions/fetchCategoryProducts';
8
+ import fetchFilters from '@shopgate/pwa-common-commerce/filter/actions/fetchFilters';
9
+ import { hex2bin } from '@shopgate/pwa-common/helpers/data';
10
+ import { categoryProductsNeedUpdate$ } from '@shopgate/engage/category/streams';
11
+ import { categoryWillEnter$, categoryDidEnter$, errorVisibleCategory$, categoryFiltersDidUpdateFromFilterPage$ } from "../streams";
12
+
13
+ /**
2
14
  * Category subscriptions.
3
15
  * @param {Function} subscribe The subscribe function.
4
- */export default function category(subscribe){subscribe(categoryWillEnter$,function(_ref){var _action$route;var dispatch=_ref.dispatch,action=_ref.action,getState=_ref.getState;if(![ACTION_PUSH,ACTION_REPLACE].includes(action===null||action===void 0?void 0:action.historyAction)){return;}var _action$route$state=action.route.state,filters=_action$route$state.filters,_action$route$state$o=_action$route$state.offset,offset=_action$route$state$o===void 0?0:_action$route$state$o;var categoryId=hex2bin(action.route.params.categoryId);var _getProductsResult=getProductsResult(getState(),_extends({categoryId:categoryId,routeId:action===null||action===void 0?void 0:(_action$route=action.route)===null||_action$route===void 0?void 0:_action$route.id},buildFetchCategoryProductsParams())),hash=_getProductsResult.hash,expired=_getProductsResult.expired;if(expired){dispatch(expireProductsByHash(hash));}dispatch(fetchCategory(categoryId));dispatch(fetchCategoryProducts(_extends({categoryId:categoryId,filters:filters,offset:offset},buildFetchCategoryProductsParams())));});subscribe(categoryDidEnter$,function(_ref2){var dispatch=_ref2.dispatch;dispatch(fetchFilters());});/**
16
+ */
17
+ export default function category(subscribe) {
18
+ subscribe(categoryWillEnter$, ({
19
+ dispatch,
20
+ action,
21
+ getState
22
+ }) => {
23
+ if (![ACTION_PUSH, ACTION_REPLACE].includes(action?.historyAction)) {
24
+ return;
25
+ }
26
+ const {
27
+ filters,
28
+ offset = 0
29
+ } = action.route.state;
30
+ const categoryId = hex2bin(action.route.params.categoryId);
31
+ const {
32
+ hash,
33
+ expired
34
+ } = getProductsResult(getState(), {
35
+ categoryId,
36
+ routeId: action?.route?.id,
37
+ ...buildFetchCategoryProductsParams()
38
+ });
39
+ if (expired) {
40
+ dispatch(expireProductsByHash(hash));
41
+ }
42
+ dispatch(fetchCategory(categoryId));
43
+ dispatch(fetchCategoryProducts({
44
+ categoryId,
45
+ filters,
46
+ offset,
47
+ ...buildFetchCategoryProductsParams()
48
+ }));
49
+ });
50
+ subscribe(categoryDidEnter$, ({
51
+ dispatch
52
+ }) => {
53
+ dispatch(fetchFilters());
54
+ });
55
+
56
+ /**
5
57
  * Gets triggered on pipeline category error.
6
- */subscribe(errorVisibleCategory$,function(_ref3){var dispatch=_ref3.dispatch;dispatch(historyPop());});subscribe(categoryProductsNeedUpdate$,function(_ref4){var dispatch=_ref4.dispatch,getState=_ref4.getState;var _getCurrentRoute=getCurrentRoute(getState()),params=_getCurrentRoute.params,_getCurrentRoute$stat=_getCurrentRoute.state,_getCurrentRoute$stat2=_getCurrentRoute$stat.offset,offset=_getCurrentRoute$stat2===void 0?0:_getCurrentRoute$stat2,filters=_getCurrentRoute$stat.filters;var categoryId=hex2bin(params.categoryId);dispatch(fetchCategoryProducts(_extends({categoryId:categoryId,filters:filters,offset:offset},buildFetchCategoryProductsParams())));});subscribe(categoryFiltersDidUpdateFromFilterPage$,function(_ref5){var dispatch=_ref5.dispatch,action=_ref5.action;var categoryId=hex2bin(action.route.params.categoryId);var _action$route$state2=action.route.state,filters=_action$route$state2.filters,_action$route$state2$=_action$route$state2.offset,offset=_action$route$state2$===void 0?0:_action$route$state2$;dispatch(fetchCategoryProducts(_extends({categoryId:categoryId,filters:filters,offset:offset},buildFetchCategoryProductsParams())));});}
58
+ */
59
+ subscribe(errorVisibleCategory$, ({
60
+ dispatch
61
+ }) => {
62
+ dispatch(historyPop());
63
+ });
64
+ subscribe(categoryProductsNeedUpdate$, ({
65
+ dispatch,
66
+ getState
67
+ }) => {
68
+ const {
69
+ params,
70
+ state: {
71
+ offset = 0,
72
+ filters
73
+ }
74
+ } = getCurrentRoute(getState());
75
+ const categoryId = hex2bin(params.categoryId);
76
+ dispatch(fetchCategoryProducts({
77
+ categoryId,
78
+ filters,
79
+ offset,
80
+ ...buildFetchCategoryProductsParams()
81
+ }));
82
+ });
83
+ subscribe(categoryFiltersDidUpdateFromFilterPage$, ({
84
+ dispatch,
85
+ action
86
+ }) => {
87
+ const categoryId = hex2bin(action.route.params.categoryId);
88
+ const {
89
+ filters,
90
+ offset = 0
91
+ } = action.route.state;
92
+ dispatch(fetchCategoryProducts({
93
+ categoryId,
94
+ filters,
95
+ offset,
96
+ ...buildFetchCategoryProductsParams()
97
+ }));
98
+ });
99
+ }
@@ -1,5 +1,12 @@
1
- import{SUCCESS_CHECKOUT}from"../constants";/**
1
+ import { SUCCESS_CHECKOUT } from "../constants";
2
+
3
+ /**
2
4
  * Creates the dispatched SUCCESS_UPDATE_PRODUCTS_IN_CART action object.
3
5
  * @param {Object[]} products cart.items of product type
4
6
  * @returns {Object} The dispatched action object.
5
- */var successCheckout=function successCheckout(products){return{type:SUCCESS_CHECKOUT,products:products};};export default successCheckout;
7
+ */
8
+ const successCheckout = products => ({
9
+ type: SUCCESS_CHECKOUT,
10
+ products
11
+ });
12
+ export default successCheckout;
@@ -1,5 +1,30 @@
1
- import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{requestUrl,receiveUrl,errorUrl}from'@shopgate/pwa-common/action-creators/url';import{mutable}from'@shopgate/pwa-common/helpers/redux';import{SHOPGATE_CHECKOUT_GET_URL}from"../constants/Pipelines";import{FETCH_CHECKOUT_URL_TIMEOUT}from"../constants";var URL_TYPE_CHECKOUT='checkout';/**
1
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
2
+ import { requestUrl, receiveUrl, errorUrl } from '@shopgate/pwa-common/action-creators/url';
3
+ import { mutable } from '@shopgate/pwa-common/helpers/redux';
4
+ import { SHOPGATE_CHECKOUT_GET_URL } from "../constants/Pipelines";
5
+ import { FETCH_CHECKOUT_URL_TIMEOUT } from "../constants";
6
+ const URL_TYPE_CHECKOUT = 'checkout';
7
+
8
+ /**
2
9
  * Get the url for checkout.
3
10
  * @return {Function} A redux thunk.
4
- */function fetchCheckoutUrl(){return function(dispatch){return new Promise(function(resolve,reject){dispatch(requestUrl(URL_TYPE_CHECKOUT));new PipelineRequest(SHOPGATE_CHECKOUT_GET_URL).setTimeout(FETCH_CHECKOUT_URL_TIMEOUT)// 12 seconds timeout
5
- .setRetries(0).dispatch().then(function(_ref){var url=_ref.url,expires=_ref.expires;dispatch(receiveUrl(URL_TYPE_CHECKOUT,url,expires));resolve(url);})["catch"](function(){dispatch(errorUrl(URL_TYPE_CHECKOUT));reject();});});};}/** @mixes {MutableFunction} */export default mutable(fetchCheckoutUrl);
11
+ */
12
+ function fetchCheckoutUrl() {
13
+ return dispatch => new Promise((resolve, reject) => {
14
+ dispatch(requestUrl(URL_TYPE_CHECKOUT));
15
+ new PipelineRequest(SHOPGATE_CHECKOUT_GET_URL).setTimeout(FETCH_CHECKOUT_URL_TIMEOUT) // 12 seconds timeout
16
+ .setRetries(0).dispatch().then(({
17
+ url,
18
+ expires
19
+ }) => {
20
+ dispatch(receiveUrl(URL_TYPE_CHECKOUT, url, expires));
21
+ resolve(url);
22
+ }).catch(() => {
23
+ dispatch(errorUrl(URL_TYPE_CHECKOUT));
24
+ reject();
25
+ });
26
+ });
27
+ }
28
+
29
+ /** @mixes {MutableFunction} */
30
+ export default mutable(fetchCheckoutUrl);
@@ -1 +1 @@
1
- export var SHOPGATE_CHECKOUT_GET_URL='shopgate.checkout.getUrl';
1
+ export const SHOPGATE_CHECKOUT_GET_URL = 'shopgate.checkout.getUrl';
@@ -1,2 +1,3 @@
1
- export var LEGACY_URL='/checkout_legacy';export var FETCH_CHECKOUT_URL_TIMEOUT=12000;// 12 seconds timeout for fetching a checkout url.
2
- export var SUCCESS_CHECKOUT='SUCCESS_CHECKOUT';
1
+ export const LEGACY_URL = '/checkout_legacy';
2
+ export const FETCH_CHECKOUT_URL_TIMEOUT = 12000; // 12 seconds timeout for fetching a checkout url.
3
+ export const SUCCESS_CHECKOUT = 'SUCCESS_CHECKOUT';
package/checkout/index.js CHANGED
@@ -1,5 +1,12 @@
1
1
  // ACTIONS
2
- export{default as fetchCheckoutUrl}from"./actions/fetchCheckoutUrl";// CONSTANTS
3
- export*from"./constants/index";export*from"./constants/Pipelines";// SELECTORS
4
- export*from"./selectors";// STREAMS
5
- export*from"./streams";
2
+ export { default as fetchCheckoutUrl } from "./actions/fetchCheckoutUrl";
3
+
4
+ // CONSTANTS
5
+ export * from "./constants/index";
6
+ export * from "./constants/Pipelines";
7
+
8
+ // SELECTORS
9
+ export * from "./selectors";
10
+
11
+ // STREAMS
12
+ export * from "./streams";
@@ -1,5 +1,10 @@
1
- import{getUrl}from'@shopgate/pwa-common/selectors/url';/**
1
+ import { getUrl } from '@shopgate/pwa-common/selectors/url';
2
+
3
+ /**
2
4
  * Gets the checkout url.
3
5
  * @param {Object} state The application state.
4
6
  * @return {string|null}
5
- */export var getCheckoutUrl=function getCheckoutUrl(state){return getUrl(state,{type:'checkout'});};
7
+ */
8
+ export const getCheckoutUrl = state => getUrl(state, {
9
+ type: 'checkout'
10
+ });
@@ -1,4 +1,10 @@
1
- import{main$}from'@shopgate/pwa-common/streams/main';import{SUCCESS_CHECKOUT}from"../constants";/**
1
+ import { main$ } from '@shopgate/pwa-common/streams/main';
2
+ import { SUCCESS_CHECKOUT } from "../constants";
3
+
4
+ /**
2
5
  * Gets triggered when the checkout has been completed.
3
6
  * @type {Observable}
4
- */export var checkoutSucceeded$=main$.filter(function(_ref){var action=_ref.action;return action.type===SUCCESS_CHECKOUT;});
7
+ */
8
+ export const checkoutSucceeded$ = main$.filter(({
9
+ action
10
+ }) => action.type === SUCCESS_CHECKOUT);
@@ -1,10 +1,39 @@
1
- import'rxjs/add/operator/debounceTime';import event from'@shopgate/pwa-core/classes/Event';import registerEvents from'@shopgate/pwa-core/commands/registerEvents';import{appDidStart$}from'@shopgate/pwa-common/streams/app';import{historyReset}from'@shopgate/pwa-common/actions/router';import successCheckout from"../action-creators/successCheckout";import{checkoutSucceeded$}from"../streams";import{getCartProducts}from"../../cart/selectors";/**
1
+ import 'rxjs/add/operator/debounceTime';
2
+ import event from '@shopgate/pwa-core/classes/Event';
3
+ import registerEvents from '@shopgate/pwa-core/commands/registerEvents';
4
+ import { appDidStart$ } from '@shopgate/pwa-common/streams/app';
5
+ import { historyReset } from '@shopgate/pwa-common/actions/router';
6
+ import successCheckout from "../action-creators/successCheckout";
7
+ import { checkoutSucceeded$ } from "../streams";
8
+ import { getCartProducts } from "../../cart/selectors";
9
+
10
+ /**
2
11
  * Checkout subscriptions.
3
12
  * @param {Function} subscribe The subscribe function.
4
- */var checkout=function checkout(subscribe){/**
13
+ */
14
+ const checkout = subscribe => {
15
+ /**
5
16
  * Gets triggered when the app starts.
6
- */subscribe(appDidStart$,function(_ref){var dispatch=_ref.dispatch,getState=_ref.getState;// Register for the app event that is triggered when the checkout process is finished
7
- registerEvents(['checkoutSuccess']);event.addCallback('checkoutSuccess',function(){dispatch(successCheckout(getCartProducts(getState())));});});/**
17
+ */
18
+ subscribe(appDidStart$, ({
19
+ dispatch,
20
+ getState
21
+ }) => {
22
+ // Register for the app event that is triggered when the checkout process is finished
23
+ registerEvents(['checkoutSuccess']);
24
+ event.addCallback('checkoutSuccess', () => {
25
+ dispatch(successCheckout(getCartProducts(getState())));
26
+ });
27
+ });
28
+
29
+ /**
8
30
  * After success checkout
9
- */subscribe(checkoutSucceeded$,function(_ref2){var dispatch=_ref2.dispatch;// Reset navigation history
10
- dispatch(historyReset());});};export default checkout;
31
+ */
32
+ subscribe(checkoutSucceeded$, ({
33
+ dispatch
34
+ }) => {
35
+ // Reset navigation history
36
+ dispatch(historyReset());
37
+ });
38
+ };
39
+ export default checkout;