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

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 +700 -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 +4 -4
  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,11 +1,40 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{getUseGetFavoriteIdsPipeline}from"../selectors";import fetchFavorites from"./fetchFavorites";import fetchFavoriteIds from"./fetchFavoriteIds";import fetchFavoritesList from"./fetchFavoritesList";/**
1
+ import { getUseGetFavoriteIdsPipeline } from "../selectors";
2
+ import fetchFavorites from "./fetchFavorites";
3
+ import fetchFavoriteIds from "./fetchFavoriteIds";
4
+ import fetchFavoritesList from "./fetchFavoritesList";
5
+
6
+ /**
2
7
  *
3
8
  * Combine fetch favorites list action and fetch favorites action.
4
9
  * @param {boolean} ignoreCache Ignores cache when true
5
10
  * @returns {Function} A redux thunk.
6
- */function fetchFavoritesListsWithItems(){var ignoreCache=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var lists,useGetFavoriteIdsPipeline,itemPromises,wishlistItems;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return dispatch(fetchFavoritesList(ignoreCache));case 2:_context.t0=_context.sent;if(_context.t0){_context.next=5;break;}_context.t0=[];case 5:lists=_context.t0;useGetFavoriteIdsPipeline=getUseGetFavoriteIdsPipeline(getState());itemPromises=lists.map(function(list){/**
11
+ */
12
+ function fetchFavoritesListsWithItems(ignoreCache = false) {
13
+ return async (dispatch, getState) => {
14
+ const lists = (await dispatch(fetchFavoritesList(ignoreCache))) || [];
15
+ const useGetFavoriteIdsPipeline = getUseGetFavoriteIdsPipeline(getState());
16
+ const itemPromises = lists.map(list => {
17
+ /**
7
18
  * In PWA6 the fetchFavoriteIds pipelines was used to retrieve the contents of the
8
19
  * favorites list. Its response doesn't contain product objects, but only product ids.
9
20
  * For compatibility reasons and simplification, the action returns an object that's similar
10
21
  * to the fetchFavorites response, so that the existing reducers can be used.
11
- */if(useGetFavoriteIdsPipeline){return dispatch(fetchFavoriteIds(ignoreCache,list.id));}return dispatch(fetchFavorites(ignoreCache,list.id));});_context.next=10;return Promise.all(itemPromises);case 10:wishlistItems=_context.sent;return _context.abrupt("return",lists.map(function(_ref2,index){var id=_ref2.id,name=_ref2.name;return{id:id,name:name,itemCount:(wishlistItems[index]||{}).itemCount,items:(wishlistItems[index]||{}).items};}));case 12:case"end":return _context.stop();}},_callee);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());}export default fetchFavoritesListsWithItems;
22
+ */
23
+ if (useGetFavoriteIdsPipeline) {
24
+ return dispatch(fetchFavoriteIds(ignoreCache, list.id));
25
+ }
26
+ return dispatch(fetchFavorites(ignoreCache, list.id));
27
+ });
28
+ const wishlistItems = await Promise.all(itemPromises);
29
+ return lists.map(({
30
+ id,
31
+ name
32
+ }, index) => ({
33
+ id,
34
+ name,
35
+ itemCount: (wishlistItems[index] || {}).itemCount,
36
+ items: (wishlistItems[index] || {}).items
37
+ }));
38
+ };
39
+ }
40
+ export default fetchFavoritesListsWithItems;
@@ -1,6 +1,10 @@
1
- import fetchFavorites from"./fetchFavorites";/**
1
+ import fetchFavorites from "./fetchFavorites";
2
+
3
+ /**
2
4
  * Get favorites action.
3
5
  * @param {boolean} ignoreCache Ignores cache when true
4
6
  * @returns {Promise|undefined}
5
7
  * @deprecated
6
- */var getFavorites=fetchFavorites;export default getFavorites;
8
+ */
9
+ const getFavorites = fetchFavorites;
10
+ export default getFavorites;
@@ -1,9 +1,38 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{mutable}from'@shopgate/pwa-common/helpers/redux';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{SHOPGATE_USER_DELETE_FAVORITES}from"../constants/Pipelines";import{successRemoveFavorites,errorRemoveFavorites}from"../action-creators";import{getHasMultipleFavoritesListsSupport,getFavoritesDefaultList}from"../selectors";/**
1
+ import { mutable } from '@shopgate/pwa-common/helpers/redux';
2
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
3
+ import { SHOPGATE_USER_DELETE_FAVORITES } from "../constants/Pipelines";
4
+ import { successRemoveFavorites, errorRemoveFavorites } from "../action-creators";
5
+ import { getHasMultipleFavoritesListsSupport, getFavoritesDefaultList } from "../selectors";
6
+
7
+ /**
2
8
  * Removes a single product from the favorite list using the `deleteFavorites` pipeline.
3
9
  * @param {string} productId Id of the product to be deleted.
4
10
  * @param {string} listId Id of the list to be deleted.
5
11
  * @param {number} quantity Quantity of the favorite
6
12
  * @param {string} notes Notes of the favorite
7
13
  * @returns {Function} A redux thunk.
8
- */function removeFavorites(productId,listId,quantity,notes){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var state,hasMultiSupport,defaultList,takenListId,request;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:state=getState();hasMultiSupport=getHasMultipleFavoritesListsSupport(state);// Fallback for deprecated calls without list id.
9
- defaultList=getFavoritesDefaultList(state);takenListId=listId||defaultList.id;request=new PipelineRequest(SHOPGATE_USER_DELETE_FAVORITES).setInput(_extends({productId:productId},hasMultiSupport?{favoritesListId:takenListId}:null)).setRetries(0).dispatch();_context.prev=5;_context.next=8;return request;case 8:dispatch(successRemoveFavorites(productId,takenListId));_context.next=14;break;case 11:_context.prev=11;_context.t0=_context["catch"](5);dispatch(errorRemoveFavorites(productId,takenListId,_context.t0,quantity,notes));case 14:return _context.abrupt("return",request);case 15:case"end":return _context.stop();}},_callee,null,[[5,11]]);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());}export default mutable(removeFavorites);
14
+ */
15
+ function removeFavorites(productId, listId, quantity, notes) {
16
+ return async (dispatch, getState) => {
17
+ const state = getState();
18
+ const hasMultiSupport = getHasMultipleFavoritesListsSupport(state);
19
+
20
+ // Fallback for deprecated calls without list id.
21
+ const defaultList = getFavoritesDefaultList(state);
22
+ const takenListId = listId || defaultList.id;
23
+ const request = new PipelineRequest(SHOPGATE_USER_DELETE_FAVORITES).setInput({
24
+ productId,
25
+ ...(hasMultiSupport ? {
26
+ favoritesListId: takenListId
27
+ } : null)
28
+ }).setRetries(0).dispatch();
29
+ try {
30
+ await request;
31
+ dispatch(successRemoveFavorites(productId, takenListId));
32
+ } catch (error) {
33
+ dispatch(errorRemoveFavorites(productId, takenListId, error, quantity, notes));
34
+ }
35
+ return request;
36
+ };
37
+ }
38
+ export default mutable(removeFavorites);
@@ -1,5 +1,27 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{mutable}from'@shopgate/pwa-common/helpers/redux';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{SHOPGATE_USER_REMOVE_FAVORITES_LIST}from"../constants/Pipelines";import{SUCCESS_REMOVE_FAVORITES_LIST}from"../constants";/**
1
+ import { mutable } from '@shopgate/pwa-common/helpers/redux';
2
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
3
+ import { SHOPGATE_USER_REMOVE_FAVORITES_LIST } from "../constants/Pipelines";
4
+ import { SUCCESS_REMOVE_FAVORITES_LIST } from "../constants";
5
+
6
+ /**
2
7
  * Adds a new favorite list.
3
8
  * @param {string} listId Id of the wishlist.
4
9
  * @returns {Function} A redux thunk.
5
- */function removeFavoritesList(listId){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:request=new PipelineRequest(SHOPGATE_USER_REMOVE_FAVORITES_LIST).setInput({id:listId}).setRetries(0).dispatch();_context.prev=1;_context.next=4;return request;case 4:dispatch({type:SUCCESS_REMOVE_FAVORITES_LIST,listId:listId});_context.next=9;break;case 7:_context.prev=7;_context.t0=_context["catch"](1);case 9:case"end":return _context.stop();}},_callee,null,[[1,7]]);}));return function(_x){return _ref.apply(this,arguments);};}());}export default mutable(removeFavoritesList);
10
+ */
11
+ function removeFavoritesList(listId) {
12
+ return async dispatch => {
13
+ const request = new PipelineRequest(SHOPGATE_USER_REMOVE_FAVORITES_LIST).setInput({
14
+ id: listId
15
+ }).setRetries(0).dispatch();
16
+ try {
17
+ await request;
18
+ dispatch({
19
+ type: SUCCESS_REMOVE_FAVORITES_LIST,
20
+ listId
21
+ });
22
+ } catch (_) {
23
+ // Fail silently
24
+ }
25
+ };
26
+ }
27
+ export default mutable(removeFavoritesList);
@@ -1,4 +1,10 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{mutable}from'@shopgate/pwa-common/helpers/redux';import{getWishlistItemQuantityEnabled,getLoadWishlistOnAppStartEnabled}from'@shopgate/engage/core/selectors/shopSettings';import{getFavoritesDefaultList,getFavoritesLists,makeIsProductOnSpecificFavoriteList}from"../selectors";import{addProductToFavorites,removeProductFromFavorites,requestFlushFavoritesBuffer,openFavoritesListChooser,updateProductInFavorites}from"../action-creators";import fetchFavoritesListsWithItems from"./fetchFavoritesListsWithItems";/**
1
+ import { mutable } from '@shopgate/pwa-common/helpers/redux';
2
+ import { getWishlistItemQuantityEnabled, getLoadWishlistOnAppStartEnabled } from '@shopgate/engage/core/selectors/shopSettings';
3
+ import { getFavoritesDefaultList, getFavoritesLists, makeIsProductOnSpecificFavoriteList } from "../selectors";
4
+ import { addProductToFavorites, removeProductFromFavorites, requestFlushFavoritesBuffer, openFavoritesListChooser, updateProductInFavorites } from "../action-creators";
5
+ import fetchFavoritesListsWithItems from "./fetchFavoritesListsWithItems";
6
+
7
+ /**
2
8
  * Adds a product to the favorite list (debounced and buffered).
3
9
  * @mixes {MutableFunction}
4
10
  * @param {string} productId Product identifier.
@@ -7,41 +13,93 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
7
13
  * @param {string} notes New favorites notes to set
8
14
  * @param {boolean} showToast Whether to show a confirmation toast after product was added
9
15
  * @return {Function}
10
- */export var addFavorite=mutable(function(productId,listId,quantity,notes){var showToast=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;return function(dispatch,getState){var defaultList=getFavoritesDefaultList(getState());dispatch(addProductToFavorites(productId,listId||defaultList.id,quantity,notes,showToast));};});/**
16
+ */
17
+ export const addFavorite = mutable((productId, listId, quantity, notes, showToast = false) => (dispatch, getState) => {
18
+ const defaultList = getFavoritesDefaultList(getState());
19
+ dispatch(addProductToFavorites(productId, listId || defaultList.id, quantity, notes, showToast));
20
+ });
21
+
22
+ /**
11
23
  * Adds a product to the favorite list (debounced and buffered).
12
24
  * @param {string} productId Product identifier.
13
25
  * @return {Function}
14
26
  * @deprecated Please use `addFavorite` instead.
15
- */export var addFavorites=addFavorite;/**
27
+ */
28
+ export const addFavorites = addFavorite;
29
+
30
+ /**
16
31
  * Removes a product and optionally its relatives from the favorite list (debounced and buffered).
17
32
  * @mixes {MutableFunction}
18
33
  * @param {string} productId Product identifier.
19
34
  * @param {boolean} withRelatives When true relatives which are on list are also removed.
20
35
  * @param {string} listId List identifier.
21
36
  * @returns {Function}
22
- */export var removeFavorites=mutable(function(productId){var withRelatives=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var listId=arguments.length>2?arguments[2]:undefined;return function(dispatch,getState){var defaultList=getFavoritesDefaultList(getState());dispatch(removeProductFromFavorites(productId,withRelatives,listId||defaultList.id));};});/**
37
+ */
38
+ export const removeFavorites = mutable((productId, withRelatives = false, listId) => (dispatch, getState) => {
39
+ const defaultList = getFavoritesDefaultList(getState());
40
+ dispatch(removeProductFromFavorites(productId, withRelatives, listId || defaultList.id));
41
+ });
42
+
43
+ /**
23
44
  * Triggers a sync of favorites by immediately flushing buffered favorite update actions.
24
45
  * @mixes {MutableFunction}
25
46
  * @return {Function}
26
- */export var requestSync=mutable(function(listId){return function(dispatch){dispatch(requestFlushFavoritesBuffer(listId));};});/**
47
+ */
48
+ export const requestSync = mutable(listId => dispatch => {
49
+ dispatch(requestFlushFavoritesBuffer(listId));
50
+ });
51
+
52
+ /**
27
53
  * Adds a product to the favorite list (debounced and buffered).
28
54
  * @param {string} productId Product identifier.
29
55
  * @param {string} listId List identifier.
30
56
  * @param {boolean} withRelatives When true relatives which are on list are also removed.
31
57
  * @return {Function}
32
- */export var toggleFavorite=mutable(function(productId,listId){var withRelatives=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return function(dispatch,getState){var state=getState();// With quantity enabled the favorites button always adds (increases quantity)
33
- var wishlistItemQuantityEnabled=getWishlistItemQuantityEnabled(state);var loadWishlistOnAppStartEnabled=getLoadWishlistOnAppStartEnabled(state);if(wishlistItemQuantityEnabled||!loadWishlistOnAppStartEnabled){dispatch(addFavorite(productId,listId,null,null,true));}else{var isOnList=makeIsProductOnSpecificFavoriteList(function(){return productId;},function(){return listId;})(state);dispatch(!isOnList?addFavorite(productId,listId):removeFavorites(productId,withRelatives,listId));}};});/**
58
+ */
59
+ export const toggleFavorite = mutable((productId, listId, withRelatives = false) => (dispatch, getState) => {
60
+ const state = getState();
61
+ // With quantity enabled the favorites button always adds (increases quantity)
62
+ const wishlistItemQuantityEnabled = getWishlistItemQuantityEnabled(state);
63
+ const loadWishlistOnAppStartEnabled = getLoadWishlistOnAppStartEnabled(state);
64
+ if (wishlistItemQuantityEnabled || !loadWishlistOnAppStartEnabled) {
65
+ dispatch(addFavorite(productId, listId, null, null, true));
66
+ } else {
67
+ const isOnList = makeIsProductOnSpecificFavoriteList(() => productId, () => listId)(state);
68
+ dispatch(!isOnList ? addFavorite(productId, listId) : removeFavorites(productId, withRelatives, listId));
69
+ }
70
+ });
71
+
72
+ /**
34
73
  * Updatest a product in the favorite list (debounced and buffered).
35
74
  * @param {string} productId Product identifier.
36
75
  * @param {string} listId List identifier.
37
76
  * @param {number} quantity
38
77
  * @param {string} notes
39
78
  * @return {Function}
40
- */export var updateFavorite=mutable(function(productId,listId,quantity,notes){return function(dispatch,getState){var defaultList=getFavoritesDefaultList(getState());dispatch(updateProductInFavorites(productId,listId||defaultList.id,quantity,notes));};});/**
79
+ */
80
+ export const updateFavorite = mutable((productId, listId, quantity, notes) => (dispatch, getState) => {
81
+ const defaultList = getFavoritesDefaultList(getState());
82
+ dispatch(updateProductInFavorites(productId, listId || defaultList.id, quantity, notes));
83
+ });
84
+
85
+ /**
41
86
  * Adds a product to a wishlist by opening a chooser if user has multiple lists.
42
87
  * @mixes {MutableFunction}
43
88
  * @param {string} productId Product identifier.
44
89
  * @param {boolean} withRelatives When true relatives which are on list are also removed.
45
90
  * @return {Function}
46
- */export var toggleFavoriteWithListChooser=mutable(function(productId){var withRelatives=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var state,lists;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return dispatch(fetchFavoritesListsWithItems());case 2:state=getState();lists=getFavoritesLists(state);// Only one list available therefore we just add/remove it the product there.
47
- if(!(lists.length<=1)){_context.next=7;break;}dispatch(toggleFavorite(productId,lists[0].id,withRelatives));return _context.abrupt("return");case 7:dispatch(openFavoritesListChooser(productId,withRelatives));case 8:case"end":return _context.stop();}},_callee);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());});
91
+ */
92
+ export const toggleFavoriteWithListChooser = mutable((productId, withRelatives = false) => async (dispatch, getState) => {
93
+ // Ensure favorites lists are fetched before.
94
+ // In some cases this fetch will NOT happen on app start
95
+ await dispatch(fetchFavoritesListsWithItems());
96
+ const state = getState();
97
+ const lists = getFavoritesLists(state);
98
+
99
+ // Only one list available therefore we just add/remove it the product there.
100
+ if (lists.length <= 1) {
101
+ dispatch(toggleFavorite(productId, lists[0].id, withRelatives));
102
+ return;
103
+ }
104
+ dispatch(openFavoritesListChooser(productId, withRelatives));
105
+ });
@@ -1,9 +1,45 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{mutable}from'@shopgate/pwa-common/helpers/redux';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import isNumber from'lodash/isNumber';import isString from'lodash/isString';import{SHOPGATE_USER_UPDATE_FAVORITES}from"../constants/Pipelines";import{errorUpdateFavorites,successUpdateFavorites}from"../action-creators";import{getHasMultipleFavoritesListsSupport,getFavoritesDefaultList}from"../selectors";/**
1
+ import { mutable } from '@shopgate/pwa-common/helpers/redux';
2
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
3
+ import isNumber from 'lodash/isNumber';
4
+ import isString from 'lodash/isString';
5
+ import { SHOPGATE_USER_UPDATE_FAVORITES } from "../constants/Pipelines";
6
+ import { errorUpdateFavorites, successUpdateFavorites } from "../action-creators";
7
+ import { getHasMultipleFavoritesListsSupport, getFavoritesDefaultList } from "../selectors";
8
+ /**
2
9
  * Updates a single product on the favorite list using the `updateFavorites` pipeline.
3
10
  * @param {string} productId The id of the product.
4
11
  * @param {string} listId Id of the list to be updated.
5
12
  * @param {number} quantity New favorites quantity to set
6
13
  * @param {string} notes ew favorites notes to set
7
14
  * @returns {Function} A redux thunk.
8
- */function updateFavorites(productId){var listId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var quantity=arguments.length>2?arguments[2]:undefined;var notes=arguments.length>3?arguments[3]:undefined;return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var state,hasMultiSupport,defaultList,takenListId,request;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:state=getState();hasMultiSupport=getHasMultipleFavoritesListsSupport(state);// Fallback for deprecated calls without list id.
9
- defaultList=getFavoritesDefaultList(state);takenListId=listId||defaultList.id;request=new PipelineRequest(SHOPGATE_USER_UPDATE_FAVORITES).setInput(_extends({productId:productId},hasMultiSupport?{favoritesListId:takenListId}:null,{},isNumber(quantity)?{quantity:quantity}:{},{},isString(notes)?{notes:notes}:{})).setRetries(0).dispatch();_context.prev=5;_context.next=8;return request;case 8:dispatch(successUpdateFavorites(productId,takenListId));_context.next=14;break;case 11:_context.prev=11;_context.t0=_context["catch"](5);dispatch(errorUpdateFavorites(productId,_context.t0,takenListId));case 14:return _context.abrupt("return",request);case 15:case"end":return _context.stop();}},_callee,null,[[5,11]]);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());}export default mutable(updateFavorites);
15
+ */
16
+ function updateFavorites(productId, listId = null, quantity, notes) {
17
+ return async (dispatch, getState) => {
18
+ const state = getState();
19
+ const hasMultiSupport = getHasMultipleFavoritesListsSupport(state);
20
+
21
+ // Fallback for deprecated calls without list id.
22
+ const defaultList = getFavoritesDefaultList(state);
23
+ const takenListId = listId || defaultList.id;
24
+ const request = new PipelineRequest(SHOPGATE_USER_UPDATE_FAVORITES).setInput({
25
+ productId,
26
+ ...(hasMultiSupport ? {
27
+ favoritesListId: takenListId
28
+ } : null),
29
+ ...(isNumber(quantity) ? {
30
+ quantity
31
+ } : {}),
32
+ ...(isString(notes) ? {
33
+ notes
34
+ } : {})
35
+ }).setRetries(0).dispatch();
36
+ try {
37
+ await request;
38
+ dispatch(successUpdateFavorites(productId, takenListId));
39
+ } catch (error) {
40
+ dispatch(errorUpdateFavorites(productId, error, takenListId));
41
+ }
42
+ return request;
43
+ };
44
+ }
45
+ export default mutable(updateFavorites);
@@ -1,6 +1,30 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{mutable}from'@shopgate/pwa-common/helpers/redux';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{SHOPGATE_USER_UPDATE_FAVORITES_LIST}from"../constants/Pipelines";import{SUCCESS_UPDATE_FAVORITES_LIST}from"../constants";/**
1
+ import { mutable } from '@shopgate/pwa-common/helpers/redux';
2
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
3
+ import { SHOPGATE_USER_UPDATE_FAVORITES_LIST } from "../constants/Pipelines";
4
+ import { SUCCESS_UPDATE_FAVORITES_LIST } from "../constants";
5
+
6
+ /**
2
7
  * Adds a new favorite list.
3
8
  * @param {string} listId Id of the wishlist.
4
9
  * @param {string} name Name of the wishlist.
5
10
  * @returns {Function} A redux thunk.
6
- */function updateFavoritesList(listId,name){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:request=new PipelineRequest(SHOPGATE_USER_UPDATE_FAVORITES_LIST).setInput({id:listId,name:name}).setRetries(0).dispatch();_context.prev=1;_context.next=4;return request;case 4:dispatch({type:SUCCESS_UPDATE_FAVORITES_LIST,listId:listId,name:name});_context.next=9;break;case 7:_context.prev=7;_context.t0=_context["catch"](1);case 9:case"end":return _context.stop();}},_callee,null,[[1,7]]);}));return function(_x){return _ref.apply(this,arguments);};}());}export default mutable(updateFavoritesList);
11
+ */
12
+ function updateFavoritesList(listId, name) {
13
+ return async dispatch => {
14
+ const request = new PipelineRequest(SHOPGATE_USER_UPDATE_FAVORITES_LIST).setInput({
15
+ id: listId,
16
+ name
17
+ }).setRetries(0).dispatch();
18
+ try {
19
+ await request;
20
+ dispatch({
21
+ type: SUCCESS_UPDATE_FAVORITES_LIST,
22
+ listId,
23
+ name
24
+ });
25
+ } catch (_) {
26
+ // Fail silently
27
+ }
28
+ };
29
+ }
30
+ export default mutable(updateFavoritesList);
@@ -1 +1,9 @@
1
- export var SHOPGATE_USER_GET_FAVORITES='shopgate.user.getFavorites';export var SHOPGATE_USER_GET_FAVORITE_IDS='shopgate.user.getFavoriteIds';export var SHOPGATE_USER_ADD_FAVORITES='shopgate.user.addFavorites';export var SHOPGATE_USER_DELETE_FAVORITES='shopgate.user.deleteFavorites';export var SHOPGATE_USER_UPDATE_FAVORITES='shopgate.user.updateFavorites';export var SHOPGATE_USER_GET_FAVORITES_LIST='shopgate.user.getFavoritesLists';export var SHOPGATE_USER_ADD_FAVORITES_LIST='shopgate.user.addFavoritesList';export var SHOPGATE_USER_UPDATE_FAVORITES_LIST='shopgate.user.updateFavoritesList';export var SHOPGATE_USER_REMOVE_FAVORITES_LIST='shopgate.user.removeFavoritesList';
1
+ export const SHOPGATE_USER_GET_FAVORITES = 'shopgate.user.getFavorites';
2
+ export const SHOPGATE_USER_GET_FAVORITE_IDS = 'shopgate.user.getFavoriteIds';
3
+ export const SHOPGATE_USER_ADD_FAVORITES = 'shopgate.user.addFavorites';
4
+ export const SHOPGATE_USER_DELETE_FAVORITES = 'shopgate.user.deleteFavorites';
5
+ export const SHOPGATE_USER_UPDATE_FAVORITES = 'shopgate.user.updateFavorites';
6
+ export const SHOPGATE_USER_GET_FAVORITES_LIST = 'shopgate.user.getFavoritesLists';
7
+ export const SHOPGATE_USER_ADD_FAVORITES_LIST = 'shopgate.user.addFavoritesList';
8
+ export const SHOPGATE_USER_UPDATE_FAVORITES_LIST = 'shopgate.user.updateFavoritesList';
9
+ export const SHOPGATE_USER_REMOVE_FAVORITES_LIST = 'shopgate.user.removeFavoritesList';
@@ -3,7 +3,35 @@
3
3
  *
4
4
  * This source code is licensed under the Apache 2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
- */ // FEATURES
7
- var NAV_MENU='nav-menu';// CONTENTS
8
- export var FAVORITES='favorites';var ADD_TO_CART='add-to-cart';var AVAILABILITY_TEXT='availability-text';var PRODUCT_NAME='product-name';var PRODUCT_PRICE='product-price';var EMPTY='empty';// POSITIONS
9
- var BEFORE='before';var AFTER='after';export var NAV_MENU_FAVORITES_BEFORE="".concat(NAV_MENU,".").concat(FAVORITES,".").concat(BEFORE);export var NAV_MENU_FAVORITES="".concat(NAV_MENU,".").concat(FAVORITES);export var NAV_MENU_FAVORITES_AFTER="".concat(NAV_MENU,".").concat(FAVORITES,".").concat(AFTER);export var FAVORITES_ADD_TO_CART_BEFORE="".concat(FAVORITES,".").concat(ADD_TO_CART,".").concat(BEFORE);export var FAVORITES_ADD_TO_CART="".concat(FAVORITES,".").concat(ADD_TO_CART);export var FAVORITES_ADD_TO_CART_AFTER="".concat(FAVORITES,".").concat(ADD_TO_CART,".").concat(AFTER);export var FAVORITES_PRODUCT_NAME_BEFORE="".concat(FAVORITES,".").concat(PRODUCT_NAME,".").concat(BEFORE);export var FAVORITES_PRODUCT_NAME="".concat(FAVORITES,".").concat(PRODUCT_NAME);export var FAVORITES_PRODUCT_NAME_AFTER="".concat(FAVORITES,".").concat(PRODUCT_NAME,".").concat(AFTER);export var FAVORITES_PRODUCT_PRICE_BEFORE="".concat(FAVORITES,".").concat(PRODUCT_PRICE,".").concat(BEFORE);export var FAVORITES_PRODUCT_PRICE="".concat(FAVORITES,".").concat(PRODUCT_PRICE);export var FAVORITES_PRODUCT_PRICE_AFTER="".concat(FAVORITES,".").concat(PRODUCT_PRICE,".").concat(AFTER);export var FAVORITES_AVAILABILITY_TEXT_BEFORE="".concat(FAVORITES,".").concat(AVAILABILITY_TEXT,".").concat(BEFORE);export var FAVORITES_AVAILABILITY_TEXT="".concat(FAVORITES,".").concat(AVAILABILITY_TEXT);export var FAVORITES_AVAILABILITY_TEXT_AFTER="".concat(FAVORITES,".").concat(AVAILABILITY_TEXT,".").concat(AFTER);export var FAVORITES_EMPTY="".concat(FAVORITES,".").concat(EMPTY);
6
+ */
7
+
8
+ // FEATURES
9
+ const NAV_MENU = 'nav-menu';
10
+
11
+ // CONTENTS
12
+ export const FAVORITES = 'favorites';
13
+ const ADD_TO_CART = 'add-to-cart';
14
+ const AVAILABILITY_TEXT = 'availability-text';
15
+ const PRODUCT_NAME = 'product-name';
16
+ const PRODUCT_PRICE = 'product-price';
17
+ const EMPTY = 'empty';
18
+
19
+ // POSITIONS
20
+ const BEFORE = 'before';
21
+ const AFTER = 'after';
22
+ export const NAV_MENU_FAVORITES_BEFORE = `${NAV_MENU}.${FAVORITES}.${BEFORE}`;
23
+ export const NAV_MENU_FAVORITES = `${NAV_MENU}.${FAVORITES}`;
24
+ export const NAV_MENU_FAVORITES_AFTER = `${NAV_MENU}.${FAVORITES}.${AFTER}`;
25
+ export const FAVORITES_ADD_TO_CART_BEFORE = `${FAVORITES}.${ADD_TO_CART}.${BEFORE}`;
26
+ export const FAVORITES_ADD_TO_CART = `${FAVORITES}.${ADD_TO_CART}`;
27
+ export const FAVORITES_ADD_TO_CART_AFTER = `${FAVORITES}.${ADD_TO_CART}.${AFTER}`;
28
+ export const FAVORITES_PRODUCT_NAME_BEFORE = `${FAVORITES}.${PRODUCT_NAME}.${BEFORE}`;
29
+ export const FAVORITES_PRODUCT_NAME = `${FAVORITES}.${PRODUCT_NAME}`;
30
+ export const FAVORITES_PRODUCT_NAME_AFTER = `${FAVORITES}.${PRODUCT_NAME}.${AFTER}`;
31
+ export const FAVORITES_PRODUCT_PRICE_BEFORE = `${FAVORITES}.${PRODUCT_PRICE}.${BEFORE}`;
32
+ export const FAVORITES_PRODUCT_PRICE = `${FAVORITES}.${PRODUCT_PRICE}`;
33
+ export const FAVORITES_PRODUCT_PRICE_AFTER = `${FAVORITES}.${PRODUCT_PRICE}.${AFTER}`;
34
+ export const FAVORITES_AVAILABILITY_TEXT_BEFORE = `${FAVORITES}.${AVAILABILITY_TEXT}.${BEFORE}`;
35
+ export const FAVORITES_AVAILABILITY_TEXT = `${FAVORITES}.${AVAILABILITY_TEXT}`;
36
+ export const FAVORITES_AVAILABILITY_TEXT_AFTER = `${FAVORITES}.${AVAILABILITY_TEXT}.${AFTER}`;
37
+ export const FAVORITES_EMPTY = `${FAVORITES}.${EMPTY}`;
@@ -1,5 +1,37 @@
1
- export var FAVORITES_PATH='/favourite_list';export var ADD_PRODUCT_TO_FAVORITES='ADD_PRODUCT_TO_FAVORITES';export var UPDATE_PRODUCT_IN_FAVORITES='UPDATE_PRODUCT_IN_FAVORITES';export var REMOVE_PRODUCT_FROM_FAVORITES='REMOVE_PRODUCT_FROM_FAVORITES';export var REQUEST_UPDATE_FAVORITES='REQUEST_UPDATE_FAVORITES';export var SUCCESS_UPDATE_FAVORITES='SUCCESS_UPDATE_FAVORITES';export var ERROR_UPDATE_FAVORITES='ERROR_UPDATE_FAVORITES';export var REQUEST_FAVORITES='REQUEST_FAVORITES';export var RECEIVE_FAVORITES='RECEIVE_FAVORITES';export var ERROR_FAVORITES='ERROR_FAVORITES';export var ERROR_FETCH_FAVORITES='ERROR_FETCH_FAVORITES';export var REQUEST_ADD_FAVORITES='REQUEST_ADD_FAVORITES';export var SUCCESS_ADD_FAVORITES='SUCCESS_ADD_FAVORITES';export var ERROR_ADD_FAVORITES='ERROR_ADD_FAVORITES';export var REQUEST_REMOVE_FAVORITES='REQUEST_REMOVE_FAVORITES';export var SUCCESS_REMOVE_FAVORITES='SUCCESS_REMOVE_FAVORITES';export var ERROR_REMOVE_FAVORITES='ERROR_REMOVE_FAVORITES';export var CANCEL_REQUEST_SYNC_FAVORITES='CANCEL_REQUEST_SYNC_FAVORITES';export var IDLE_SYNC_FAVORITES='IDLE_SYNC_FAVORITES';export var REQUEST_FLUSH_FAVORITES_BUFFER='REQUEST_FLUSH_FAVORITES_BUFFER';// Defines a local error code which is not related to a backend call
2
- export var FAVORITES_LIMIT_ERROR='FAVORITES_LIMIT_ERROR';export var FAVORITES_LIFETIME=3600000;// 1 hour
3
- export var FETCH_FAVORITES_THROTTLE=process.env&&process.env.NODE_ENV==='test'?0:2000;export var FAVORITE_ACTION_BUFFER_TIME=500;export var FAVORITE_BUTTON_DEBOUNCE_TIME=200;// Handles duplicated add/remove button clicks
4
- export var FAVORITE_QUANTITY_DEBOUNCE_TIME=200;// Handles duplicated update button clicks
5
- export var RECEIVE_FAVORITES_LISTS='SUCCESS_FETCH_FAVORITES_LIST';export var SUCCESS_ADD_FAVORITES_LIST='SUCCESS_ADD_FAVORITES_LIST';export var SUCCESS_UPDATE_FAVORITES_LIST='SUCCESS_UPDATE_FAVORITES_LIST';export var SUCCESS_REMOVE_FAVORITES_LIST='SUCCESS_REMOVE_FAVORITES_LIST';export var OPEN_FAVORITE_LIST_CHOOSER='OPEN_FAVORITE_LIST_CHOOSER';export var CLOSE_FAVORITE_LIST_CHOOSER='CLOSE_FAVORITE_LIST_CHOOSER';export var OPEN_FAVORITE_COMMENT_DIALOG='OPEN_FAVORITE_COMMENT_DIALOG';export var CLOSE_FAVORITE_COMMENT_DIALOG='CLOSE_FAVORITE_COMMENT_DIALOG';
1
+ export const FAVORITES_PATH = '/favourite_list';
2
+ export const ADD_PRODUCT_TO_FAVORITES = 'ADD_PRODUCT_TO_FAVORITES';
3
+ export const UPDATE_PRODUCT_IN_FAVORITES = 'UPDATE_PRODUCT_IN_FAVORITES';
4
+ export const REMOVE_PRODUCT_FROM_FAVORITES = 'REMOVE_PRODUCT_FROM_FAVORITES';
5
+ export const REQUEST_UPDATE_FAVORITES = 'REQUEST_UPDATE_FAVORITES';
6
+ export const SUCCESS_UPDATE_FAVORITES = 'SUCCESS_UPDATE_FAVORITES';
7
+ export const ERROR_UPDATE_FAVORITES = 'ERROR_UPDATE_FAVORITES';
8
+ export const REQUEST_FAVORITES = 'REQUEST_FAVORITES';
9
+ export const RECEIVE_FAVORITES = 'RECEIVE_FAVORITES';
10
+ export const ERROR_FAVORITES = 'ERROR_FAVORITES';
11
+ export const ERROR_FETCH_FAVORITES = 'ERROR_FETCH_FAVORITES';
12
+ export const REQUEST_ADD_FAVORITES = 'REQUEST_ADD_FAVORITES';
13
+ export const SUCCESS_ADD_FAVORITES = 'SUCCESS_ADD_FAVORITES';
14
+ export const ERROR_ADD_FAVORITES = 'ERROR_ADD_FAVORITES';
15
+ export const REQUEST_REMOVE_FAVORITES = 'REQUEST_REMOVE_FAVORITES';
16
+ export const SUCCESS_REMOVE_FAVORITES = 'SUCCESS_REMOVE_FAVORITES';
17
+ export const ERROR_REMOVE_FAVORITES = 'ERROR_REMOVE_FAVORITES';
18
+ export const CANCEL_REQUEST_SYNC_FAVORITES = 'CANCEL_REQUEST_SYNC_FAVORITES';
19
+ export const IDLE_SYNC_FAVORITES = 'IDLE_SYNC_FAVORITES';
20
+ export const REQUEST_FLUSH_FAVORITES_BUFFER = 'REQUEST_FLUSH_FAVORITES_BUFFER';
21
+
22
+ // Defines a local error code which is not related to a backend call
23
+ export const FAVORITES_LIMIT_ERROR = 'FAVORITES_LIMIT_ERROR';
24
+ export const FAVORITES_LIFETIME = 3600000; // 1 hour
25
+ export const FETCH_FAVORITES_THROTTLE = process.env && process.env.NODE_ENV === 'test' ? 0 : 2000;
26
+ export const FAVORITE_ACTION_BUFFER_TIME = 500;
27
+ export const FAVORITE_BUTTON_DEBOUNCE_TIME = 200; // Handles duplicated add/remove button clicks
28
+ export const FAVORITE_QUANTITY_DEBOUNCE_TIME = 200; // Handles duplicated update button clicks
29
+
30
+ export const RECEIVE_FAVORITES_LISTS = 'SUCCESS_FETCH_FAVORITES_LIST';
31
+ export const SUCCESS_ADD_FAVORITES_LIST = 'SUCCESS_ADD_FAVORITES_LIST';
32
+ export const SUCCESS_UPDATE_FAVORITES_LIST = 'SUCCESS_UPDATE_FAVORITES_LIST';
33
+ export const SUCCESS_REMOVE_FAVORITES_LIST = 'SUCCESS_REMOVE_FAVORITES_LIST';
34
+ export const OPEN_FAVORITE_LIST_CHOOSER = 'OPEN_FAVORITE_LIST_CHOOSER';
35
+ export const CLOSE_FAVORITE_LIST_CHOOSER = 'CLOSE_FAVORITE_LIST_CHOOSER';
36
+ export const OPEN_FAVORITE_COMMENT_DIALOG = 'OPEN_FAVORITE_COMMENT_DIALOG';
37
+ export const CLOSE_FAVORITE_COMMENT_DIALOG = 'CLOSE_FAVORITE_COMMENT_DIALOG';
@@ -1,5 +1,15 @@
1
1
  // ACTIONS
2
- export{default as fetchFavorites}from"./actions/fetchFavorites";export{addFavorite,removeFavorites,requestSync as toggleFavorites}from"./actions/toggleFavorites";export{default as fetchFavoritesListsWithItems}from"./actions/fetchFavoritesListsWithItems";// CONSTANTS
3
- export*from"./constants/index";export*from"./constants/Pipelines";export*from"./constants/Portals";// SELECTORS
4
- export*from"./selectors";// STREAMS
5
- export*from"./streams";
2
+ export { default as fetchFavorites } from "./actions/fetchFavorites";
3
+ export { addFavorite, removeFavorites, requestSync as toggleFavorites } from "./actions/toggleFavorites";
4
+ export { default as fetchFavoritesListsWithItems } from "./actions/fetchFavoritesListsWithItems";
5
+
6
+ // CONSTANTS
7
+ export * from "./constants/index";
8
+ export * from "./constants/Pipelines";
9
+ export * from "./constants/Portals";
10
+
11
+ // SELECTORS
12
+ export * from "./selectors";
13
+
14
+ // STREAMS
15
+ export * from "./streams";
package/favorites/mock.js CHANGED
@@ -1,15 +1,100 @@
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);}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;}import{mockedProducts as mockedList}from"../product/mock";export var mockedDefaultListId='DEFAULT';var mockedStateWithoutProducts={favorites:{byList:_defineProperty({},mockedDefaultListId,{isFetching:false,expires:0,ids:[]}),lists:{expires:0,lists:[{id:mockedDefaultListId,name:'Wish List'}]}}};/**
1
+ import "core-js/modules/es.array.reduce.js";
2
+ import { mockedProducts as mockedList } from "../product/mock";
3
+ export const mockedDefaultListId = 'DEFAULT';
4
+ const mockedStateWithoutProducts = {
5
+ favorites: {
6
+ byList: {
7
+ [mockedDefaultListId]: {
8
+ isFetching: false,
9
+ expires: 0,
10
+ ids: []
11
+ }
12
+ },
13
+ lists: {
14
+ expires: 0,
15
+ lists: [{
16
+ id: mockedDefaultListId,
17
+ name: 'Wish List'
18
+ }]
19
+ }
20
+ }
21
+ };
22
+
23
+ /**
2
24
  * Creates a products state from the mocked list.
3
25
  * @return {Object}
4
- */var createProductsState=function createProductsState(){var productsById=mockedList.products.reduce(function(result,current){return _extends({},result,_defineProperty({},current.id,{isFetching:false,expires:0,productData:current}));},{});return{product:{productsById:productsById}};};var mockedStateWithProducts=_extends({},createProductsState(),{favorites:{byList:_defineProperty({},mockedDefaultListId,{isFetching:false,expires:0,ids:[mockedList.products[0].id,mockedList.products[1].id]}),lists:{expires:0,lists:[{id:mockedDefaultListId,name:'Wish List'}]}}});/**
26
+ */
27
+ const createProductsState = () => {
28
+ const productsById = mockedList.products.reduce((result, current) => ({
29
+ ...result,
30
+ [current.id]: {
31
+ isFetching: false,
32
+ expires: 0,
33
+ productData: current
34
+ }
35
+ }), {});
36
+ return {
37
+ product: {
38
+ productsById
39
+ }
40
+ };
41
+ };
42
+ const mockedStateWithProducts = {
43
+ ...createProductsState(),
44
+ favorites: {
45
+ byList: {
46
+ [mockedDefaultListId]: {
47
+ isFetching: false,
48
+ expires: 0,
49
+ ids: [mockedList.products[0].id, mockedList.products[1].id]
50
+ }
51
+ },
52
+ lists: {
53
+ expires: 0,
54
+ lists: [{
55
+ id: mockedDefaultListId,
56
+ name: 'Wish List'
57
+ }]
58
+ }
59
+ }
60
+ };
61
+
62
+ /**
5
63
  * Gets mocked state.
6
64
  * @param {boolean} withProducts When true products are returned.
7
65
  * @param {boolean} validCache When true, `.expires` flag is > `Date.now()`
8
66
  * @returns {Object}
9
- */var getMockedState=function getMockedState(_ref){var withProducts=_ref.withProducts,_ref$validCache=_ref.validCache,validCache=_ref$validCache===void 0?false:_ref$validCache;var data=withProducts?mockedStateWithProducts:mockedStateWithoutProducts;if(validCache){data.favorites.byList[mockedDefaultListId].expires=Date.now()+999999;}return data;};/**
67
+ */
68
+ const getMockedState = ({
69
+ withProducts,
70
+ validCache = false
71
+ }) => {
72
+ const data = withProducts ? mockedStateWithProducts : mockedStateWithoutProducts;
73
+ if (validCache) {
74
+ data.favorites.byList[mockedDefaultListId].expires = Date.now() + 999999;
75
+ }
76
+ return data;
77
+ };
78
+
79
+ /**
10
80
  * Gets mocked state.
11
81
  * @param {'then'|string} variant Variant as in MockedPipelineResponse.
12
82
  * @param {boolean} withProducts When true products are returned.
13
83
  * @param {boolean} validCache When true, `.expires` flag is > `Date.now()`
14
84
  * @returns {Function}
15
- */var mockedGetState=function mockedGetState(variant){var _ref2=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref2$withProducts=_ref2.withProducts,withProducts=_ref2$withProducts===void 0?false:_ref2$withProducts,_ref2$validCache=_ref2.validCache,validCache=_ref2$validCache===void 0?false:_ref2$validCache;return function(){if(variant==='then'){return getMockedState({withProducts:withProducts,validCache:validCache});}return getMockedState({withProducts:false});};};export{mockedList,mockedGetState};
85
+ */
86
+ const mockedGetState = (variant, {
87
+ withProducts = false,
88
+ validCache = false
89
+ } = {}) => () => {
90
+ if (variant === 'then') {
91
+ return getMockedState({
92
+ withProducts,
93
+ validCache
94
+ });
95
+ }
96
+ return getMockedState({
97
+ withProducts: false
98
+ });
99
+ };
100
+ export { mockedList, mockedGetState };
@@ -1 +1,7 @@
1
- import{combineReducers}from'redux';import products from"./products";import lists from"./lists";export default combineReducers({products:products,lists:lists});
1
+ import { combineReducers } from 'redux';
2
+ import products from "./products";
3
+ import lists from "./lists";
4
+ export default combineReducers({
5
+ products,
6
+ lists
7
+ });