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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/cart/action-creators/addCouponsToCart.js +9 -2
  2. package/cart/action-creators/addProductsToCart.js +9 -2
  3. package/cart/action-creators/deleteCouponsFromCart.js +9 -2
  4. package/cart/action-creators/deleteProductsFromCart.js +9 -2
  5. package/cart/action-creators/errorAddCouponsToCart.js +10 -2
  6. package/cart/action-creators/errorAddProductsToCart.js +10 -2
  7. package/cart/action-creators/errorCart.js +8 -2
  8. package/cart/action-creators/errorDeleteCouponsFromCart.js +10 -2
  9. package/cart/action-creators/errorDeleteProductsFromCart.js +10 -2
  10. package/cart/action-creators/errorUpdateProductsInCart.js +10 -2
  11. package/cart/action-creators/receiveCart.js +9 -2
  12. package/cart/action-creators/requestCart.js +8 -2
  13. package/cart/action-creators/setCartProductPendingCount.js +9 -2
  14. package/cart/action-creators/setCouponFieldError.js +9 -2
  15. package/cart/action-creators/setCouponFieldValue.js +9 -2
  16. package/cart/action-creators/setFulfillmentSlot.js +9 -2
  17. package/cart/action-creators/successAddCouponsToCart.js +10 -2
  18. package/cart/action-creators/successAddProductsToCart.js +8 -2
  19. package/cart/action-creators/successDeleteCouponsFromCart.js +8 -2
  20. package/cart/action-creators/successDeleteProductsFromCart.js +8 -2
  21. package/cart/action-creators/successUpdateProductsInCart.js +8 -2
  22. package/cart/action-creators/updateProductsInCart.js +9 -2
  23. package/cart/actions/addCouponsToCart.js +52 -8
  24. package/cart/actions/addProductsToCart.js +80 -11
  25. package/cart/actions/deleteCouponsFromCart.js +39 -6
  26. package/cart/actions/deleteProductsFromCart.js +38 -6
  27. package/cart/actions/fetchCart.js +52 -8
  28. package/cart/actions/updateProductsInCart.js +44 -6
  29. package/cart/constants/PipelineErrors.js +6 -1
  30. package/cart/constants/Pipelines.js +6 -1
  31. package/cart/constants/Portals.js +85 -1
  32. package/cart/constants/index.js +39 -2
  33. package/cart/helpers/config.js +47 -2
  34. package/cart/helpers/createPipelineErrorList.js +30 -4
  35. package/cart/helpers/fulfillmentSlots.js +37 -4
  36. package/cart/helpers/index.js +14 -3
  37. package/cart/helpers/quantity.js +23 -4
  38. package/cart/helpers/shipping.js +57 -2
  39. package/cart/helpers/tax.js +26 -2
  40. package/cart/index.js +25 -5
  41. package/cart/mock.js +130 -1
  42. package/cart/reducers/couponField.js +30 -2
  43. package/cart/reducers/data.js +98 -6
  44. package/cart/reducers/index.js +7 -1
  45. package/cart/selectors/index.js +181 -31
  46. package/cart/selectors/spec.js +189 -2
  47. package/cart/streams/index.js +176 -29
  48. package/cart/subscriptions/index.js +307 -30
  49. package/category/action-creators/errorCategory.js +10 -2
  50. package/category/action-creators/errorCategoryChildren.js +9 -2
  51. package/category/action-creators/errorRootCategories.js +8 -2
  52. package/category/action-creators/receiveCategory.js +12 -2
  53. package/category/action-creators/receiveCategoryChildren.js +10 -2
  54. package/category/action-creators/receiveRootCategories.js +9 -2
  55. package/category/action-creators/requestCategory.js +9 -2
  56. package/category/action-creators/requestCategoryChildren.js +9 -2
  57. package/category/action-creators/requestRootCategories.js +8 -2
  58. package/category/actions/fetchCategory.js +47 -5
  59. package/category/actions/fetchCategoryChildren.js +30 -2
  60. package/category/actions/fetchCategoryOrRootCategories.js +16 -2
  61. package/category/actions/fetchCategoryProducts.js +36 -2
  62. package/category/actions/fetchRootCategories.js +31 -2
  63. package/category/actions/getCategory.js +10 -2
  64. package/category/constants/Pipelines.js +3 -1
  65. package/category/constants/Portals.js +56 -3
  66. package/category/constants/index.js +17 -2
  67. package/category/helpers/index.js +27 -3
  68. package/category/index.js +19 -5
  69. package/category/mock.js +176 -1
  70. package/category/reducers/categoriesById.js +65 -3
  71. package/category/reducers/childrenByCategoryId.js +55 -4
  72. package/category/reducers/helpers/handleCategoryCollection.js +24 -3
  73. package/category/reducers/helpers/handleReceivedCategories.js +3 -1
  74. package/category/reducers/index.js +12 -2
  75. package/category/reducers/rootCategories.js +31 -2
  76. package/category/selectors/index.js +115 -16
  77. package/category/streams/index.js +82 -4
  78. package/category/subscriptions/index.js +96 -3
  79. package/checkout/action-creators/successCheckout.js +9 -2
  80. package/checkout/actions/fetchCheckoutUrl.js +28 -3
  81. package/checkout/constants/Pipelines.js +1 -1
  82. package/checkout/constants/index.js +3 -2
  83. package/checkout/index.js +11 -4
  84. package/checkout/selectors/index.js +7 -2
  85. package/checkout/streams/index.js +8 -2
  86. package/checkout/subscriptions/index.js +35 -6
  87. package/favorites/action-creators/index.js +206 -24
  88. package/favorites/actions/addFavorites.js +41 -3
  89. package/favorites/actions/addFavoritesList.js +27 -2
  90. package/favorites/actions/fetchFavoriteIds.js +49 -5
  91. package/favorites/actions/fetchFavorites.js +60 -5
  92. package/favorites/actions/fetchFavoritesList.js +47 -3
  93. package/favorites/actions/fetchFavoritesListsWithItems.js +32 -3
  94. package/favorites/actions/getFavorites.js +6 -2
  95. package/favorites/actions/removeFavorites.js +32 -3
  96. package/favorites/actions/removeFavoritesList.js +24 -2
  97. package/favorites/actions/toggleFavorites.js +68 -10
  98. package/favorites/actions/updateFavorites.js +39 -3
  99. package/favorites/actions/updateFavoritesList.js +26 -2
  100. package/favorites/constants/Pipelines.js +9 -1
  101. package/favorites/constants/Portals.js +32 -4
  102. package/favorites/constants/index.js +37 -5
  103. package/favorites/index.js +14 -4
  104. package/favorites/mock.js +89 -4
  105. package/favorites/reducers/index.js +7 -1
  106. package/favorites/reducers/lists.js +74 -2
  107. package/favorites/reducers/products.js +231 -24
  108. package/favorites/selectors/index.js +188 -24
  109. package/favorites/streams/index.js +135 -23
  110. package/favorites/streams/spec.js +517 -8
  111. package/favorites/subscriptions/index.js +260 -25
  112. package/favorites/subscriptions/spec.js +701 -28
  113. package/filter/action-creators/errorFilters.js +9 -2
  114. package/filter/action-creators/index.js +4 -1
  115. package/filter/action-creators/receiveFilters.js +10 -2
  116. package/filter/action-creators/requestFilters.js +9 -2
  117. package/filter/action-creators/updateFilters.js +8 -2
  118. package/filter/actions/fetchFilters.js +46 -3
  119. package/filter/actions/getFilters.js +6 -2
  120. package/filter/actions/helpers/buildFilterParams.js +34 -2
  121. package/filter/actions/helpers/buildRequestFilters.js +35 -2
  122. package/filter/actions/helpers/processFilters.js +10 -2
  123. package/filter/actions/helpers/processParams.js +26 -2
  124. package/filter/constants/Pipelines.js +1 -1
  125. package/filter/constants/Portals.js +39 -3
  126. package/filter/constants/index.js +8 -1
  127. package/filter/index.js +12 -4
  128. package/filter/reducers/helpers/enrichFilters.js +11 -3
  129. package/filter/reducers/index.js +5 -1
  130. package/filter/reducers/resultsByHash.js +43 -3
  131. package/filter/selectors/index.js +47 -6
  132. package/filter/streams/index.js +30 -1
  133. package/filter/subscriptions/index.js +34 -2
  134. package/market/constants/Portals.js +22 -4
  135. package/market/constants/index.js +2 -1
  136. package/market/helpers/showReturnPolicy.js +3 -1
  137. package/market/helpers/showTaxDisclaimer.js +3 -1
  138. package/market/index.js +6 -2
  139. package/orders/constants.js +2 -1
  140. package/package.json +3 -3
  141. package/product/action-creators/deleteProductsByIds.js +10 -2
  142. package/product/action-creators/errorProduct.js +10 -2
  143. package/product/action-creators/errorProductDescription.js +10 -2
  144. package/product/action-creators/errorProductImages.js +10 -2
  145. package/product/action-creators/errorProductMedia.js +10 -2
  146. package/product/action-creators/errorProductOptions.js +10 -2
  147. package/product/action-creators/errorProductProperties.js +10 -2
  148. package/product/action-creators/errorProductRelations.js +9 -2
  149. package/product/action-creators/errorProductShipping.js +10 -2
  150. package/product/action-creators/errorProductVariants.js +10 -2
  151. package/product/action-creators/errorProducts.js +9 -2
  152. package/product/action-creators/expireProductById.js +10 -2
  153. package/product/action-creators/expireProductData.js +11 -2
  154. package/product/action-creators/expireProductsByHash.js +9 -2
  155. package/product/action-creators/productNotAvailable.js +10 -2
  156. package/product/action-creators/provideProduct.js +9 -2
  157. package/product/action-creators/receiveProduct.js +10 -2
  158. package/product/action-creators/receiveProductCached.js +9 -2
  159. package/product/action-creators/receiveProductDescription.js +10 -2
  160. package/product/action-creators/receiveProductImages.js +10 -2
  161. package/product/action-creators/receiveProductMedia.js +10 -2
  162. package/product/action-creators/receiveProductOptions.js +10 -2
  163. package/product/action-creators/receiveProductProperties.js +10 -2
  164. package/product/action-creators/receiveProductRelations.js +12 -2
  165. package/product/action-creators/receiveProductShipping.js +10 -2
  166. package/product/action-creators/receiveProductVariants.js +10 -2
  167. package/product/action-creators/receiveProducts.js +16 -2
  168. package/product/action-creators/receiveProductsCached.js +9 -2
  169. package/product/action-creators/refreshExpiredPDPData.js +8 -2
  170. package/product/action-creators/requestProduct.js +10 -2
  171. package/product/action-creators/requestProductDescription.js +9 -2
  172. package/product/action-creators/requestProductImages.js +9 -2
  173. package/product/action-creators/requestProductMedia.js +9 -2
  174. package/product/action-creators/requestProductOptions.js +9 -2
  175. package/product/action-creators/requestProductProperties.js +9 -2
  176. package/product/action-creators/requestProductRelations.js +10 -2
  177. package/product/action-creators/requestProductShipping.js +9 -2
  178. package/product/action-creators/requestProductVariants.js +9 -2
  179. package/product/action-creators/requestProducts.js +9 -2
  180. package/product/action-creators/setProductId.js +9 -2
  181. package/product/action-creators/setProductQuantity.js +9 -2
  182. package/product/action-creators/setProductVariantId.js +9 -2
  183. package/product/actions/changeSortOrder.js +21 -2
  184. package/product/actions/fetchHighlightProducts.js +18 -2
  185. package/product/actions/fetchLiveshoppingProducts.js +14 -2
  186. package/product/actions/fetchProduct.js +52 -3
  187. package/product/actions/fetchProductDescription.js +30 -2
  188. package/product/actions/fetchProductImages.js +31 -2
  189. package/product/actions/fetchProductMedia.js +35 -2
  190. package/product/actions/fetchProductOptions.js +31 -2
  191. package/product/actions/fetchProductProperties.js +30 -2
  192. package/product/actions/fetchProductRelations.js +63 -2
  193. package/product/actions/fetchProductShipping.js +31 -2
  194. package/product/actions/fetchProductVariants.js +31 -2
  195. package/product/actions/fetchProducts.js +189 -17
  196. package/product/actions/fetchProductsById.js +68 -8
  197. package/product/actions/fetchProductsByQuery.js +102 -18
  198. package/product/actions/getHighlightProducts.js +6 -2
  199. package/product/actions/getLiveshoppingProducts.js +6 -2
  200. package/product/actions/getProduct.js +6 -2
  201. package/product/actions/getProductDescription.js +6 -2
  202. package/product/actions/getProductImages.js +6 -2
  203. package/product/actions/getProductOptions.js +6 -2
  204. package/product/actions/getProductProperties.js +6 -2
  205. package/product/actions/getProductRelations.js +6 -2
  206. package/product/actions/getProductShipping.js +6 -2
  207. package/product/actions/getProductVariants.js +6 -2
  208. package/product/actions/getProducts.js +6 -2
  209. package/product/actions/getProductsById.js +6 -2
  210. package/product/actions/getProductsByQuery.js +6 -2
  211. package/product/actions/processProductFlags.js +35 -3
  212. package/product/actions/updateMetadata.js +17 -2
  213. package/product/collections/ProductImageFormats.js +48 -8
  214. package/product/collections/index.js +1 -1
  215. package/product/constants/Pipelines.js +12 -1
  216. package/product/constants/Portals.js +200 -33
  217. package/product/constants/index.js +90 -18
  218. package/product/helpers/index.js +61 -8
  219. package/product/index.js +36 -6
  220. package/product/mock.js +1002 -2
  221. package/product/reducers/descriptionsByProductId.js +54 -5
  222. package/product/reducers/helpers/formatOptions.js +17 -2
  223. package/product/reducers/helpers/handleProductCollection.js +19 -2
  224. package/product/reducers/imagesByProductId.js +51 -4
  225. package/product/reducers/index.js +23 -1
  226. package/product/reducers/mediaByProductId.js +55 -3
  227. package/product/reducers/optionsByProductId.js +41 -2
  228. package/product/reducers/productRelationsByHash.js +43 -2
  229. package/product/reducers/productsById.js +122 -7
  230. package/product/reducers/propertiesByProductId.js +48 -2
  231. package/product/reducers/resultsByHash.js +125 -9
  232. package/product/reducers/shippingByProductId.js +37 -2
  233. package/product/reducers/variantsByProductId.js +56 -2
  234. package/product/selectors/options.js +90 -13
  235. package/product/selectors/page.js +62 -13
  236. package/product/selectors/price.js +81 -18
  237. package/product/selectors/product.js +549 -59
  238. package/product/selectors/product.mock.js +327 -12
  239. package/product/selectors/relations.js +35 -5
  240. package/product/selectors/variants.js +91 -15
  241. package/product/streams/index.js +167 -13
  242. package/product/subscriptions/index.js +210 -4
  243. package/reviews/action-creators/errorProductReviews.js +9 -2
  244. package/reviews/action-creators/errorReviews.js +9 -2
  245. package/reviews/action-creators/errorSubmitReview.js +9 -2
  246. package/reviews/action-creators/errorUserReview.js +9 -2
  247. package/reviews/action-creators/flushUserReview.js +8 -2
  248. package/reviews/action-creators/receiveProductReviews.js +11 -2
  249. package/reviews/action-creators/receiveReviews.js +12 -2
  250. package/reviews/action-creators/receiveSubmitReview.js +9 -2
  251. package/reviews/action-creators/receiveUserReview.js +10 -2
  252. package/reviews/action-creators/requestProductReviews.js +10 -2
  253. package/reviews/action-creators/requestReviews.js +9 -2
  254. package/reviews/action-creators/requestSubmitReview.js +9 -2
  255. package/reviews/action-creators/requestUserReview.js +9 -2
  256. package/reviews/action-creators/resetSubmittedReview.js +9 -2
  257. package/reviews/action-creators/spec.js +40 -1
  258. package/reviews/actions/fetchProductReviews.js +37 -2
  259. package/reviews/actions/fetchReviews.js +38 -2
  260. package/reviews/actions/fetchUserReview.js +31 -2
  261. package/reviews/actions/flushUserReview.js +5 -1
  262. package/reviews/actions/getProductReviews.js +6 -2
  263. package/reviews/actions/getUserReview.js +6 -2
  264. package/reviews/actions/spec.js +241 -4
  265. package/reviews/actions/submitReview.js +63 -3
  266. package/reviews/constants/Pipelines.js +4 -1
  267. package/reviews/constants/Portals.js +4 -1
  268. package/reviews/constants/index.js +26 -7
  269. package/reviews/index.js +15 -4
  270. package/reviews/mock.js +172 -11
  271. package/reviews/reducers/index.js +11 -1
  272. package/reviews/reducers/mock.js +14 -2
  273. package/reviews/reducers/reviewsByHash.js +52 -6
  274. package/reviews/reducers/reviewsById.js +27 -2
  275. package/reviews/reducers/reviewsByProductId.js +47 -2
  276. package/reviews/reducers/spec.js +211 -2
  277. package/reviews/reducers/userReviewsByProductId.js +68 -2
  278. package/reviews/selectors/index.js +123 -19
  279. package/reviews/selectors/mock.js +100 -1
  280. package/reviews/selectors/spec.js +100 -1
  281. package/reviews/streams/index.js +37 -5
  282. package/reviews/streams/spec.js +25 -1
  283. package/reviews/subscriptions/index.js +27 -2
  284. package/scanner/action-creators/errorHandleScanner.js +11 -2
  285. package/scanner/action-creators/scannerFinished.js +11 -2
  286. package/scanner/action-creators/startScanner.js +8 -2
  287. package/scanner/action-creators/successHandleScanner.js +11 -2
  288. package/scanner/actions/handleBarCode.js +22 -2
  289. package/scanner/actions/handleNoResults.js +23 -2
  290. package/scanner/actions/handleQrCode.js +116 -6
  291. package/scanner/actions/handleSearch.js +33 -2
  292. package/scanner/constants/Portals.js +22 -1
  293. package/scanner/constants/index.js +17 -1
  294. package/scanner/helpers/index.js +115 -5
  295. package/scanner/index.js +19 -5
  296. package/scanner/streams/index.js +36 -1
  297. package/scanner/subscriptions/index.js +78 -8
  298. package/search/action-creators/errorSearchResults.js +10 -2
  299. package/search/action-creators/receiveSearchResults.js +11 -2
  300. package/search/action-creators/receiveSearchSuggestions.js +10 -2
  301. package/search/action-creators/requestSearchResults.js +10 -2
  302. package/search/action-creators/requestSearchSuggestions.js +9 -2
  303. package/search/actions/fetchSearchResults.js +66 -8
  304. package/search/actions/fetchSearchSuggestions.js +36 -2
  305. package/search/constants/Pipelines.js +1 -1
  306. package/search/constants/Portals.js +9 -2
  307. package/search/constants/index.js +10 -2
  308. package/search/helpers/index.js +5 -2
  309. package/search/helpers/removeHighlightingPlaceholders.js +4 -1
  310. package/search/helpers/spec.js +19 -1
  311. package/search/index.js +17 -5
  312. package/search/reducers/index.js +38 -2
  313. package/search/selectors/index.js +23 -4
  314. package/search/streams/index.js +51 -3
  315. package/search/subscriptions/index.js +132 -5
@@ -1,24 +1,178 @@
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 _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import'rxjs/add/operator/switchMap';import'rxjs/add/observable/of';import{Observable}from'rxjs/Observable';import{ENOTFOUND}from'@shopgate/pwa-core';import{main$}from'@shopgate/pwa-common/streams/main';import{routeWillEnter$,routeWillLeave$,routeDidUpdate$}from'@shopgate/pwa-common/streams/router';import{pwaDidAppear$}from'@shopgate/pwa-common/streams';import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import{hex2bin}from'@shopgate/pwa-common/helpers/data';import{getBaseProduct}from"../selectors/product";import{ITEM_PATTERN,ITEM_GALLERY_PATTERN,RECEIVE_PRODUCT,RECEIVE_PRODUCT_CACHED,RECEIVE_PRODUCT_RELATIONS,ERROR_PRODUCT,ERROR_PRODUCT_DESCRIPTION,ERROR_PRODUCT_IMAGES,ERROR_PRODUCT_VARIANTS,ERROR_PRODUCT_PROPERTIES,ERROR_PRODUCT_OPTIONS,ERROR_PRODUCT_SHIPPING,PRODUCT_NOT_AVAILABLE,RECEIVE_PRODUCTS_CACHED,RECEIVE_PRODUCTS,PROVIDE_PRODUCT_BUFFER_TIME,PROVIDE_PRODUCT,EXPIRE_PRODUCT_DATA,REFRESH_EXPIRED_PDP_DATA}from"../constants";/**
1
+ import 'rxjs/add/operator/switchMap';
2
+ import 'rxjs/add/observable/of';
3
+ import { Observable } from 'rxjs/Observable';
4
+ import { ENOTFOUND } from '@shopgate/pwa-core';
5
+ import { main$ } from '@shopgate/pwa-common/streams/main';
6
+ import { routeWillEnter$, routeWillLeave$, routeDidUpdate$ } from '@shopgate/pwa-common/streams/router';
7
+ import { pwaDidAppear$ } from '@shopgate/pwa-common/streams';
8
+ import { getCurrentRoute } from '@shopgate/pwa-common/selectors/router';
9
+ import { hex2bin } from '@shopgate/pwa-common/helpers/data';
10
+ import { getBaseProduct } from "../selectors/product";
11
+ import { ITEM_PATTERN, ITEM_GALLERY_PATTERN, RECEIVE_PRODUCT, RECEIVE_PRODUCT_CACHED, RECEIVE_PRODUCT_RELATIONS, ERROR_PRODUCT, ERROR_PRODUCT_DESCRIPTION, ERROR_PRODUCT_IMAGES, ERROR_PRODUCT_VARIANTS, ERROR_PRODUCT_PROPERTIES, ERROR_PRODUCT_OPTIONS, ERROR_PRODUCT_SHIPPING, PRODUCT_NOT_AVAILABLE, RECEIVE_PRODUCTS_CACHED, RECEIVE_PRODUCTS, PROVIDE_PRODUCT_BUFFER_TIME, PROVIDE_PRODUCT, EXPIRE_PRODUCT_DATA, REFRESH_EXPIRED_PDP_DATA } from "../constants";
12
+
13
+ /**
2
14
  * Emits when the category route comes active again after a legacy page was active.
3
- */export var productRouteReappeared$=pwaDidAppear$.filter(function(_ref){var action=_ref.action;return action.route.pattern===ITEM_PATTERN;});export var productWillEnter$=routeWillEnter$.merge(routeDidUpdate$).filter(function(_ref2){var action=_ref2.action;return action.route.pattern===ITEM_PATTERN;});export var variantWillUpdate$=routeDidUpdate$.filter(function(_ref3){var action=_ref3.action;return action.route.pattern===ITEM_PATTERN;});export var galleryWillEnter$=routeWillEnter$.filter(function(_ref4){var action=_ref4.action;return action.route.pattern===ITEM_GALLERY_PATTERN;});export var galleryWillLeave$=routeWillLeave$.filter(function(_ref5){var action=_ref5.action;return action.route.pattern===ITEM_GALLERY_PATTERN;});export var productReceived$=main$.filter(function(_ref6){var action=_ref6.action;return action.type===RECEIVE_PRODUCT;}).distinctUntilChanged();/** Dispatched when ERROR_PRODUCT received */export var errorProduct$=main$.filter(function(_ref7){var action=_ref7.action;return action.type===ERROR_PRODUCT;});/** Dispatched when ERROR_PRODUCT_* (resources) is received */export var errorProductResources$=main$.filter(function(_ref8){var action=_ref8.action;return[ERROR_PRODUCT_DESCRIPTION,ERROR_PRODUCT_IMAGES,ERROR_PRODUCT_VARIANTS,ERROR_PRODUCT_PROPERTIES,ERROR_PRODUCT_OPTIONS,ERROR_PRODUCT_SHIPPING].includes(action.type);});/** Dispatched when ERROR_PRODUCT ENOTFOUND received */export var errorProductNotFound$=errorProduct$.filter(function(_ref9){var action=_ref9.action;return action.errorCode===ENOTFOUND;});/** Dispatched when ERROR_PRODUCT_* ENOTFOUND received */export var errorProductResourcesNotFound$=errorProductResources$.filter(function(_ref10){var action=_ref10.action;return action.errorCode===ENOTFOUND;});export var cachedProductReceived$=main$.filter(function(_ref11){var action=_ref11.action;return action.type===RECEIVE_PRODUCT_CACHED;}).distinctUntilChanged();export var receivedVisibleProduct$=productReceived$.merge(cachedProductReceived$).filter(function(_ref12){var action=_ref12.action,getState=_ref12.getState;var route=getCurrentRoute(getState());if(typeof action.productData==='undefined'||typeof action.productData.id==='undefined'){return false;}if(!route.params.productId&&!route.state.productId){return false;}if(route.state.productId){return action.productData.id===route.state.productId;}return action.productData.id===hex2bin(route.params.productId);});/**
15
+ */
16
+ export const productRouteReappeared$ = pwaDidAppear$.filter(({
17
+ action
18
+ }) => action.route.pattern === ITEM_PATTERN);
19
+ export const productWillEnter$ = routeWillEnter$.merge(routeDidUpdate$).filter(({
20
+ action
21
+ }) => action.route.pattern === ITEM_PATTERN);
22
+ export const variantWillUpdate$ = routeDidUpdate$.filter(({
23
+ action
24
+ }) => action.route.pattern === ITEM_PATTERN);
25
+ export const galleryWillEnter$ = routeWillEnter$.filter(({
26
+ action
27
+ }) => action.route.pattern === ITEM_GALLERY_PATTERN);
28
+ export const galleryWillLeave$ = routeWillLeave$.filter(({
29
+ action
30
+ }) => action.route.pattern === ITEM_GALLERY_PATTERN);
31
+ export const productReceived$ = main$.filter(({
32
+ action
33
+ }) => action.type === RECEIVE_PRODUCT).distinctUntilChanged();
34
+
35
+ /** Dispatched when ERROR_PRODUCT received */
36
+ export const errorProduct$ = main$.filter(({
37
+ action
38
+ }) => action.type === ERROR_PRODUCT);
39
+
40
+ /** Dispatched when ERROR_PRODUCT_* (resources) is received */
41
+ export const errorProductResources$ = main$.filter(({
42
+ action
43
+ }) => [ERROR_PRODUCT_DESCRIPTION, ERROR_PRODUCT_IMAGES, ERROR_PRODUCT_VARIANTS, ERROR_PRODUCT_PROPERTIES, ERROR_PRODUCT_OPTIONS, ERROR_PRODUCT_SHIPPING].includes(action.type));
44
+
45
+ /** Dispatched when ERROR_PRODUCT ENOTFOUND received */
46
+ export const errorProductNotFound$ = errorProduct$.filter(({
47
+ action
48
+ }) => action.errorCode === ENOTFOUND);
49
+
50
+ /** Dispatched when ERROR_PRODUCT_* ENOTFOUND received */
51
+ export const errorProductResourcesNotFound$ = errorProductResources$.filter(({
52
+ action
53
+ }) => action.errorCode === ENOTFOUND);
54
+ export const cachedProductReceived$ = main$.filter(({
55
+ action
56
+ }) => action.type === RECEIVE_PRODUCT_CACHED).distinctUntilChanged();
57
+ export const receivedVisibleProduct$ = productReceived$.merge(cachedProductReceived$).filter(({
58
+ action,
59
+ getState
60
+ }) => {
61
+ const route = getCurrentRoute(getState());
62
+ if (typeof action.productData === 'undefined' || typeof action.productData.id === 'undefined') {
63
+ return false;
64
+ }
65
+ if (!route.params.productId && !route.state.productId) {
66
+ return false;
67
+ }
68
+ if (route.state.productId) {
69
+ return action.productData.id === route.state.productId;
70
+ }
71
+ return action.productData.id === hex2bin(route.params.productId);
72
+ });
73
+
74
+ /**
4
75
  * Emits when a product page was initially opened and its data is present.
5
- */export var productIsReady$=productWillEnter$// Take care that the stream only emits when underlying streams emit within the correct order.
6
- .switchMap(function(){return receivedVisibleProduct$.first();}).merge(productRouteReappeared$);/** Dispatched when ERROR_PRODUCT ENOTFOUND of visible product is received */export var visibleProductNotFound$=errorProductNotFound$.withLatestFrom(routeWillEnter$).filter(function(_ref13){var _ref14=_slicedToArray(_ref13,2),errorAction=_ref14[0],routeAction=_ref14[1];return routeAction.action.route.pattern===ITEM_PATTERN&&errorAction.action.productId===hex2bin(routeAction.action.route.params.productId);}).map(function(_ref15){var _ref16=_slicedToArray(_ref15,1),errorAction=_ref16[0];return errorAction;});export var variantDidChange$=variantWillUpdate$// Take care that the stream only emits when underlying streams emit within the correct order.
7
- .switchMap(function(){return receivedVisibleProduct$.first().switchMap(function(data){var _data$action$productD=data.action.productData,id=_data$action$productD.id,baseProductId=_data$action$productD.baseProductId;var variantId=baseProductId!==null?id:null;var baseProduct=getBaseProduct(data.getState(),{variantId:variantId});if(baseProduct===null){/**
8
- * A PDP with a variant product was opened, but the base product is not fetched yet.
9
- * So emitting of the stream is postponed till the data is present.
10
- */return productReceived$;}return Observable.of(data);});});export var productRelationsReceived$=main$.filter(function(_ref17){var action=_ref17.action;return action.type===RECEIVE_PRODUCT_RELATIONS;});export var productNotAvailable$=main$.filter(function(_ref18){var action=_ref18.action;return action.type===PRODUCT_NOT_AVAILABLE;});/**
76
+ */
77
+ export const productIsReady$ = productWillEnter$
78
+ // Take care that the stream only emits when underlying streams emit within the correct order.
79
+ .switchMap(() => receivedVisibleProduct$.first()).merge(productRouteReappeared$);
80
+
81
+ /** Dispatched when ERROR_PRODUCT ENOTFOUND of visible product is received */
82
+ export const visibleProductNotFound$ = errorProductNotFound$.withLatestFrom(routeWillEnter$).filter(([errorAction, routeAction]) => routeAction.action.route.pattern === ITEM_PATTERN && errorAction.action.productId === hex2bin(routeAction.action.route.params.productId)).map(([errorAction]) => errorAction);
83
+ export const variantDidChange$ = variantWillUpdate$
84
+ // Take care that the stream only emits when underlying streams emit within the correct order.
85
+ .switchMap(() => receivedVisibleProduct$.first().switchMap(data => {
86
+ const {
87
+ id,
88
+ baseProductId
89
+ } = data.action.productData;
90
+ const variantId = baseProductId !== null ? id : null;
91
+ const baseProduct = getBaseProduct(data.getState(), {
92
+ variantId
93
+ });
94
+ if (baseProduct === null) {
95
+ /**
96
+ * A PDP with a variant product was opened, but the base product is not fetched yet.
97
+ * So emitting of the stream is postponed till the data is present.
98
+ */
99
+ return productReceived$;
100
+ }
101
+ return Observable.of(data);
102
+ }));
103
+ export const productRelationsReceived$ = main$.filter(({
104
+ action
105
+ }) => action.type === RECEIVE_PRODUCT_RELATIONS);
106
+ export const productNotAvailable$ = main$.filter(({
107
+ action
108
+ }) => action.type === PRODUCT_NOT_AVAILABLE);
109
+
110
+ /**
11
111
  * Emits when product results has been received.
12
- */export var productsReceived$=main$.filter(function(_ref19){var action=_ref19.action;return action.type===RECEIVE_PRODUCTS;});/**
112
+ */
113
+ export const productsReceived$ = main$.filter(({
114
+ action
115
+ }) => action.type === RECEIVE_PRODUCTS);
116
+
117
+ /**
13
118
  * Emits when product results has been received from cache.
14
- */export var productsReceivedCached$=main$.filter(function(_ref20){var action=_ref20.action;return action.type===RECEIVE_PRODUCTS_CACHED;});/**
119
+ */
120
+ export const productsReceivedCached$ = main$.filter(({
121
+ action
122
+ }) => action.type === RECEIVE_PRODUCTS_CACHED);
123
+
124
+ /**
15
125
  * Buffer PROVIDE_PRODUCT action and map to have array of requested products
16
126
  * @type {Observable}
17
- */export var fetchProductsRequested$=main$.filter(function(_ref21){var action=_ref21.action;return action.type===PROVIDE_PRODUCT;}).bufferTime(PROVIDE_PRODUCT_BUFFER_TIME).filter(function(actions){return actions.length>0;}).map(function(actions){var productIds=actions.map(function(_ref22){var productId=_ref22.action.productId;return productId;});return _extends({},actions[0],{action:_extends({},actions[0].action,{productId:productIds})});});/**
127
+ */
128
+ export const fetchProductsRequested$ = main$.filter(({
129
+ action
130
+ }) => action.type === PROVIDE_PRODUCT).bufferTime(PROVIDE_PRODUCT_BUFFER_TIME).filter(actions => actions.length > 0).map(actions => {
131
+ const productIds = actions.map(({
132
+ action: {
133
+ productId
134
+ }
135
+ }) => productId);
136
+ return {
137
+ ...actions[0],
138
+ action: {
139
+ ...actions[0].action,
140
+ productId: productIds
141
+ }
142
+ };
143
+ });
144
+
145
+ /**
18
146
  * Emits when product data has been expired.
19
- */export var productDataExpired$=main$.filter(function(_ref23){var action=_ref23.action;return action.type===EXPIRE_PRODUCT_DATA;});/**
147
+ */
148
+ export const productDataExpired$ = main$.filter(({
149
+ action
150
+ }) => action.type === EXPIRE_PRODUCT_DATA);
151
+
152
+ /**
20
153
  * Emits when the REFRESH_EXPIRED_PDP_DATA action is dispatched
21
154
  * and the current route is a product detail page.
22
155
  *
23
156
  * Stream payload will contain a route object that reflects the current active product / variant.
24
- */export var pdpDataNeedsRefresh$=main$.filter(function(_ref24){var action=_ref24.action;return action.type===REFRESH_EXPIRED_PDP_DATA;}).filter(function(_ref25){var getState=_ref25.getState;var _getCurrentRoute=getCurrentRoute(getState()),pattern=_getCurrentRoute.pattern;return pattern===ITEM_PATTERN;}).switchMap(function(params){var getState=params.getState;var route=getCurrentRoute(getState());return Observable.of(_extends({},params,{action:{route:route}}));});
157
+ */
158
+ export const pdpDataNeedsRefresh$ = main$.filter(({
159
+ action
160
+ }) => action.type === REFRESH_EXPIRED_PDP_DATA).filter(({
161
+ getState
162
+ }) => {
163
+ const {
164
+ pattern
165
+ } = getCurrentRoute(getState());
166
+ return pattern === ITEM_PATTERN;
167
+ }).switchMap(params => {
168
+ const {
169
+ getState
170
+ } = params;
171
+ const route = getCurrentRoute(getState());
172
+ return Observable.of({
173
+ ...params,
174
+ action: {
175
+ route
176
+ }
177
+ });
178
+ });
@@ -1,9 +1,215 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{hex2bin}from'@shopgate/pwa-common/helpers/data';import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{getThemeSettings,historyPop,historyPush,routeWillEnter$,routeWillLeave$}from'@shopgate/engage/core';import{ToastProvider}from'@shopgate/pwa-common/providers';import{getSearchRoute}from'@shopgate/pwa-common-commerce/search';import fetchProduct from"../actions/fetchProduct";import fetchProductDescription from"../actions/fetchProductDescription";import fetchProductProperties from"../actions/fetchProductProperties";import fetchProductImages from"../actions/fetchProductImages";import fetchProductShipping from"../actions/fetchProductShipping";import fetchProductVariants from"../actions/fetchProductVariants";import fetchProductOptions from"../actions/fetchProductOptions";import fetchProductMedia from"../actions/fetchProductMedia";import{productWillEnter$,galleryWillEnter$,productReceived$,cachedProductReceived$,productRelationsReceived$,receivedVisibleProduct$,errorProductResourcesNotFound$,visibleProductNotFound$,productNotAvailable$,fetchProductsRequested$,pdpDataNeedsRefresh$}from"../streams";import fetchProductsById from"../actions/fetchProductsById";import{getProductRelationsByHash}from"../selectors/relations";import{checkoutSucceeded$}from"../../checkout/streams";import expireProductById from"../action-creators/expireProductById";import{ITEM_PATTERN,NOT_AVAILABLE_EFFECTIVITY_DATES}from"../constants";import{getProductName}from"../selectors/product";var fetchPDPData$=productWillEnter$.merge(pdpDataNeedsRefresh$);/**
1
+ import "core-js/modules/es.regexp.flags.js";
2
+ import { hex2bin } from '@shopgate/pwa-common/helpers/data';
3
+ import showModal from '@shopgate/pwa-common/actions/modal/showModal';
4
+ import { getThemeSettings, historyPop, historyPush, routeWillEnter$, routeWillLeave$ } from '@shopgate/engage/core';
5
+ import { ToastProvider } from '@shopgate/pwa-common/providers';
6
+ import { getSearchRoute } from '@shopgate/pwa-common-commerce/search';
7
+ import fetchProduct from "../actions/fetchProduct";
8
+ import fetchProductDescription from "../actions/fetchProductDescription";
9
+ import fetchProductProperties from "../actions/fetchProductProperties";
10
+ import fetchProductImages from "../actions/fetchProductImages";
11
+ import fetchProductShipping from "../actions/fetchProductShipping";
12
+ import fetchProductVariants from "../actions/fetchProductVariants";
13
+ import fetchProductOptions from "../actions/fetchProductOptions";
14
+ import fetchProductMedia from "../actions/fetchProductMedia";
15
+ import { productWillEnter$, galleryWillEnter$, productReceived$, cachedProductReceived$, productRelationsReceived$, receivedVisibleProduct$, errorProductResourcesNotFound$, visibleProductNotFound$, productNotAvailable$, fetchProductsRequested$, pdpDataNeedsRefresh$ } from "../streams";
16
+ import fetchProductsById from "../actions/fetchProductsById";
17
+ import { getProductRelationsByHash } from "../selectors/relations";
18
+ import { checkoutSucceeded$ } from "../../checkout/streams";
19
+ import expireProductById from "../action-creators/expireProductById";
20
+ import { ITEM_PATTERN, NOT_AVAILABLE_EFFECTIVITY_DATES } from "../constants";
21
+ import { getProductName } from "../selectors/product";
22
+ const fetchPDPData$ = productWillEnter$.merge(pdpDataNeedsRefresh$);
23
+
24
+ /**
2
25
  * Product subscriptions.
3
26
  * @param {Function} subscribe The subscribe function.
4
- */function product(subscribe){var processProduct$=productReceived$.merge(cachedProductReceived$);subscribe(fetchPDPData$,function(_ref){var action=_ref.action,dispatch=_ref.dispatch;var productId=action.route.params.productId;var variantId=action.route.state.productId;var id=variantId||hex2bin(productId);dispatch(fetchProduct(id));dispatch(fetchProductDescription(id));dispatch(fetchProductProperties(id));dispatch(fetchProductImages(id));dispatch(fetchProductShipping(id));/**
27
+ */
28
+ function product(subscribe) {
29
+ const processProduct$ = productReceived$.merge(cachedProductReceived$);
30
+ subscribe(fetchPDPData$, ({
31
+ action,
32
+ dispatch
33
+ }) => {
34
+ const {
35
+ productId
36
+ } = action.route.params;
37
+ const {
38
+ productId: variantId
39
+ } = action.route.state;
40
+ const id = variantId || hex2bin(productId);
41
+ dispatch(fetchProduct(id));
42
+ dispatch(fetchProductDescription(id));
43
+ dispatch(fetchProductProperties(id));
44
+ dispatch(fetchProductImages(id));
45
+ dispatch(fetchProductShipping(id));
46
+ /**
5
47
  * This feature is currently in BETA testing.
6
48
  * It should only be used for approved BETA Client Projects
7
- */dispatch(fetchProductMedia(id));});subscribe(galleryWillEnter$,function(_ref2){var action=_ref2.action,dispatch=_ref2.dispatch;var productId=action.route.params.productId;dispatch(fetchProductImages(hex2bin(productId)));dispatch(fetchProductMedia(hex2bin(productId)));});subscribe(processProduct$,function(_ref3){var action=_ref3.action,dispatch=_ref3.dispatch;var _action$productData=action.productData,id=_action$productData.id,_action$productData$f=_action$productData.flags,flags=_action$productData$f===void 0?{hasVariants:false,hasOptions:false}:_action$productData$f,baseProductId=_action$productData.baseProductId,active=_action$productData.active;if(baseProductId){dispatch(fetchProduct(baseProductId));dispatch(fetchProductImages(baseProductId));}if(active&&flags.hasVariants){dispatch(fetchProductVariants(id));}if(active&&flags.hasOptions){dispatch(fetchProductOptions(id));}});var errorProductResourcesNotFoundFirst$=receivedVisibleProduct$.filter(function(_ref4){var _action$productData2;var action=_ref4.action;var active=action===null||action===void 0?void 0:(_action$productData2=action.productData)===null||_action$productData2===void 0?void 0:_action$productData2.active;return!!active;}).switchMap(function(){return errorProductResourcesNotFound$.first();});/** Refresh product data after some of resources has ENOTFOUND code */subscribe(errorProductResourcesNotFoundFirst$,function(_ref5){var action=_ref5.action,dispatch=_ref5.dispatch;var productId=action.productId;dispatch(fetchProduct(productId,true));});var productNotFound$=visibleProductNotFound$.withLatestFrom(receivedVisibleProduct$.startWith({action:{productData:{}}}));/** Visible product is no more available */subscribe(productNotFound$,function(_ref6){var _ref7=_slicedToArray(_ref6,2),_ref7$=_ref7[0],action=_ref7$.action,dispatch=_ref7$.dispatch,productData=_ref7[1].action.productData;var productId=action.productId;var name=productData.id===productId?productData.name:productId;dispatch(showModal({confirm:null,dismiss:'modal.ok',title:'modal.title_error',message:'product.no_more_found',params:{name:name}}));dispatch(historyPop());dispatch(expireProductById(productId));});subscribe(productRelationsReceived$,function(_ref8){var dispatch=_ref8.dispatch,getState=_ref8.getState,action=_ref8.action;var hash=action.hash;var productIds=getProductRelationsByHash(hash)(getState());dispatch(fetchProductsById(productIds));});/**
49
+ */
50
+ dispatch(fetchProductMedia(id));
51
+ });
52
+ subscribe(galleryWillEnter$, ({
53
+ action,
54
+ dispatch
55
+ }) => {
56
+ const {
57
+ productId
58
+ } = action.route.params;
59
+ dispatch(fetchProductImages(hex2bin(productId)));
60
+ dispatch(fetchProductMedia(hex2bin(productId)));
61
+ });
62
+ subscribe(processProduct$, ({
63
+ action,
64
+ dispatch
65
+ }) => {
66
+ const {
67
+ id,
68
+ flags = {
69
+ hasVariants: false,
70
+ hasOptions: false
71
+ },
72
+ baseProductId,
73
+ active
74
+ } = action.productData;
75
+ if (baseProductId) {
76
+ dispatch(fetchProduct(baseProductId));
77
+ dispatch(fetchProductImages(baseProductId));
78
+ }
79
+ if (active && flags.hasVariants) {
80
+ dispatch(fetchProductVariants(id));
81
+ }
82
+ if (active && flags.hasOptions) {
83
+ dispatch(fetchProductOptions(id));
84
+ }
85
+ });
86
+ const errorProductResourcesNotFoundFirst$ = receivedVisibleProduct$.filter(({
87
+ action
88
+ }) => {
89
+ const active = action?.productData?.active;
90
+ return !!active;
91
+ }).switchMap(() => errorProductResourcesNotFound$.first());
92
+
93
+ /** Refresh product data after some of resources has ENOTFOUND code */
94
+ subscribe(errorProductResourcesNotFoundFirst$, ({
95
+ action,
96
+ dispatch
97
+ }) => {
98
+ const {
99
+ productId
100
+ } = action;
101
+ dispatch(fetchProduct(productId, true));
102
+ });
103
+ const productNotFound$ = visibleProductNotFound$.withLatestFrom(receivedVisibleProduct$.startWith({
104
+ action: {
105
+ productData: {}
106
+ }
107
+ }));
108
+ /** Visible product is no more available */
109
+ subscribe(productNotFound$, ([{
110
+ action,
111
+ dispatch
112
+ }, {
113
+ action: {
114
+ productData
115
+ }
116
+ }]) => {
117
+ const {
118
+ productId
119
+ } = action;
120
+ const name = productData.id === productId ? productData.name : productId;
121
+ dispatch(showModal({
122
+ confirm: null,
123
+ dismiss: 'modal.ok',
124
+ title: 'modal.title_error',
125
+ message: 'product.no_more_found',
126
+ params: {
127
+ name
128
+ }
129
+ }));
130
+ dispatch(historyPop());
131
+ dispatch(expireProductById(productId));
132
+ });
133
+ subscribe(productRelationsReceived$, ({
134
+ dispatch,
135
+ getState,
136
+ action
137
+ }) => {
138
+ const {
139
+ hash
140
+ } = action;
141
+ const productIds = getProductRelationsByHash(hash)(getState());
142
+ dispatch(fetchProductsById(productIds));
143
+ });
144
+
145
+ /**
8
146
  * Expire products after checkout, fetch updated data
9
- */subscribe(checkoutSucceeded$,function(_ref9){var dispatch=_ref9.dispatch,action=_ref9.action;var products=action.products;var productIds=products.map(function(p){return p.product.id;});productIds.forEach(function(id){return dispatch(expireProductById(id));});dispatch(fetchProductsById(productIds));});var productNotAvailableEffDates$=productNotAvailable$.filter(function(_ref10){var action=_ref10.action;return action.reason===NOT_AVAILABLE_EFFECTIVITY_DATES;});/** PDP expired effectivity dates */var productNotAvailableEffDatesPDP$=productNotAvailableEffDates$.withLatestFrom(routeWillEnter$).filter(function(_ref11){var _ref12=_slicedToArray(_ref11,2),notAvailable=_ref12[0],willEnter=_ref12[1];return willEnter.action.route.pattern===ITEM_PATTERN&&notAvailable.action.productId===willEnter.action.route.state.productId;}).map(function(_ref13){var _ref14=_slicedToArray(_ref13,1),notAvailable=_ref14[0];return notAvailable;});subscribe(productNotAvailableEffDatesPDP$,function(_ref15){var action=_ref15.action,getState=_ref15.getState,dispatch=_ref15.dispatch,events=_ref15.events;var _ref16=getThemeSettings('product')||{},_ref16$effectivityDat=_ref16.effectivityDates,_ref16$effectivityDat2=_ref16$effectivityDat===void 0?{}:_ref16$effectivityDat,accessExpired=_ref16$effectivityDat2.accessExpired;if(accessExpired===false){var productId=action.productId;dispatch(historyPop());var name=getProductName(getState(),{productId:productId});events.emit(ToastProvider.ADD,{id:'product.available.not_search_similar',message:'product.available.not_search_similar',messageParams:{name:name},action:function action(){return dispatch(historyPush({pathname:getSearchRoute(name)}));}});}});/** Expired effectivity dates products after PLP leave */var productNotAvailableEffDatesPLP$=productNotAvailableEffDates$.buffer(routeWillLeave$).filter(function(buffered){return buffered.length;});subscribe(productNotAvailableEffDatesPLP$,function(buffered){var _buffered=_slicedToArray(buffered,1),dispatch=_buffered[0].dispatch;var productIds=buffered.map(function(params){return params.action.productId;});dispatch(expireProductById(productIds,true));});subscribe(fetchProductsRequested$,function(_ref17){var dispatch=_ref17.dispatch,productId=_ref17.action.productId;dispatch(fetchProductsById(Array.isArray(productId)?productId:[productId]));});}export default product;
147
+ */
148
+ subscribe(checkoutSucceeded$, ({
149
+ dispatch,
150
+ action
151
+ }) => {
152
+ const {
153
+ products
154
+ } = action;
155
+ const productIds = products.map(p => p.product.id);
156
+ productIds.forEach(id => dispatch(expireProductById(id)));
157
+ dispatch(fetchProductsById(productIds));
158
+ });
159
+ const productNotAvailableEffDates$ = productNotAvailable$.filter(({
160
+ action
161
+ }) => action.reason === NOT_AVAILABLE_EFFECTIVITY_DATES);
162
+
163
+ /** PDP expired effectivity dates */
164
+ const productNotAvailableEffDatesPDP$ = productNotAvailableEffDates$.withLatestFrom(routeWillEnter$).filter(([notAvailable, willEnter]) => willEnter.action.route.pattern === ITEM_PATTERN && notAvailable.action.productId === willEnter.action.route.state.productId).map(([notAvailable]) => notAvailable);
165
+ subscribe(productNotAvailableEffDatesPDP$, ({
166
+ action,
167
+ getState,
168
+ dispatch,
169
+ events
170
+ }) => {
171
+ const {
172
+ effectivityDates: {
173
+ accessExpired
174
+ } = {}
175
+ } = getThemeSettings('product') || {};
176
+ if (accessExpired === false) {
177
+ const {
178
+ productId
179
+ } = action;
180
+ dispatch(historyPop());
181
+ const name = getProductName(getState(), {
182
+ productId
183
+ });
184
+ events.emit(ToastProvider.ADD, {
185
+ id: 'product.available.not_search_similar',
186
+ message: 'product.available.not_search_similar',
187
+ messageParams: {
188
+ name
189
+ },
190
+ action: () => dispatch(historyPush({
191
+ pathname: getSearchRoute(name)
192
+ }))
193
+ });
194
+ }
195
+ });
196
+
197
+ /** Expired effectivity dates products after PLP leave */
198
+ const productNotAvailableEffDatesPLP$ = productNotAvailableEffDates$.buffer(routeWillLeave$).filter(buffered => buffered.length);
199
+ subscribe(productNotAvailableEffDatesPLP$, buffered => {
200
+ const [{
201
+ dispatch
202
+ }] = buffered;
203
+ const productIds = buffered.map(params => params.action.productId);
204
+ dispatch(expireProductById(productIds, true));
205
+ });
206
+ subscribe(fetchProductsRequested$, ({
207
+ dispatch,
208
+ action: {
209
+ productId
210
+ }
211
+ }) => {
212
+ dispatch(fetchProductsById(Array.isArray(productId) ? productId : [productId]));
213
+ });
214
+ }
215
+ export default product;
@@ -1,5 +1,12 @@
1
- import{ERROR_PRODUCT_REVIEWS}from"../constants";/**
1
+ import { ERROR_PRODUCT_REVIEWS } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the ERROR_PRODUCT_REVIEWS action.
3
5
  * @param {string} productId The ID of the product
4
6
  * @returns {Object} The ERROR_PRODUCT_REVIEWS action
5
- */var errorProductReviews=function errorProductReviews(productId){return{type:ERROR_PRODUCT_REVIEWS,productId:productId};};export default errorProductReviews;
7
+ */
8
+ const errorProductReviews = productId => ({
9
+ type: ERROR_PRODUCT_REVIEWS,
10
+ productId
11
+ });
12
+ export default errorProductReviews;
@@ -1,5 +1,12 @@
1
- import{ERROR_REVIEWS}from"../constants";/**
1
+ import { ERROR_REVIEWS } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the ERROR_REVIEWS action.
3
5
  * @param {string} hash Generated hash.
4
6
  * @returns {Object} The ERROR_PRODUCT_REVIEWS action.
5
- */var errorProductReviews=function errorProductReviews(hash){return{type:ERROR_REVIEWS,hash:hash};};export default errorProductReviews;
7
+ */
8
+ const errorProductReviews = hash => ({
9
+ type: ERROR_REVIEWS,
10
+ hash
11
+ });
12
+ export default errorProductReviews;
@@ -1,5 +1,12 @@
1
- import{ERROR_SUBMIT_REVIEW}from"../constants";/**
1
+ import { ERROR_SUBMIT_REVIEW } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the ERROR_SUBMIT_REVIEW action.
3
5
  * @param {string} productId The ID of the product.
4
6
  * @returns {Object} The ERROR_SUBMIT_REVIEW action.
5
- */var errorSubmitReview=function errorSubmitReview(productId){return{type:ERROR_SUBMIT_REVIEW,productId:productId};};export default errorSubmitReview;
7
+ */
8
+ const errorSubmitReview = productId => ({
9
+ type: ERROR_SUBMIT_REVIEW,
10
+ productId
11
+ });
12
+ export default errorSubmitReview;
@@ -1,5 +1,12 @@
1
- import{ERROR_USER_REVIEW}from"../constants";/**
1
+ import { ERROR_USER_REVIEW } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the ERROR_USER_REVIEW action.
3
5
  * @param {string} productId The ID of the product.
4
6
  * @returns {Object} The ERROR_USER_REVIEW action.
5
- */var errorUserReview=function errorUserReview(productId){return{type:ERROR_USER_REVIEW,productId:productId};};export default errorUserReview;
7
+ */
8
+ const errorUserReview = productId => ({
9
+ type: ERROR_USER_REVIEW,
10
+ productId
11
+ });
12
+ export default errorUserReview;
@@ -1,4 +1,10 @@
1
- import{FLUSH_USER_REVIEWS}from"../constants";/**
1
+ import { FLUSH_USER_REVIEWS } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the FLUSH_USER_REVIEWS action.
3
5
  * @returns {Object} The FLUSH_USER_REVIEWS action
4
- */var receiveProductReviews=function receiveProductReviews(){return{type:FLUSH_USER_REVIEWS};};export default receiveProductReviews;
6
+ */
7
+ const receiveProductReviews = () => ({
8
+ type: FLUSH_USER_REVIEWS
9
+ });
10
+ export default receiveProductReviews;
@@ -1,7 +1,16 @@
1
- import{RECEIVE_PRODUCT_REVIEWS}from"../constants";/**
1
+ import { RECEIVE_PRODUCT_REVIEWS } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the RECEIVE_PRODUCT_REVIEWS action.
3
5
  * @param {string} productId The ID of the product
4
6
  * @param {Object} reviews The received review data
5
7
  * @param {number} totalReviewCount The total number of reviews for a product
6
8
  * @returns {Object} The RECEIVE_PRODUCT_REVIEWS action
7
- */var receiveProductReviews=function receiveProductReviews(productId,reviews,totalReviewCount){return{type:RECEIVE_PRODUCT_REVIEWS,productId:productId,reviews:reviews,totalReviewCount:totalReviewCount};};export default receiveProductReviews;
9
+ */
10
+ const receiveProductReviews = (productId, reviews, totalReviewCount) => ({
11
+ type: RECEIVE_PRODUCT_REVIEWS,
12
+ productId,
13
+ reviews,
14
+ totalReviewCount
15
+ });
16
+ export default receiveProductReviews;
@@ -1,8 +1,18 @@
1
- import{RECEIVE_REVIEWS}from"../constants";/**
1
+ import { RECEIVE_REVIEWS } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the RECEIVE_REVIEWS action.
3
5
  * @param {string} hash Generated hash for an entity.
4
6
  * @param {string} productId The ID of the product.
5
7
  * @param {Array} reviews The received review data.
6
8
  * @param {number} totalReviewCount The total number of reviews for a product.
7
9
  * @returns {Object} The RECEIVE_PRODUCT_REVIEWS action.
8
- */var receiveReviews=function receiveReviews(hash,productId,reviews,totalReviewCount){return{type:RECEIVE_REVIEWS,hash:hash,productId:productId,reviews:reviews,totalReviewCount:totalReviewCount};};export default receiveReviews;
10
+ */
11
+ const receiveReviews = (hash, productId, reviews, totalReviewCount) => ({
12
+ type: RECEIVE_REVIEWS,
13
+ hash,
14
+ productId,
15
+ reviews,
16
+ totalReviewCount
17
+ });
18
+ export default receiveReviews;
@@ -1,5 +1,12 @@
1
- import{RECEIVE_SUBMIT_REVIEW}from"../constants";/**
1
+ import { RECEIVE_SUBMIT_REVIEW } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the RECEIVE_SUBMIT_REVIEW action.
3
5
  * @param {Object} review The received review data.
4
6
  * @returns {Object} The RECEIVE_SUBMIT_REVIEW action.
5
- */var receiveSubmitReview=function receiveSubmitReview(review){return{type:RECEIVE_SUBMIT_REVIEW,review:review};};export default receiveSubmitReview;
7
+ */
8
+ const receiveSubmitReview = review => ({
9
+ type: RECEIVE_SUBMIT_REVIEW,
10
+ review
11
+ });
12
+ export default receiveSubmitReview;
@@ -1,6 +1,14 @@
1
- import{RECEIVE_USER_REVIEW}from"../constants";/**
1
+ import { RECEIVE_USER_REVIEW } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the RECEIVE_USER_REVIEW action.
3
5
  * @param {string} productId The ID of the product.
4
6
  * @param {Object} review The received review data.
5
7
  * @returns {Object} The RECEIVE_USER_REVIEW action.
6
- */var receiveUserReview=function receiveUserReview(productId,review){return{type:RECEIVE_USER_REVIEW,productId:productId,review:review};};export default receiveUserReview;
8
+ */
9
+ const receiveUserReview = (productId, review) => ({
10
+ type: RECEIVE_USER_REVIEW,
11
+ productId,
12
+ review
13
+ });
14
+ export default receiveUserReview;
@@ -1,6 +1,14 @@
1
- import{REQUEST_PRODUCT_REVIEWS}from"../constants";/**
1
+ import { REQUEST_PRODUCT_REVIEWS } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the REQUEST_PRODUCT_REVIEWS action.
3
5
  * @param {string} productId The ID of the product
4
6
  * @param {number} limit The maximum number of reviews
5
7
  * @returns {Object} The REQUEST_PRODUCT_REVIEWS action
6
- */var requestProductReviews=function requestProductReviews(productId,limit){return{type:REQUEST_PRODUCT_REVIEWS,productId:productId,limit:limit};};export default requestProductReviews;
8
+ */
9
+ const requestProductReviews = (productId, limit) => ({
10
+ type: REQUEST_PRODUCT_REVIEWS,
11
+ productId,
12
+ limit
13
+ });
14
+ export default requestProductReviews;
@@ -1,5 +1,12 @@
1
- import{REQUEST_REVIEWS}from"../constants";/**
1
+ import { REQUEST_REVIEWS } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the REQUEST_REVIEWS action.
3
5
  * @param {string} hash Generated hash.
4
6
  * @returns {Object} The REQUEST_PRODUCT_REVIEWS action.
5
- */var requestReviews=function requestReviews(hash){return{type:REQUEST_REVIEWS,hash:hash};};export default requestReviews;
7
+ */
8
+ const requestReviews = hash => ({
9
+ type: REQUEST_REVIEWS,
10
+ hash
11
+ });
12
+ export default requestReviews;
@@ -1,5 +1,12 @@
1
- import{REQUEST_SUBMIT_REVIEW}from"../constants";/**
1
+ import { REQUEST_SUBMIT_REVIEW } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the REQUEST_SUBMIT_REVIEW action.
3
5
  * @param {Object} review The review data.
4
6
  * @returns {Object} The REQUEST_SUBMIT_REVIEW action.
5
- */var requestSubmitReview=function requestSubmitReview(review){return{type:REQUEST_SUBMIT_REVIEW,review:review};};export default requestSubmitReview;
7
+ */
8
+ const requestSubmitReview = review => ({
9
+ type: REQUEST_SUBMIT_REVIEW,
10
+ review
11
+ });
12
+ export default requestSubmitReview;
@@ -1,5 +1,12 @@
1
- import{REQUEST_USER_REVIEW}from"../constants";/**
1
+ import { REQUEST_USER_REVIEW } from "../constants";
2
+
3
+ /**
2
4
  * Dispatches the REQUEST_USER_REVIEW action.
3
5
  * @param {string} productId The ID of the product.
4
6
  * @returns {Object} The REQUEST_USER_REVIEW action.
5
- */var requestUserReview=function requestUserReview(productId){return{type:REQUEST_USER_REVIEW,productId:productId};};export default requestUserReview;
7
+ */
8
+ const requestUserReview = productId => ({
9
+ type: REQUEST_USER_REVIEW,
10
+ productId
11
+ });
12
+ export default requestUserReview;