@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
package/cart/index.js CHANGED
@@ -1,6 +1,26 @@
1
1
  // ACTIONS
2
- export{default as addCouponsToCart}from"./actions/addCouponsToCart";export{default as addProductsToCart}from"./actions/addProductsToCart";export{default as deleteCouponsFromCart}from"./actions/deleteCouponsFromCart";export{default as deleteProductsFromCart}from"./actions/deleteProductsFromCart";export{default as fetchCart}from"./actions/fetchCart";export{default as updateProductsInCart}from"./actions/updateProductsInCart";// CONSTANTS
3
- export*from"./constants/index";export*from"./constants/PipelineErrors";export*from"./constants/Pipelines";export*from"./constants/Portals";// HELPERS
4
- export*from"./helpers";export*from"./helpers/config";export{default as createPipelineErrorList}from"./helpers/createPipelineErrorList";export*from"./helpers/shipping";export*from"./helpers/tax";// SELECTORS
5
- export*from"./selectors";// STREAMS
6
- export*from"./streams";
2
+ export { default as addCouponsToCart } from "./actions/addCouponsToCart";
3
+ export { default as addProductsToCart } from "./actions/addProductsToCart";
4
+ export { default as deleteCouponsFromCart } from "./actions/deleteCouponsFromCart";
5
+ export { default as deleteProductsFromCart } from "./actions/deleteProductsFromCart";
6
+ export { default as fetchCart } from "./actions/fetchCart";
7
+ export { default as updateProductsInCart } from "./actions/updateProductsInCart";
8
+
9
+ // CONSTANTS
10
+ export * from "./constants/index";
11
+ export * from "./constants/PipelineErrors";
12
+ export * from "./constants/Pipelines";
13
+ export * from "./constants/Portals";
14
+
15
+ // HELPERS
16
+ export * from "./helpers";
17
+ export * from "./helpers/config";
18
+ export { default as createPipelineErrorList } from "./helpers/createPipelineErrorList";
19
+ export * from "./helpers/shipping";
20
+ export * from "./helpers/tax";
21
+
22
+ // SELECTORS
23
+ export * from "./selectors";
24
+
25
+ // STREAMS
26
+ export * from "./streams";
package/cart/mock.js CHANGED
@@ -1 +1,130 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}var emptyState={cart:{items:[],totals:[{label:null,amount:0,type:'subTotal'},{label:null,amount:0,type:'grandTotal'}],productPendingCount:0,flags:{orderable:true,taxIncluded:false,coupons:true},isFetching:false,expires:0,isOrderable:true,isTaxIncluded:false,currency:'USD',messages:[],text:{legalText:'By placing your order you agree to our <b><u>Privacy Policy</u></b> and our <b><u>Terms and Conditions</u></b>.',legalInfo:''}},view:{isLoading:false},client:{device:{locale:'de',model:'Redmi Note 4',os:{apiLevel:'23',platform:'android',ver:'6.0'},type:'phone'}},router:{routing:false,stack:[{id:'82588781-089a-46bc-8174-7cebfae12d95',params:{},pathname:'/',pattern:'/',query:{},state:{}},{id:'834a9c2f-c94d-441d-aba5-446a7895d724',params:{},pathname:'/cart',pattern:'/cart',query:{},state:{title:'Shopping cart'}}]}};var products=[{id:'123',quantity:1,type:'product',product:{id:'test_product',name:'Test Product',featuredImageBaseUrl:'https://img-cdn.shopgate.com/30794/1/d11b2e01b66f7a505fbd98b6ed7463c092aeaebae11ee8bec20ffc13344297fa',featuredImageUrl:'https://img-cdn.shopgate.com/30794/1/d11b2e01b66f7a505fbd98b6ed7463c092aeaebae11ee8bec20ffc13344297fa',price:{unit:20,"default":20,special:null},properties:[{label:'Weight',value:'15kg'}],appliedDiscounts:[]},coupon:null,messages:[]}];var coupon={id:'234',quantity:1,type:'coupon',coupon:{code:'FOREVER',description:null,label:'Coupon',savedPrice:{value:5,type:'fixed'}},messages:[],product:null};var cartState=_extends({},emptyState,{},{cart:_extends({},emptyState.cart,{items:products})});var couponState=_extends({},emptyState,{},{cart:_extends({},emptyState.cart,{items:[].concat(products,[_extends({},coupon)])})});var uiState={ui:{general:{}}};export{uiState,emptyState,cartState,couponState};
1
+ const emptyState = {
2
+ cart: {
3
+ items: [],
4
+ totals: [{
5
+ label: null,
6
+ amount: 0,
7
+ type: 'subTotal'
8
+ }, {
9
+ label: null,
10
+ amount: 0,
11
+ type: 'grandTotal'
12
+ }],
13
+ productPendingCount: 0,
14
+ flags: {
15
+ orderable: true,
16
+ taxIncluded: false,
17
+ coupons: true
18
+ },
19
+ isFetching: false,
20
+ expires: 0,
21
+ isOrderable: true,
22
+ isTaxIncluded: false,
23
+ currency: 'USD',
24
+ messages: [],
25
+ text: {
26
+ legalText: 'By placing your order you agree to our <b><u>Privacy Policy</u></b> and our <b><u>Terms and Conditions</u></b>.',
27
+ legalInfo: ''
28
+ }
29
+ },
30
+ view: {
31
+ isLoading: false
32
+ },
33
+ client: {
34
+ device: {
35
+ locale: 'de',
36
+ model: 'Redmi Note 4',
37
+ os: {
38
+ apiLevel: '23',
39
+ platform: 'android',
40
+ ver: '6.0'
41
+ },
42
+ type: 'phone'
43
+ }
44
+ },
45
+ router: {
46
+ routing: false,
47
+ stack: [{
48
+ id: '82588781-089a-46bc-8174-7cebfae12d95',
49
+ params: {},
50
+ pathname: '/',
51
+ pattern: '/',
52
+ query: {},
53
+ state: {}
54
+ }, {
55
+ id: '834a9c2f-c94d-441d-aba5-446a7895d724',
56
+ params: {},
57
+ pathname: '/cart',
58
+ pattern: '/cart',
59
+ query: {},
60
+ state: {
61
+ title: 'Shopping cart'
62
+ }
63
+ }]
64
+ }
65
+ };
66
+ const products = [{
67
+ id: '123',
68
+ quantity: 1,
69
+ type: 'product',
70
+ product: {
71
+ id: 'test_product',
72
+ name: 'Test Product',
73
+ featuredImageBaseUrl: 'https://img-cdn.shopgate.com/30794/1/d11b2e01b66f7a505fbd98b6ed7463c092aeaebae11ee8bec20ffc13344297fa',
74
+ featuredImageUrl: 'https://img-cdn.shopgate.com/30794/1/d11b2e01b66f7a505fbd98b6ed7463c092aeaebae11ee8bec20ffc13344297fa',
75
+ price: {
76
+ unit: 20,
77
+ default: 20,
78
+ special: null
79
+ },
80
+ properties: [{
81
+ label: 'Weight',
82
+ value: '15kg'
83
+ }],
84
+ appliedDiscounts: []
85
+ },
86
+ coupon: null,
87
+ messages: []
88
+ }];
89
+ const coupon = {
90
+ id: '234',
91
+ quantity: 1,
92
+ type: 'coupon',
93
+ coupon: {
94
+ code: 'FOREVER',
95
+ description: null,
96
+ label: 'Coupon',
97
+ savedPrice: {
98
+ value: 5,
99
+ type: 'fixed'
100
+ }
101
+ },
102
+ messages: [],
103
+ product: null
104
+ };
105
+ const cartState = {
106
+ ...emptyState,
107
+ ...{
108
+ cart: {
109
+ ...emptyState.cart,
110
+ items: products
111
+ }
112
+ }
113
+ };
114
+ const couponState = {
115
+ ...emptyState,
116
+ ...{
117
+ cart: {
118
+ ...emptyState.cart,
119
+ items: [...products, {
120
+ ...coupon
121
+ }]
122
+ }
123
+ }
124
+ };
125
+ const uiState = {
126
+ ui: {
127
+ general: {}
128
+ }
129
+ };
130
+ export { uiState, emptyState, cartState, couponState };
@@ -1,6 +1,34 @@
1
- import{produce}from'immer';import{SET_COUPON_FIELD_VALUE,SET_COUPON_FIELD_ERROR}from"../constants";var defaultState={error:'',value:''};/**
1
+ import { produce } from 'immer';
2
+ import { SET_COUPON_FIELD_VALUE, SET_COUPON_FIELD_ERROR } from "../constants";
3
+ const defaultState = {
4
+ error: '',
5
+ value: ''
6
+ };
7
+
8
+ /**
2
9
  * The reducer for all checkout related state.
3
10
  * @param {Object} state The application state.
4
11
  * @param {Object} action The redux action.
5
12
  * @returns {Object}
6
- */export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(function(draft){switch(action.type){case SET_COUPON_FIELD_VALUE:{draft.value=action.value;break;}case SET_COUPON_FIELD_ERROR:{draft.error=action.message;break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);});
13
+ */
14
+ export default (state = defaultState, action) => {
15
+ /* eslint-disable no-param-reassign */
16
+ const producer = produce(draft => {
17
+ switch (action.type) {
18
+ case SET_COUPON_FIELD_VALUE:
19
+ {
20
+ draft.value = action.value;
21
+ break;
22
+ }
23
+ case SET_COUPON_FIELD_ERROR:
24
+ {
25
+ draft.error = action.message;
26
+ break;
27
+ }
28
+ default:
29
+ break;
30
+ }
31
+ });
32
+ /* eslint-enable no-param-reassign */
33
+ return producer(state);
34
+ };
@@ -1,11 +1,103 @@
1
- var _excluded=["cartItems"];function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _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 remove from'lodash/remove';import{ADD_PRODUCTS_TO_CART,DELETE_PRODUCTS_FROM_CART,UPDATE_PRODUCTS_IN_CART,ERROR_ADD_PRODUCTS_TO_CART,REQUEST_CART,RECEIVE_CART,ERROR_CART,SET_CART_PENDING_PRODUCT_COUNT,SET_FULFILLMENT_SLOT}from"../constants";var defaultState={items:[],totals:[],productPendingCount:0,flags:{},activeFulfillmentSlot:null};/**
1
+ import "core-js/modules/es.regexp.flags.js";
2
+ import remove from 'lodash/remove';
3
+ import { ADD_PRODUCTS_TO_CART, DELETE_PRODUCTS_FROM_CART, UPDATE_PRODUCTS_IN_CART, ERROR_ADD_PRODUCTS_TO_CART, REQUEST_CART, RECEIVE_CART, ERROR_CART, SET_CART_PENDING_PRODUCT_COUNT, SET_FULFILLMENT_SLOT } from "../constants";
4
+ const defaultState = {
5
+ items: [],
6
+ totals: [],
7
+ productPendingCount: 0,
8
+ flags: {},
9
+ activeFulfillmentSlot: null
10
+ };
11
+
12
+ /**
2
13
  * Stores all the cart items.
3
14
  * The cart will be cached in localStorage as defined in './library/store/configureStore.js'.
4
15
  * @param {Object} [state] The current state.
5
16
  * @param {Object} action The action object.
6
17
  * @return {Object} The new state.
7
- */export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case ADD_PRODUCTS_TO_CART:case ERROR_ADD_PRODUCTS_TO_CART:{return state;}case DELETE_PRODUCTS_FROM_CART:{return _extends({},state,{items:remove(state.items,function(item){return!action.cartItemIds.includes(item.id);})});}case UPDATE_PRODUCTS_IN_CART:{return _extends({},state,{items:state.items.map(function(item){var updateData=action.updateData;// Search the stored cart item, which shall be updated
8
- var match=updateData.find(function(update){return item.id===update.cartItemId;});// Apply the updated quantity to the cart item in the store.
9
- return _extends({},item,{},typeof match!=='undefined'&&typeof match.quantity!=='undefined'&&{quantity:match.quantity},{},typeof match!=='undefined'&&typeof match.substitutionAllowed!=='undefined'&&{substitutionAllowed:match.substitutionAllowed});})});}case REQUEST_CART:{return _extends({},state,{isFetching:true,expires:0});}case RECEIVE_CART:{var _ref,_cart$flags,_ref2,_cart$flags2;var _action$cart2=action.cart,cartItems=_action$cart2.cartItems,cart=_objectWithoutProperties(_action$cart2,_excluded);return _extends({},state,{},cart,{// Map cart flags to properties on root level to establish compatibility with getCart
10
- // pipelines that don't return "isOrderable" and "isTaxIncluded" flags
11
- isOrderable:(_ref=cart===null||cart===void 0?void 0:(_cart$flags=cart.flags)===null||_cart$flags===void 0?void 0:_cart$flags.orderable)!==null&&_ref!==void 0?_ref:true,isTaxIncluded:(_ref2=cart===null||cart===void 0?void 0:(_cart$flags2=cart.flags)===null||_cart$flags2===void 0?void 0:_cart$flags2.taxIncluded)!==null&&_ref2!==void 0?_ref2:true,expires:0,items:cartItems,isFetching:false,productPendingCount:0});}case ERROR_CART:return _extends({},state,{isFetching:false,expires:0});case SET_CART_PENDING_PRODUCT_COUNT:return _extends({},state,{productPendingCount:Math.max(0,action.count)});case SET_FULFILLMENT_SLOT:return _extends({},state,{activeFulfillmentSlot:action.fulfillmentSlot});default:return state;}});
18
+ */
19
+ export default (state = defaultState, action) => {
20
+ switch (action.type) {
21
+ case ADD_PRODUCTS_TO_CART:
22
+ case ERROR_ADD_PRODUCTS_TO_CART:
23
+ {
24
+ return state;
25
+ }
26
+ case DELETE_PRODUCTS_FROM_CART:
27
+ {
28
+ return {
29
+ ...state,
30
+ items: remove(state.items, item => !action.cartItemIds.includes(item.id))
31
+ };
32
+ }
33
+ case UPDATE_PRODUCTS_IN_CART:
34
+ {
35
+ return {
36
+ ...state,
37
+ items: state.items.map(item => {
38
+ const {
39
+ updateData
40
+ } = action;
41
+ // Search the stored cart item, which shall be updated
42
+ const match = updateData.find(update => item.id === update.cartItemId);
43
+
44
+ // Apply the updated quantity to the cart item in the store.
45
+ return {
46
+ ...item,
47
+ ...(typeof match !== 'undefined' && typeof match.quantity !== 'undefined' && {
48
+ quantity: match.quantity
49
+ }),
50
+ ...(typeof match !== 'undefined' && typeof match.substitutionAllowed !== 'undefined' && {
51
+ substitutionAllowed: match.substitutionAllowed
52
+ })
53
+ };
54
+ })
55
+ };
56
+ }
57
+ case REQUEST_CART:
58
+ {
59
+ return {
60
+ ...state,
61
+ isFetching: true,
62
+ expires: 0
63
+ };
64
+ }
65
+ case RECEIVE_CART:
66
+ {
67
+ const {
68
+ cartItems,
69
+ ...cart
70
+ } = action.cart;
71
+ return {
72
+ ...state,
73
+ ...cart,
74
+ // Map cart flags to properties on root level to establish compatibility with getCart
75
+ // pipelines that don't return "isOrderable" and "isTaxIncluded" flags
76
+ isOrderable: cart?.flags?.orderable ?? true,
77
+ isTaxIncluded: cart?.flags?.taxIncluded ?? true,
78
+ expires: 0,
79
+ items: cartItems,
80
+ isFetching: false,
81
+ productPendingCount: 0
82
+ };
83
+ }
84
+ case ERROR_CART:
85
+ return {
86
+ ...state,
87
+ isFetching: false,
88
+ expires: 0
89
+ };
90
+ case SET_CART_PENDING_PRODUCT_COUNT:
91
+ return {
92
+ ...state,
93
+ productPendingCount: Math.max(0, action.count)
94
+ };
95
+ case SET_FULFILLMENT_SLOT:
96
+ return {
97
+ ...state,
98
+ activeFulfillmentSlot: action.fulfillmentSlot
99
+ };
100
+ default:
101
+ return state;
102
+ }
103
+ };
@@ -1 +1,7 @@
1
- import{combineReducers}from'redux';import data from"./data";import couponField from"./couponField";export default combineReducers({data:data,couponField:couponField});
1
+ import { combineReducers } from 'redux';
2
+ import data from "./data";
3
+ import couponField from "./couponField";
4
+ export default combineReducers({
5
+ data,
6
+ couponField
7
+ });
@@ -1,105 +1,255 @@
1
- import{createSelector}from'reselect';import{getBaseProductMetadata}from"../../product/selectors/product";import{getSelectedVariantMetadata}from"../../product/selectors/variants";import{getRawProductOptions,hasProductOptions,areProductOptionsSet}from"../../product/selectors/options";import{CART_ITEM_TYPE_PRODUCT,CART_ITEM_TYPE_COUPON,CART_TOTALS_TYPE_SUB,CART_TOTALS_TYPE_GRAND,CART_TOTALS_TYPE_DISCOUNT,CART_TOTALS_TYPE_SHIPPING,CART_TOTALS_TYPE_TAX}from"../constants";import{getDisplayedProductQuantity}from"../helpers/quantity";/**
1
+ import "core-js/modules/es.array.reduce.js";
2
+ import "core-js/modules/es.regexp.flags.js";
3
+ import { createSelector } from 'reselect';
4
+ import { getBaseProductMetadata } from "../../product/selectors/product";
5
+ import { getSelectedVariantMetadata } from "../../product/selectors/variants";
6
+ import { getRawProductOptions, hasProductOptions, areProductOptionsSet } from "../../product/selectors/options";
7
+ import { CART_ITEM_TYPE_PRODUCT, CART_ITEM_TYPE_COUPON, CART_TOTALS_TYPE_SUB, CART_TOTALS_TYPE_GRAND, CART_TOTALS_TYPE_DISCOUNT, CART_TOTALS_TYPE_SHIPPING, CART_TOTALS_TYPE_TAX } from "../constants";
8
+ import { getDisplayedProductQuantity } from "../helpers/quantity";
9
+
10
+ /**
2
11
  * Selects the coupon field data from the store.
3
12
  * @param {Object} state The current state.
4
13
  * @return {Object}
5
- */var getCouponField=function getCouponField(state){return state.cart.couponField;};/**
14
+ */
15
+ const getCouponField = state => state.cart.couponField;
16
+
17
+ /**
6
18
  * Selects the cart data from the store.
7
19
  * @param {Object} state The current state.
8
20
  * @return {Object}
9
- */export var getCart=function getCart(state){return state.cart.data;};/**
21
+ */
22
+ export const getCart = state => state.cart.data;
23
+
24
+ /**
10
25
  * Selects the cartItems from the current cart in the state.
11
26
  * @param {Object} state The current state.
12
27
  * @return {Array} The cartItems.
13
- */var cartItemsSelector=function cartItemsSelector(state){return state.cart.data.items;};/**
28
+ */
29
+ const cartItemsSelector = state => state.cart.data.items;
30
+
31
+ /**
14
32
  * Selects the total amounts stack from the cart data.
15
33
  * @param {Object} state The current application state.
16
34
  * @return {Object} The total amount stack.
17
- */var getTotals=createSelector(getCart,function(cart){return cart.totals;});/**
35
+ */
36
+ const getTotals = createSelector(getCart, cart => cart.totals);
37
+
38
+ /**
18
39
  * Selects all items from the cart.
19
40
  * @param {Object} state The current state.
20
41
  * @return {Array} The cart items.
21
- */export var getCartItems=createSelector(cartItemsSelector,function(cartItems){return cartItems;});/**
42
+ */
43
+ export const getCartItems = createSelector(cartItemsSelector, cartItems => cartItems);
44
+
45
+ /**
22
46
  * Selects the cartItem of the given Id.
23
47
  * @param {Object} state The current state.
24
48
  * @param {string} params.cartItemId Id of the cartItem.
25
49
  * @return {Array} The cart items.
26
- */export var getCartItemById=createSelector(function(state,_ref){var cartItemId=_ref.cartItemId;return cartItemId;},getCartItems,function(cartItemId,cartItems){return cartItems.find(function(_ref2){var id=_ref2.id;return id===cartItemId;})||null;});/**
50
+ */
51
+ export const getCartItemById = createSelector((state, {
52
+ cartItemId
53
+ }) => cartItemId, getCartItems, (cartItemId, cartItems) => cartItems.find(({
54
+ id
55
+ }) => id === cartItemId) || null);
56
+
57
+ /**
27
58
  * Selects the products from the cart.
28
59
  * @param {Object} state The current state.
29
60
  * @return {Object[]} The cart products.
30
- */export var getCartProducts=createSelector(cartItemsSelector,function(cartItems){return cartItems.filter(function(item){return item.type===CART_ITEM_TYPE_PRODUCT;});});/**
61
+ */
62
+ export const getCartProducts = createSelector(cartItemsSelector, cartItems => cartItems.filter(item => item.type === CART_ITEM_TYPE_PRODUCT));
63
+
64
+ /**
31
65
  * Selects the coupons from the cart.
32
66
  * @param {Object} state The current state.
33
67
  * @return {Array} The cart coupons.
34
- */export var getCartCoupons=createSelector(cartItemsSelector,function(cartItems){return cartItems.filter(function(item){return item.type===CART_ITEM_TYPE_COUPON;});});/**
68
+ */
69
+ export const getCartCoupons = createSelector(cartItemsSelector, cartItems => cartItems.filter(item => item.type === CART_ITEM_TYPE_COUPON));
70
+
71
+ /**
35
72
  * Calculates the current number of product in the cart.
36
73
  * @param {Object} state The current state.
37
74
  * @return {number} The current number of products within the cart.
38
- */export var getCartProductCount=createSelector(cartItemsSelector,function(cartItems){return(cartItems===null||cartItems===void 0?void 0:cartItems.reduce(function(count,cartItem){// We don't count coupons etc.
39
- if(cartItem.type!==CART_ITEM_TYPE_PRODUCT){return count;}return count+getDisplayedProductQuantity(cartItem);},0))||0;});/**
75
+ */
76
+ export const getCartProductCount = createSelector(cartItemsSelector, cartItems => cartItems?.reduce((count, cartItem) => {
77
+ // We don't count coupons etc.
78
+ if (cartItem.type !== CART_ITEM_TYPE_PRODUCT) {
79
+ return count;
80
+ }
81
+ return count + getDisplayedProductQuantity(cartItem);
82
+ }, 0) || 0);
83
+
84
+ /**
40
85
  * Selects the pending product count from the cart.
41
86
  * @param {Object} state The current application state.
42
87
  * @return {number}
43
- */export var getProductPendingCount=createSelector(getCart,function(cart){return cart.productPendingCount;});/**
88
+ */
89
+ export const getProductPendingCount = createSelector(getCart, cart => cart.productPendingCount);
90
+
91
+ /**
44
92
  * Selects the total, theoretical, number of products in the cart.
45
93
  * @param {Object} state The current application state.
46
94
  * @return {number}
47
- */export var getCartProductDisplayCount=createSelector(getCartProductCount,getProductPendingCount,function(productCount,pendingCount){return productCount+pendingCount;});/**
95
+ */
96
+ export const getCartProductDisplayCount = createSelector(getCartProductCount, getProductPendingCount, (productCount, pendingCount) => productCount + pendingCount);
97
+
98
+ /**
48
99
  * Selects the orderable status from the cart data.
49
100
  * @param {Object} state The current application state.
50
101
  * @return {boolean}
51
- */export var getOrderableStatus=createSelector(getCart,function(cart){return cart.isOrderable;});/**
102
+ */
103
+ export const getOrderableStatus = createSelector(getCart, cart => cart.isOrderable);
104
+
105
+ /**
52
106
  * Selects the currency from the cart data.
53
107
  * @param {Object} state The current application state.
54
108
  * @return {string}
55
- */export var getCurrency=createSelector(getCart,function(cart){return cart.currency;});/**
109
+ */
110
+ export const getCurrency = createSelector(getCart, cart => cart.currency);
111
+
112
+ /**
56
113
  * Selects the sub total.
57
114
  * @param {Object} state The current application state.
58
115
  * @return {string}
59
- */export var getSubTotal=createSelector(getTotals,function(totals){var _ref3=totals.find(function(total){return total.type===CART_TOTALS_TYPE_SUB;})||{},_ref3$amount=_ref3.amount,amount=_ref3$amount===void 0?0:_ref3$amount;return amount;});/**
116
+ */
117
+ export const getSubTotal = createSelector(getTotals, totals => {
118
+ const {
119
+ amount = 0
120
+ } = totals.find(total => total.type === CART_TOTALS_TYPE_SUB) || {};
121
+ return amount;
122
+ });
123
+
124
+ /**
60
125
  * Selects the grand total.
61
126
  * @param {Object} state The current application state.
62
127
  * @returns {number}
63
- */export var getGrandTotal=createSelector(getTotals,function(totals){var _ref4=totals.find(function(total){return total.type===CART_TOTALS_TYPE_GRAND;})||{},_ref4$amount=_ref4.amount,amount=_ref4$amount===void 0?0:_ref4$amount;return amount;});/**
128
+ */
129
+ export const getGrandTotal = createSelector(getTotals, totals => {
130
+ const {
131
+ amount = 0
132
+ } = totals.find(total => total.type === CART_TOTALS_TYPE_GRAND) || {};
133
+ return amount;
134
+ });
135
+
136
+ /**
64
137
  * Selects the grand total data.
65
138
  * @param {Object} state The current application state.
66
139
  * @returns {number}
67
- */export var getGrandTotalData=createSelector(getTotals,function(totals){var totalData=totals.find(function(total){return total.type===CART_TOTALS_TYPE_GRAND;})||null;return totalData;});/**
140
+ */
141
+ export const getGrandTotalData = createSelector(getTotals, totals => {
142
+ const totalData = totals.find(total => total.type === CART_TOTALS_TYPE_GRAND) || null;
143
+ return totalData;
144
+ });
145
+
146
+ /**
68
147
  * Selects the shipping costs.
69
148
  * @returns {Object|null}
70
- */export var getShippingCost=createSelector(getTotals,function(totals){return totals.find(function(total){return total.type===CART_TOTALS_TYPE_SHIPPING;})||null;});/**
149
+ */
150
+ export const getShippingCost = createSelector(getTotals, totals => totals.find(total => total.type === CART_TOTALS_TYPE_SHIPPING) || null);
151
+
152
+ /**
71
153
  * Selects the summed up shipping costs of the cart.
72
154
  * @returns {number}
73
- */export var getShippingCosts=createSelector(getShippingCost,function(shippingCost){if(!shippingCost){return null;}var _shippingCost$amount=shippingCost.amount,amount=_shippingCost$amount===void 0?0:_shippingCost$amount;return amount;});/**
155
+ */
156
+ export const getShippingCosts = createSelector(getShippingCost, shippingCost => {
157
+ if (!shippingCost) {
158
+ return null;
159
+ }
160
+ const {
161
+ amount = 0
162
+ } = shippingCost;
163
+ return amount;
164
+ });
165
+
166
+ /**
74
167
  * Selects the tax value of the cart.
75
168
  * @returns {Object}
76
- */export var getTax=createSelector(getTotals,function(totals){return totals.find(function(total){return total.type===CART_TOTALS_TYPE_TAX;})||null;});/**
169
+ */
170
+ export const getTax = createSelector(getTotals, totals => totals.find(total => total.type === CART_TOTALS_TYPE_TAX) || null);
171
+
172
+ /**
77
173
  * Selects applied discounts from the total amounts stack.
78
174
  * @param {Object} state The current application state.
79
175
  * @return {Object[]|null}
80
- */export var getDiscounts=createSelector(getTotals,function(totals){var discounts=totals.filter(function(total){return total.type===CART_TOTALS_TYPE_DISCOUNT;});return discounts.length?discounts:null;});/**
176
+ */
177
+ export const getDiscounts = createSelector(getTotals, totals => {
178
+ const discounts = totals.filter(total => total.type === CART_TOTALS_TYPE_DISCOUNT);
179
+ return discounts.length ? discounts : null;
180
+ });
181
+
182
+ /**
81
183
  * Selects the discounts value of the cart.
82
184
  * @returns {number}
83
- */export var getDiscountsAmount=createSelector(getDiscounts,function(discounts){if(!discounts){return 0;}return discounts.reduce(function(acc,d){return acc+d.amount;},0);});/**
185
+ */
186
+ export const getDiscountsAmount = createSelector(getDiscounts, discounts => {
187
+ if (!discounts) {
188
+ return 0;
189
+ }
190
+ return discounts.reduce((acc, d) => acc + d.amount, 0);
191
+ });
192
+
193
+ /**
84
194
  * Selects the received messages from the cart.
85
195
  * @param {Object} state The current application state.
86
196
  * @return {Array}
87
- */export var getCartMessages=createSelector(getCart,function(cart){return cart.messages;});/**
197
+ */
198
+ export const getCartMessages = createSelector(getCart, cart => cart.messages);
199
+
200
+ /**
88
201
  * Selects the cart flags from the cart data.
89
202
  * @return {Object}
90
- */export var getFlags=createSelector(getCart,function(_ref5){var flags=_ref5.flags;return flags||{};});/**
203
+ */
204
+ export const getFlags = createSelector(getCart, ({
205
+ flags
206
+ }) => flags || {});
207
+
208
+ /**
91
209
  * Builds the data for the 'options' property of addProductsToCart pipeline request payload.
92
210
  * @param {Object} state The application state.
93
211
  * @returns {Object|null} The data if it was determinable, otherwise NULL.
94
- */export var getAddToCartOptions=createSelector(hasProductOptions,areProductOptionsSet,getRawProductOptions,function(state,props){return props.options;},function(hasOptions,areOptionsSet,options,currentOptions){// Check if options are ready to be added to a pipeline request.
95
- if(!hasOptions||!areOptionsSet){return null;}// Create the data structure.
96
- return Object.keys(currentOptions).map(function(id){var value=currentOptions[id];var _options$find=options.find(function(option){return option.id===id;}),type=_options$find.type;return{type:type,id:id,value:value};});});/**
212
+ */
213
+ export const getAddToCartOptions = createSelector(hasProductOptions, areProductOptionsSet, getRawProductOptions, (state, props) => props.options, (hasOptions, areOptionsSet, options, currentOptions) => {
214
+ // Check if options are ready to be added to a pipeline request.
215
+ if (!hasOptions || !areOptionsSet) {
216
+ return null;
217
+ }
218
+
219
+ // Create the data structure.
220
+ return Object.keys(currentOptions).map(id => {
221
+ const value = currentOptions[id];
222
+ const {
223
+ type
224
+ } = options.find(option => option.id === id);
225
+ return {
226
+ type,
227
+ id,
228
+ value
229
+ };
230
+ });
231
+ });
232
+
233
+ /**
97
234
  * Builds the data for the 'metadata' property of addProductsToCart pipeline request payload.
98
235
  * @returns {Object|null} The data if it was determinable, otherwise NULL.
99
- */export var getAddToCartMetadata=createSelector(getSelectedVariantMetadata,getBaseProductMetadata,function(variantMetadata,baseProductMetadata){return variantMetadata||baseProductMetadata||null;});/**
236
+ */
237
+ export const getAddToCartMetadata = createSelector(getSelectedVariantMetadata, getBaseProductMetadata, (variantMetadata, baseProductMetadata) => variantMetadata || baseProductMetadata || null);
238
+
239
+ /**
100
240
  * Checks if the cart supports redemption of coupons.
101
241
  * @return {boolean}
102
- */export var hasCouponSupport=createSelector(getFlags,function(_ref6){var coupons=_ref6.coupons;return typeof coupons==='boolean'?coupons:true;});/**
242
+ */
243
+ export const hasCouponSupport = createSelector(getFlags, ({
244
+ coupons
245
+ }) => typeof coupons === 'boolean' ? coupons : true);
246
+
247
+ /**
103
248
  * Checks if the cart is fetching
104
249
  * @return {boolean}
105
- */export var getIsFetching=createSelector(getCart,function(_ref7){var isFetching=_ref7.isFetching;return isFetching||false;});export var getCouponFieldError=createSelector(getCouponField,function(data){return(data===null||data===void 0?void 0:data.error)||'';});export var getCouponFieldValue=createSelector(getCouponField,function(data){return(data===null||data===void 0?void 0:data.value)||'';});
250
+ */
251
+ export const getIsFetching = createSelector(getCart, ({
252
+ isFetching
253
+ }) => isFetching || false);
254
+ export const getCouponFieldError = createSelector(getCouponField, data => data?.error || '');
255
+ export const getCouponFieldValue = createSelector(getCouponField, data => data?.value || '');