@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,4 +1,7 @@
1
- import{ADD_PRODUCT_TO_FAVORITES,REMOVE_PRODUCT_FROM_FAVORITES,CANCEL_REQUEST_SYNC_FAVORITES,ERROR_FETCH_FAVORITES,RECEIVE_FAVORITES,REQUEST_FAVORITES,REQUEST_ADD_FAVORITES,SUCCESS_ADD_FAVORITES,ERROR_ADD_FAVORITES,REQUEST_REMOVE_FAVORITES,SUCCESS_REMOVE_FAVORITES,ERROR_REMOVE_FAVORITES,ERROR_FAVORITES,IDLE_SYNC_FAVORITES,REQUEST_FLUSH_FAVORITES_BUFFER,OPEN_FAVORITE_LIST_CHOOSER,CLOSE_FAVORITE_LIST_CHOOSER,REQUEST_UPDATE_FAVORITES,SUCCESS_UPDATE_FAVORITES,ERROR_UPDATE_FAVORITES,UPDATE_PRODUCT_IN_FAVORITES,OPEN_FAVORITE_COMMENT_DIALOG,CLOSE_FAVORITE_COMMENT_DIALOG}from"../constants";import{makeGetFavorites}from"../selectors";/**
1
+ import { ADD_PRODUCT_TO_FAVORITES, REMOVE_PRODUCT_FROM_FAVORITES, CANCEL_REQUEST_SYNC_FAVORITES, ERROR_FETCH_FAVORITES, RECEIVE_FAVORITES, REQUEST_FAVORITES, REQUEST_ADD_FAVORITES, SUCCESS_ADD_FAVORITES, ERROR_ADD_FAVORITES, REQUEST_REMOVE_FAVORITES, SUCCESS_REMOVE_FAVORITES, ERROR_REMOVE_FAVORITES, ERROR_FAVORITES, IDLE_SYNC_FAVORITES, REQUEST_FLUSH_FAVORITES_BUFFER, OPEN_FAVORITE_LIST_CHOOSER, CLOSE_FAVORITE_LIST_CHOOSER, REQUEST_UPDATE_FAVORITES, SUCCESS_UPDATE_FAVORITES, ERROR_UPDATE_FAVORITES, UPDATE_PRODUCT_IN_FAVORITES, OPEN_FAVORITE_COMMENT_DIALOG, CLOSE_FAVORITE_COMMENT_DIALOG } from "../constants";
2
+ import { makeGetFavorites } from "../selectors";
3
+
4
+ /**
2
5
  * First action to add one product to favorites.
3
6
  * @param {number} productId Id of the product to add.
4
7
  * @param {string} listId List identifier.
@@ -6,30 +9,71 @@ import{ADD_PRODUCT_TO_FAVORITES,REMOVE_PRODUCT_FROM_FAVORITES,CANCEL_REQUEST_SYN
6
9
  * @param {string} notes New favorites notes to set
7
10
  * @param {boolean} showToast Whether to show a confirmation toast after product was added
8
11
  * @returns {Object}
9
- */export var addProductToFavorites=function addProductToFavorites(productId,listId,quantity,notes){var showToast=arguments.length>4&&arguments[4]!==undefined?arguments[4]:true;return{type:ADD_PRODUCT_TO_FAVORITES,productId:productId,listId:listId,quantity:quantity,notes:notes,showToast:showToast};};/**
12
+ */
13
+ export const addProductToFavorites = (productId, listId, quantity, notes, showToast = true) => ({
14
+ type: ADD_PRODUCT_TO_FAVORITES,
15
+ productId,
16
+ listId,
17
+ quantity,
18
+ notes,
19
+ showToast
20
+ });
21
+
22
+ /**
10
23
  * First action to update a product in favorites.
11
24
  * @param {number} productId Id of the product to add.
12
25
  * @param {string} listId List identifier.
13
26
  * @param {number} quantity The quantity of the product.
14
27
  * @param {string} notes Notes about the product.
15
28
  * @returns {Object}
16
- */export var updateProductInFavorites=function updateProductInFavorites(productId,listId,quantity,notes){return{type:UPDATE_PRODUCT_IN_FAVORITES,productId:productId,listId:listId,notes:notes,quantity:quantity};};/**
29
+ */
30
+ export const updateProductInFavorites = (productId, listId, quantity, notes) => ({
31
+ type: UPDATE_PRODUCT_IN_FAVORITES,
32
+ productId,
33
+ listId,
34
+ notes,
35
+ quantity
36
+ });
37
+
38
+ /**
17
39
  * First action to remove one product to favorites.
18
40
  * @param {number} productId Id of the product to remove.
19
41
  * @param {boolean} withRelatives States, whether to remove all relative products or not.
20
42
  * @param {string} listId List identifier.
21
43
  * @returns {Object}
22
- */export var removeProductFromFavorites=function removeProductFromFavorites(productId,withRelatives,listId){return{type:REMOVE_PRODUCT_FROM_FAVORITES,productId:productId,withRelatives:withRelatives,listId:listId};};/**
44
+ */
45
+ export const removeProductFromFavorites = (productId, withRelatives, listId) => ({
46
+ type: REMOVE_PRODUCT_FROM_FAVORITES,
47
+ productId,
48
+ withRelatives,
49
+ listId
50
+ });
51
+
52
+ /**
23
53
  * Error on fetch favorites action.
24
54
  * @param {Error} error Error.
25
55
  * @param {string} listId List identifier.
26
56
  * @returns {Object}
27
- */export var errorFetchFavorites=function errorFetchFavorites(error,listId){return{type:ERROR_FETCH_FAVORITES,error:error,listId:listId};};/**
57
+ */
58
+ export const errorFetchFavorites = (error, listId) => ({
59
+ type: ERROR_FETCH_FAVORITES,
60
+ error,
61
+ listId
62
+ });
63
+
64
+ /**
28
65
  * Error on favorites action.
29
66
  * @param {string} productId Product identifier.
30
67
  * @param {Error} error Error.
31
68
  * @returns {Object}
32
- */export var errorFavorites=function errorFavorites(productId,error){return{type:ERROR_FAVORITES,productId:productId,error:error};};/**
69
+ */
70
+ export const errorFavorites = (productId, error) => ({
71
+ type: ERROR_FAVORITES,
72
+ productId,
73
+ error
74
+ });
75
+
76
+ /**
33
77
  * Request add favorites action. This action just updates the redux store.
34
78
  * @param {string} productId Product identifier.
35
79
  * @param {string} listId List identifier.
@@ -37,47 +81,120 @@ import{ADD_PRODUCT_TO_FAVORITES,REMOVE_PRODUCT_FROM_FAVORITES,CANCEL_REQUEST_SYN
37
81
  * @param {string} notes New favorites notes to set
38
82
  * @param {boolean} showToast Whether to show a confirmation toast after product was added
39
83
  * @returns {Object}
40
- */export var requestAddFavorites=function requestAddFavorites(productId,listId,quantity,notes){var showToast=arguments.length>4&&arguments[4]!==undefined?arguments[4]:true;return{type:REQUEST_ADD_FAVORITES,productId:productId,listId:listId,quantity:quantity,notes:notes,showToast:showToast};};/**
84
+ */
85
+ export const requestAddFavorites = (productId, listId, quantity, notes, showToast = true) => ({
86
+ type: REQUEST_ADD_FAVORITES,
87
+ productId,
88
+ listId,
89
+ quantity,
90
+ notes,
91
+ showToast
92
+ });
93
+
94
+ /**
41
95
  * Action to be triggered upon successful addFavorites pipeline call.
42
96
  * @param {string} productId Product identifier.
43
97
  * @param {string} listId List identifier.
44
98
  * @param {boolean} showToast Whether to show a confirmation toast after product was added
45
99
  * @returns {Object}
46
- */export var successAddFavorites=function successAddFavorites(productId,listId){var showToast=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return{type:SUCCESS_ADD_FAVORITES,productId:productId,listId:listId,showToast:showToast};};/**
100
+ */
101
+ export const successAddFavorites = (productId, listId, showToast = true) => ({
102
+ type: SUCCESS_ADD_FAVORITES,
103
+ productId,
104
+ listId,
105
+ showToast
106
+ });
107
+
108
+ /**
47
109
  * Action to be triggered upon a failed addFavorites pipeline call.
48
110
  * @param {string} productId Product identifier.
49
111
  * @param {Error} error The error that occurred.
50
112
  * @param {string} listId List identifier.
51
113
  * @returns {Object}
52
- */export var errorAddFavorites=function errorAddFavorites(productId,error,listId){return{type:ERROR_ADD_FAVORITES,productId:productId,listId:listId,error:error};};/**
114
+ */
115
+ export const errorAddFavorites = (productId, error, listId) => ({
116
+ type: ERROR_ADD_FAVORITES,
117
+ productId,
118
+ listId,
119
+ error
120
+ });
121
+
122
+ /**
53
123
  * Request update favorites action. This action just updates the redux store.
54
124
  * @param {string} productId Product identifier.
55
125
  * @param {string} listId List identifier.
56
126
  * @param {number} quantity The quantity of the product
57
127
  * @param {string} notes Notes about the product
58
128
  * @returns {Object}
59
- */export var requestUpdateFavorites=function requestUpdateFavorites(productId,listId,quantity,notes){return{type:REQUEST_UPDATE_FAVORITES,productId:productId,listId:listId,notes:notes,quantity:quantity};};/**
129
+ */
130
+ export const requestUpdateFavorites = (productId, listId, quantity, notes) => ({
131
+ type: REQUEST_UPDATE_FAVORITES,
132
+ productId,
133
+ listId,
134
+ notes,
135
+ quantity
136
+ });
137
+
138
+ /**
60
139
  * Action to be triggered upon successful updateFavorites pipeline call.
61
140
  * @param {string} productId Product identifier.
62
141
  * @param {string} listId List identifier.
63
142
  * @returns {Object}
64
- */export var successUpdateFavorites=function successUpdateFavorites(productId,listId){return{type:SUCCESS_UPDATE_FAVORITES,productId:productId,listId:listId};};/**
143
+ */
144
+ export const successUpdateFavorites = (productId, listId) => ({
145
+ type: SUCCESS_UPDATE_FAVORITES,
146
+ productId,
147
+ listId
148
+ });
149
+
150
+ /**
65
151
  * Action to be triggered upon failed updateFavorites pipeline call.
66
152
  * @param {string} productId Product identifier.
67
153
  * @param {string} listId List identifier.
68
154
  * @param {Error} error The error that occurred.
69
155
  * @returns {Object}
70
- */export var errorUpdateFavorites=function errorUpdateFavorites(productId,listId,error){return{type:ERROR_UPDATE_FAVORITES,productId:productId,listId:listId,error:error};};/**
156
+ */
157
+ export const errorUpdateFavorites = (productId, listId, error) => ({
158
+ type: ERROR_UPDATE_FAVORITES,
159
+ productId,
160
+ listId,
161
+ error
162
+ });
163
+
164
+ /**
71
165
  * Request remove favorites action. This action just updates the redux store.
72
166
  * @param {string} productId Product identifier.
73
167
  * @param {string} listId List identifier.
74
168
  * @returns {Object}
75
- */export var requestRemoveFavorites=function requestRemoveFavorites(productId,listId){return function(dispatch,getState){var getFavorites=makeGetFavorites(function(){return listId;});var favorites=getFavorites(getState());var matchingFavorite=favorites.find(function(_ref){var itemProductId=_ref.productId;return itemProductId===productId;})||{};return dispatch({type:REQUEST_REMOVE_FAVORITES,productId:productId,listId:listId,quantity:matchingFavorite.quantity||1,notes:matchingFavorite.notes||''});};};/**
169
+ */
170
+ export const requestRemoveFavorites = (productId, listId) => (dispatch, getState) => {
171
+ const getFavorites = makeGetFavorites(() => listId);
172
+ const favorites = getFavorites(getState());
173
+ const matchingFavorite = favorites.find(({
174
+ productId: itemProductId
175
+ }) => itemProductId === productId) || {};
176
+ return dispatch({
177
+ type: REQUEST_REMOVE_FAVORITES,
178
+ productId,
179
+ listId,
180
+ quantity: matchingFavorite.quantity || 1,
181
+ notes: matchingFavorite.notes || ''
182
+ });
183
+ };
184
+
185
+ /**
76
186
  * Action to be triggered upon successful removeFavorites (deleteFavorites) pipeline call.
77
187
  * @param {string} productId Product identifier.
78
188
  * @param {number} takenListId List id
79
189
  * @returns {Object}
80
- */export var successRemoveFavorites=function successRemoveFavorites(productId,takenListId){return{type:SUCCESS_REMOVE_FAVORITES,productId:productId,listId:takenListId};};/**
190
+ */
191
+ export const successRemoveFavorites = (productId, takenListId) => ({
192
+ type: SUCCESS_REMOVE_FAVORITES,
193
+ productId,
194
+ listId: takenListId
195
+ });
196
+
197
+ /**
81
198
  * Action to be triggered upon a failed removeFavorites (deleteFavorites) pipeline call.
82
199
  * @param {string} productId Product identifier.
83
200
  * @param {string} takenListId List id
@@ -85,43 +202,108 @@ import{ADD_PRODUCT_TO_FAVORITES,REMOVE_PRODUCT_FROM_FAVORITES,CANCEL_REQUEST_SYN
85
202
  * @param {number} quantity Quantity of the favorite
86
203
  * @param {string} notes Notes of the favorite
87
204
  * @returns {Object}
88
- */export var errorRemoveFavorites=function errorRemoveFavorites(productId,takenListId,error,quantity,notes){return{type:ERROR_REMOVE_FAVORITES,productId:productId,listId:takenListId,error:error,quantity:quantity,notes:notes};};/**
205
+ */
206
+ export const errorRemoveFavorites = (productId, takenListId, error, quantity, notes) => ({
207
+ type: ERROR_REMOVE_FAVORITES,
208
+ productId,
209
+ listId: takenListId,
210
+ error,
211
+ quantity,
212
+ notes
213
+ });
214
+
215
+ /**
89
216
  * Return the flush favorites buffer Now action object
90
217
  * @param {string} listId The Id of the wishlist.
91
218
  * @return {Object}
92
- */export var requestFlushFavoritesBuffer=function requestFlushFavoritesBuffer(listId){return{type:REQUEST_FLUSH_FAVORITES_BUFFER,listId:listId};};/**
219
+ */
220
+ export const requestFlushFavoritesBuffer = listId => ({
221
+ type: REQUEST_FLUSH_FAVORITES_BUFFER,
222
+ listId
223
+ });
224
+
225
+ /**
93
226
  * Idle sync action.
94
227
  * @param {string} listId The Id of the wishlist.
95
228
  * @returns {Object}
96
- */export var idleSyncFavorites=function idleSyncFavorites(listId){return{type:IDLE_SYNC_FAVORITES,listId:listId};};/**
229
+ */
230
+ export const idleSyncFavorites = listId => ({
231
+ type: IDLE_SYNC_FAVORITES,
232
+ listId
233
+ });
234
+
235
+ /**
97
236
  * Action to cancel one or multiple request to add or to remove favorites.
98
237
  * @param {number} [count=1] Optional count of sync requests.
99
238
  * @param {string} listId The Id of the wishlist.
100
239
  * @returns {Object}
101
- */export var cancelRequestSyncFavorites=function cancelRequestSyncFavorites(){var count=arguments.length>0&&arguments[0]!==undefined?arguments[0]:1;var listId=arguments.length>1?arguments[1]:undefined;return{type:CANCEL_REQUEST_SYNC_FAVORITES,count:count,listId:listId};};/**
240
+ */
241
+ export const cancelRequestSyncFavorites = (count = 1, listId) => ({
242
+ type: CANCEL_REQUEST_SYNC_FAVORITES,
243
+ count,
244
+ listId
245
+ });
246
+
247
+ /**
102
248
  * Receive favorites action.
103
249
  * @param {Array} items Wishlist items.
104
250
  * @param {number} requestTimestamp Time when request was initiated (ms).
105
251
  * @param {string} listId The Id of the wishlist.
106
252
  * @returns {Object}
107
- */export var receiveFavorites=function receiveFavorites(items,requestTimestamp){var listId=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return{type:RECEIVE_FAVORITES,items:items,requestTimestamp:requestTimestamp,listId:listId};};/**
253
+ */
254
+ export const receiveFavorites = (items, requestTimestamp, listId = null) => ({
255
+ type: RECEIVE_FAVORITES,
256
+ items,
257
+ requestTimestamp,
258
+ listId
259
+ });
260
+
261
+ /**
108
262
  * Request favorites action.
109
263
  * @param {string} listId The Id of the wishlist.
110
264
  * @returns {Object}
111
- */export var requestFavorites=function requestFavorites(){var listId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return{type:REQUEST_FAVORITES,listId:listId};};/**
265
+ */
266
+ export const requestFavorites = (listId = null) => ({
267
+ type: REQUEST_FAVORITES,
268
+ listId
269
+ });
270
+
271
+ /**
112
272
  * Opens the favorite list chooser.
113
273
  * @param {string} productId The Id of the product.
114
274
  * @param {boolean} withRelatives States, whether to remove all relative products or not.
115
275
  * @returns {Object}
116
- */export var openFavoritesListChooser=function openFavoritesListChooser(productId){var withRelatives=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;return{type:OPEN_FAVORITE_LIST_CHOOSER,productId:productId,withRelatives:withRelatives};};/**
276
+ */
277
+ export const openFavoritesListChooser = (productId, withRelatives = false) => ({
278
+ type: OPEN_FAVORITE_LIST_CHOOSER,
279
+ productId,
280
+ withRelatives
281
+ });
282
+
283
+ /**
117
284
  * Opens the favorite list chooser.
118
285
  * @returns {Object}
119
- */export var closeFavoritesListChooser=function closeFavoritesListChooser(){return{type:CLOSE_FAVORITE_LIST_CHOOSER};};/**
286
+ */
287
+ export const closeFavoritesListChooser = () => ({
288
+ type: CLOSE_FAVORITE_LIST_CHOOSER
289
+ });
290
+
291
+ /**
120
292
  * Opens the favorite comment sheet
121
293
  * @param {string} productId The id of the product.
122
294
  * @param {string} listId The id of the list.
123
295
  * @returns {Object}
124
- */export var openFavoritesCommentDialog=function openFavoritesCommentDialog(productId,listId){return{type:OPEN_FAVORITE_COMMENT_DIALOG,productId:productId,listId:listId};};/**
296
+ */
297
+ export const openFavoritesCommentDialog = (productId, listId) => ({
298
+ type: OPEN_FAVORITE_COMMENT_DIALOG,
299
+ productId,
300
+ listId
301
+ });
302
+
303
+ /**
125
304
  * Closes the favorite comment sheet
126
305
  * @returns {Object}
127
- */export var closeFavoritesCommentDialog=function closeFavoritesCommentDialog(){return{type:CLOSE_FAVORITE_COMMENT_DIALOG};};
306
+ */
307
+ export const closeFavoritesCommentDialog = () => ({
308
+ type: CLOSE_FAVORITE_COMMENT_DIALOG
309
+ });
@@ -1,4 +1,11 @@
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{getWishlistItemNotesEnabled,getWishlistItemQuantityEnabled}from'@shopgate/engage/core/selectors';import{SHOPGATE_USER_ADD_FAVORITES}from"../constants/Pipelines";import{successAddFavorites,errorAddFavorites}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 { getWishlistItemNotesEnabled, getWishlistItemQuantityEnabled } from '@shopgate/engage/core/selectors';
4
+ import { SHOPGATE_USER_ADD_FAVORITES } from "../constants/Pipelines";
5
+ import { successAddFavorites, errorAddFavorites } from "../action-creators";
6
+ import { getHasMultipleFavoritesListsSupport, getFavoritesDefaultList } from "../selectors";
7
+
8
+ /**
2
9
  * Adds a single product to the favorite list using the `addFavorites` pipeline.
3
10
  * @param {string} productId Id of the product to be added.
4
11
  * @param {string} listId Id of the list to be added.
@@ -6,5 +13,36 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){
6
13
  * @param {string} notes New favorites notes to set
7
14
  * @param {boolean} showToast Whether to show a confirmation toast after product was added
8
15
  * @returns {Function} A redux thunk.
9
- */function addFavorites(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;var showToast=arguments.length>4&&arguments[4]!==undefined?arguments[4]:true;return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var state,hasMultiSupport,quantityEnabled,notesEnabled,defaultList,takenListId,request;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:state=getState();hasMultiSupport=getHasMultipleFavoritesListsSupport(state);quantityEnabled=getWishlistItemQuantityEnabled(state);notesEnabled=getWishlistItemNotesEnabled(state);// Fallback for deprecated calls without list id.
10
- defaultList=getFavoritesDefaultList(state);takenListId=listId||defaultList.id;request=new PipelineRequest(SHOPGATE_USER_ADD_FAVORITES).setInput(_extends({productId:productId},hasMultiSupport?{favoritesListId:takenListId}:null,{},quantityEnabled&&quantity!==null?{quantity:quantity}:null,{},notesEnabled&&notes!==null?{notes:notes}:null)).setRetries(0).dispatch();_context.prev=7;_context.next=10;return request;case 10:dispatch(successAddFavorites(productId,takenListId,showToast));_context.next=16;break;case 13:_context.prev=13;_context.t0=_context["catch"](7);dispatch(errorAddFavorites(productId,_context.t0,takenListId));case 16:return _context.abrupt("return",request);case 17:case"end":return _context.stop();}},_callee,null,[[7,13]]);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());}export default mutable(addFavorites);
16
+ */
17
+ function addFavorites(productId, listId = null, quantity, notes, showToast = true) {
18
+ return async (dispatch, getState) => {
19
+ const state = getState();
20
+ const hasMultiSupport = getHasMultipleFavoritesListsSupport(state);
21
+ const quantityEnabled = getWishlistItemQuantityEnabled(state);
22
+ const notesEnabled = getWishlistItemNotesEnabled(state);
23
+
24
+ // Fallback for deprecated calls without list id.
25
+ const defaultList = getFavoritesDefaultList(state);
26
+ const takenListId = listId || defaultList.id;
27
+ const request = new PipelineRequest(SHOPGATE_USER_ADD_FAVORITES).setInput({
28
+ productId,
29
+ ...(hasMultiSupport ? {
30
+ favoritesListId: takenListId
31
+ } : null),
32
+ ...(quantityEnabled && quantity !== null ? {
33
+ quantity
34
+ } : null),
35
+ ...(notesEnabled && notes !== null ? {
36
+ notes
37
+ } : null)
38
+ }).setRetries(0).dispatch();
39
+ try {
40
+ await request;
41
+ dispatch(successAddFavorites(productId, takenListId, showToast));
42
+ } catch (error) {
43
+ dispatch(errorAddFavorites(productId, error, takenListId));
44
+ }
45
+ return request;
46
+ };
47
+ }
48
+ export default mutable(addFavorites);
@@ -1,5 +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_ADD_FAVORITES_LIST}from"../constants/Pipelines";import{SUCCESS_ADD_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_ADD_FAVORITES_LIST } from "../constants/Pipelines";
4
+ import { SUCCESS_ADD_FAVORITES_LIST } from "../constants";
5
+
6
+ /**
2
7
  * Adds a new favorite list.
3
8
  * @param {string} name Name of the wishlist.
4
9
  * @returns {Function} A redux thunk.
5
- */function addFavoritesList(name){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request,_ref3,id;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:request=new PipelineRequest(SHOPGATE_USER_ADD_FAVORITES_LIST).setInput({name:name}).setRetries(0).dispatch();_context.prev=1;_context.next=4;return request;case 4:_ref3=_context.sent;id=_ref3.id;dispatch({type:SUCCESS_ADD_FAVORITES_LIST,listId:id,name:name});_context.next=11;break;case 9:_context.prev=9;_context.t0=_context["catch"](1);case 11:case"end":return _context.stop();}},_callee,null,[[1,9]]);}));return function(_x){return _ref.apply(this,arguments);};}());}export default mutable(addFavoritesList);
10
+ */
11
+ function addFavoritesList(name) {
12
+ return async dispatch => {
13
+ const request = new PipelineRequest(SHOPGATE_USER_ADD_FAVORITES_LIST).setInput({
14
+ name
15
+ }).setRetries(0).dispatch();
16
+ try {
17
+ const {
18
+ id
19
+ } = await request;
20
+ dispatch({
21
+ type: SUCCESS_ADD_FAVORITES_LIST,
22
+ listId: id,
23
+ name
24
+ });
25
+ } catch (_) {
26
+ // Fail silently
27
+ }
28
+ };
29
+ }
30
+ export default mutable(addFavoritesList);
@@ -1,9 +1,53 @@
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 PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{EFAVORITE,EUNKNOWN}from'@shopgate/pwa-core/constants/Pipeline';import{shouldFetchData,mutable}from'@shopgate/pwa-common/helpers/redux';import{SHOPGATE_USER_GET_FAVORITE_IDS}from"../constants/Pipelines";import{receiveFavorites,requestFavorites,errorFetchFavorites}from"../action-creators";import{getHasMultipleFavoritesListsSupport,makeGetFavoritesProductsByList}from"../selectors";/**
1
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
2
+ import { EFAVORITE, EUNKNOWN } from '@shopgate/pwa-core/constants/Pipeline';
3
+ import { shouldFetchData, mutable } from '@shopgate/pwa-common/helpers/redux';
4
+ import { SHOPGATE_USER_GET_FAVORITE_IDS } from "../constants/Pipelines";
5
+ import { receiveFavorites, requestFavorites, errorFetchFavorites } from "../action-creators";
6
+ import { getHasMultipleFavoritesListsSupport, makeGetFavoritesProductsByList } from "../selectors";
7
+
8
+ /**
2
9
  * Fetch favorite IDs of a favorites list action.
3
10
  * @param {boolean} ignoreCache Ignores cache when true
4
11
  * @param {string} [favoritesListId] The ID of the favorites list
5
12
  * @returns {Function} A redux thunk.
6
- */function fetchFavoriteIds(){var ignoreCache=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var favoritesListId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'DEFAULT';return function(dispatch,getState){var hasMultiSupport=getHasMultipleFavoritesListsSupport(getState());var getFavoritesProductsByList=makeGetFavoritesProductsByList(function(){return favoritesListId;});var data=getFavoritesProductsByList(getState());if(!ignoreCache&&!shouldFetchData(data)){return Promise.resolve(data);}var timestamp=Date.now();dispatch(requestFavorites(favoritesListId));return new PipelineRequest(SHOPGATE_USER_GET_FAVORITE_IDS).setInput(_extends({},hasMultiSupport?{favoritesListId:favoritesListId}:null)).setErrorBlacklist([EFAVORITE,EUNKNOWN]).dispatch().then(function(_ref){var productIds=_ref.productIds;/**
7
- * Sanitize the pipeline return value to archive compatibility with the reducers for the
8
- * fetchFavorites pipeline.
9
- */var items=productIds.map(function(productId){return{product:{id:productId}};});var sanitizedResponse={items:items,itemCount:items.length};dispatch(receiveFavorites(sanitizedResponse.items,timestamp,favoritesListId));return sanitizedResponse;})["catch"](function(err){dispatch(errorFetchFavorites(err,favoritesListId));});};}/** @mixes {MutableFunction} */export default mutable(fetchFavoriteIds);
13
+ */
14
+ function fetchFavoriteIds(ignoreCache = false, favoritesListId = 'DEFAULT') {
15
+ return (dispatch, getState) => {
16
+ const hasMultiSupport = getHasMultipleFavoritesListsSupport(getState());
17
+ const getFavoritesProductsByList = makeGetFavoritesProductsByList(() => favoritesListId);
18
+ const data = getFavoritesProductsByList(getState());
19
+ if (!ignoreCache && !shouldFetchData(data)) {
20
+ return Promise.resolve(data);
21
+ }
22
+ const timestamp = Date.now();
23
+ dispatch(requestFavorites(favoritesListId));
24
+ return new PipelineRequest(SHOPGATE_USER_GET_FAVORITE_IDS).setInput({
25
+ ...(hasMultiSupport ? {
26
+ favoritesListId
27
+ } : null)
28
+ }).setErrorBlacklist([EFAVORITE, EUNKNOWN]).dispatch().then(({
29
+ productIds
30
+ }) => {
31
+ /**
32
+ * Sanitize the pipeline return value to archive compatibility with the reducers for the
33
+ * fetchFavorites pipeline.
34
+ */
35
+ const items = productIds.map(productId => ({
36
+ product: {
37
+ id: productId
38
+ }
39
+ }));
40
+ const sanitizedResponse = {
41
+ items,
42
+ itemCount: items.length
43
+ };
44
+ dispatch(receiveFavorites(sanitizedResponse.items, timestamp, favoritesListId));
45
+ return sanitizedResponse;
46
+ }).catch(err => {
47
+ dispatch(errorFetchFavorites(err, favoritesListId));
48
+ });
49
+ };
50
+ }
51
+
52
+ /** @mixes {MutableFunction} */
53
+ export default mutable(fetchFavoriteIds);
@@ -1,9 +1,64 @@
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 PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{EFAVORITE,EUNKNOWN,EBIGAPI,ELIMIT}from'@shopgate/pwa-core/constants/Pipeline';import{shouldFetchData,mutable}from'@shopgate/pwa-common/helpers/redux';import{hasNewServices}from'@shopgate/engage/core/helpers';import{SHOPGATE_USER_GET_FAVORITES}from"../constants/Pipelines";import{receiveFavorites,requestFavorites,errorFetchFavorites}from"../action-creators";import{getHasMultipleFavoritesListsSupport,makeGetFavoritesProductsByList,getFavoritesDefaultList}from"../selectors";import receiveProducts from"../../product/action-creators/receiveProducts";/**
1
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
2
+ import { EFAVORITE, EUNKNOWN, EBIGAPI, ELIMIT } from '@shopgate/pwa-core/constants/Pipeline';
3
+ import { shouldFetchData, mutable } from '@shopgate/pwa-common/helpers/redux';
4
+ import { hasNewServices } from '@shopgate/engage/core/helpers';
5
+ import { SHOPGATE_USER_GET_FAVORITES } from "../constants/Pipelines";
6
+ import { receiveFavorites, requestFavorites, errorFetchFavorites } from "../action-creators";
7
+ import { getHasMultipleFavoritesListsSupport, makeGetFavoritesProductsByList, getFavoritesDefaultList } from "../selectors";
8
+ import receiveProducts from "../../product/action-creators/receiveProducts";
9
+
10
+ /**
2
11
  * Fetch favorites action.
3
12
  * @param {boolean} ignoreCache Ignores cache when true
4
13
  * @param {string} listId The id of the list that needs to be fetched.
5
14
  * @returns {Function} A redux thunk.
6
- */function fetchFavorites(){var ignoreCache=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var listId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:undefined;return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var defaultList,takenListId,hasMultiSupport,getFavoritesProductsByList,data,timestamp,pipelineVersion,request,result;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:// Fallback for deprecated calls without list id.
7
- defaultList=getFavoritesDefaultList(getState());takenListId=listId||defaultList.code;hasMultiSupport=getHasMultipleFavoritesListsSupport(getState());getFavoritesProductsByList=makeGetFavoritesProductsByList(function(){return takenListId;});data=getFavoritesProductsByList(getState());if(!(!ignoreCache&&!shouldFetchData(data))){_context.next=7;break;}return _context.abrupt("return",null);case 7:timestamp=Date.now();dispatch(requestFavorites(takenListId));// v2 of the getFavorites pipeline doesn't exist right now within the old services
8
- pipelineVersion=hasNewServices()?2:1;request=new PipelineRequest(SHOPGATE_USER_GET_FAVORITES).setVersion(pipelineVersion).setInput(_extends({},hasMultiSupport?{favoritesListId:takenListId}:null)).setErrorBlacklist([EFAVORITE,EUNKNOWN,EBIGAPI,ELIMIT]).dispatch();_context.prev=11;_context.next=14;return request;case 14:result=_context.sent;if(pipelineVersion===1){// Convert response data based on the pipeline version
9
- result.items=((result===null||result===void 0?void 0:result.products)||[]).map(function(product){return{product:product,note:null,quantity:1};});delete result.products;}dispatch(receiveProducts({products:result.items.map(function(_ref2){var product=_ref2.product;return product;}),fetchInventory:false}));dispatch(receiveFavorites(result.items,timestamp,takenListId));return _context.abrupt("return",result);case 21:_context.prev=21;_context.t0=_context["catch"](11);dispatch(errorFetchFavorites(_context.t0,takenListId));return _context.abrupt("return",null);case 25:case"end":return _context.stop();}},_callee,null,[[11,21]]);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());}/** @mixes {MutableFunction} */export default mutable(fetchFavorites);
15
+ */
16
+ function fetchFavorites(ignoreCache = false, listId = undefined) {
17
+ return async (dispatch, getState) => {
18
+ // Fallback for deprecated calls without list id.
19
+ const defaultList = getFavoritesDefaultList(getState());
20
+ const takenListId = listId || defaultList.code;
21
+ const hasMultiSupport = getHasMultipleFavoritesListsSupport(getState());
22
+ const getFavoritesProductsByList = makeGetFavoritesProductsByList(() => takenListId);
23
+ const data = getFavoritesProductsByList(getState());
24
+ if (!ignoreCache && !shouldFetchData(data)) {
25
+ return null;
26
+ }
27
+ const timestamp = Date.now();
28
+ dispatch(requestFavorites(takenListId));
29
+
30
+ // v2 of the getFavorites pipeline doesn't exist right now within the old services
31
+ const pipelineVersion = hasNewServices() ? 2 : 1;
32
+ const request = new PipelineRequest(SHOPGATE_USER_GET_FAVORITES).setVersion(pipelineVersion).setInput({
33
+ ...(hasMultiSupport ? {
34
+ favoritesListId: takenListId
35
+ } : null)
36
+ }).setErrorBlacklist([EFAVORITE, EUNKNOWN, EBIGAPI, ELIMIT]).dispatch();
37
+ try {
38
+ const result = await request;
39
+ if (pipelineVersion === 1) {
40
+ // Convert response data based on the pipeline version
41
+ result.items = (result?.products || []).map(product => ({
42
+ product,
43
+ note: null,
44
+ quantity: 1
45
+ }));
46
+ delete result.products;
47
+ }
48
+ dispatch(receiveProducts({
49
+ products: result.items.map(({
50
+ product
51
+ }) => product),
52
+ fetchInventory: false
53
+ }));
54
+ dispatch(receiveFavorites(result.items, timestamp, takenListId));
55
+ return result;
56
+ } catch (err) {
57
+ dispatch(errorFetchFavorites(err, takenListId));
58
+ return null;
59
+ }
60
+ };
61
+ }
62
+
63
+ /** @mixes {MutableFunction} */
64
+ export default mutable(fetchFavorites);
@@ -1,9 +1,53 @@
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 PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{shouldFetchData,mutable}from'@shopgate/pwa-common/helpers/redux';import{getFavoritesListState,getHasMultipleFavoritesListsSupport}from"../selectors";import{SHOPGATE_USER_GET_FAVORITES_LIST}from"../constants/Pipelines";import{RECEIVE_FAVORITES_LISTS}from"../constants";/**
1
+ import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
2
+ import { shouldFetchData, mutable } from '@shopgate/pwa-common/helpers/redux';
3
+ import { getFavoritesListState, getHasMultipleFavoritesListsSupport } from "../selectors";
4
+ import { SHOPGATE_USER_GET_FAVORITES_LIST } from "../constants/Pipelines";
5
+ import { RECEIVE_FAVORITES_LISTS } from "../constants";
6
+
7
+ /**
2
8
  * Fetch favorites list action.
3
9
  * @param {boolean} ignoreCache Ignores cache when true
4
10
  * @returns {Function} A redux thunk.
5
- */function fetchFavoritesLists(){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 state,hasMultiSupport,favoritesLists,data,_ref3,_favoritesLists;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:state=getState();hasMultiSupport=getHasMultipleFavoritesListsSupport(state);if(hasMultiSupport){_context.next=6;break;}/**
11
+ */
12
+ function fetchFavoritesLists(ignoreCache = false) {
13
+ return async (dispatch, getState) => {
14
+ const state = getState();
15
+ const hasMultiSupport = getHasMultipleFavoritesListsSupport(state);
16
+ if (!hasMultiSupport) {
17
+ /**
6
18
  * If the doesn't have support for multiple favorite lists, we just mock the pipeline response
7
19
  * and don't dispatch the request. So we can keep backwards compatibility with older
8
20
  * extensions that don't support the pipeline.
9
- */favoritesLists=[{id:'DEFAULT',name:''}];dispatch({type:RECEIVE_FAVORITES_LISTS,favoritesLists:favoritesLists});return _context.abrupt("return",favoritesLists);case 6:data=getFavoritesListState(state);if(!(!ignoreCache&&!shouldFetchData(data))){_context.next=9;break;}return _context.abrupt("return",(data===null||data===void 0?void 0:data.lists)||[]);case 9:_context.prev=9;_context.next=12;return new PipelineRequest(SHOPGATE_USER_GET_FAVORITES_LIST).dispatch();case 12:_ref3=_context.sent;_favoritesLists=_ref3.favoritesLists;dispatch({type:RECEIVE_FAVORITES_LISTS,favoritesLists:_favoritesLists});return _context.abrupt("return",_favoritesLists);case 18:_context.prev=18;_context.t0=_context["catch"](9);return _context.abrupt("return",[]);case 21:case"end":return _context.stop();}},_callee,null,[[9,18]]);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());}/** @mixes {MutableFunction} */export default mutable(fetchFavoritesLists);
21
+ */
22
+ const favoritesLists = [{
23
+ id: 'DEFAULT',
24
+ name: ''
25
+ }];
26
+ dispatch({
27
+ type: RECEIVE_FAVORITES_LISTS,
28
+ favoritesLists
29
+ });
30
+ return favoritesLists;
31
+ }
32
+ const data = getFavoritesListState(state);
33
+ if (!ignoreCache && !shouldFetchData(data)) {
34
+ return data?.lists || [];
35
+ }
36
+ try {
37
+ const {
38
+ favoritesLists
39
+ } = await new PipelineRequest(SHOPGATE_USER_GET_FAVORITES_LIST).dispatch();
40
+ dispatch({
41
+ type: RECEIVE_FAVORITES_LISTS,
42
+ favoritesLists
43
+ });
44
+ return favoritesLists;
45
+ } catch (err) {
46
+ // Fail silently
47
+ return [];
48
+ }
49
+ };
50
+ }
51
+
52
+ /** @mixes {MutableFunction} */
53
+ export default mutable(fetchFavoritesLists);