@commercelayer/react-components 2.49.5 → 2.50.0

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 (362) hide show
  1. package/lib/cjs/components/AddToCartButton.js +1 -1
  2. package/lib/cjs/components/Address.js +1 -1
  3. package/lib/cjs/components/AddressCountrySelector.js +1 -1
  4. package/lib/cjs/components/AddressField.js +1 -1
  5. package/lib/cjs/components/AddressInput.js +1 -1
  6. package/lib/cjs/components/AddressStateSelector.js +1 -1
  7. package/lib/cjs/components/AddressesContainer.js +1 -1
  8. package/lib/cjs/components/AdyenPayment.js +1 -1
  9. package/lib/cjs/components/AvailabilityContainer.js +1 -1
  10. package/lib/cjs/components/AvailabilityTemplate.js +1 -1
  11. package/lib/cjs/components/BillingAddressContainer.js +1 -1
  12. package/lib/cjs/components/BillingAddressForm.js +1 -1
  13. package/lib/cjs/components/BraintreePayment.js +1 -1
  14. package/lib/cjs/components/CheckoutLink.js +1 -1
  15. package/lib/cjs/components/CommerceLayer.js +1 -1
  16. package/lib/cjs/components/CustomerContainer.js +1 -1
  17. package/lib/cjs/components/CustomerInput.js +1 -1
  18. package/lib/cjs/components/DeliveryLeadTime.js +1 -1
  19. package/lib/cjs/components/DiscountAmount.js +1 -1
  20. package/lib/cjs/components/Errors.js +1 -1
  21. package/lib/cjs/components/ExternalFunction.js +1 -1
  22. package/lib/cjs/components/GiftCard.js +1 -1
  23. package/lib/cjs/components/GiftCardAmount.js +1 -1
  24. package/lib/cjs/components/GiftCardContainer.js +1 -1
  25. package/lib/cjs/components/GiftCardCurrencySelector.js +1 -1
  26. package/lib/cjs/components/GiftCardInput.js +1 -1
  27. package/lib/cjs/components/GiftCardOrCouponCode.js +1 -1
  28. package/lib/cjs/components/GiftCardOrCouponForm.js +1 -1
  29. package/lib/cjs/components/GiftCardOrCouponInput.js +1 -1
  30. package/lib/cjs/components/GiftCardOrCouponRemoveButton.js +1 -1
  31. package/lib/cjs/components/GiftCardOrCouponSubmit.js +1 -1
  32. package/lib/cjs/components/ItemContainer.js +1 -1
  33. package/lib/cjs/components/LineItem.js +1 -1
  34. package/lib/cjs/components/LineItemAmount.js +1 -1
  35. package/lib/cjs/components/LineItemCode.js +1 -1
  36. package/lib/cjs/components/LineItemImage.js +1 -1
  37. package/lib/cjs/components/LineItemName.js +1 -1
  38. package/lib/cjs/components/LineItemOption.js +1 -1
  39. package/lib/cjs/components/LineItemOptions.js +1 -1
  40. package/lib/cjs/components/LineItemQuantity.js +1 -1
  41. package/lib/cjs/components/LineItemRemoveLink.js +1 -1
  42. package/lib/cjs/components/LineItemsContainer.js +1 -1
  43. package/lib/cjs/components/LineItemsCount.js +1 -1
  44. package/lib/cjs/components/MetadataInput.js +1 -1
  45. package/lib/cjs/components/OrderContainer.js +1 -1
  46. package/lib/cjs/components/OrderNumber.js +1 -1
  47. package/lib/cjs/components/OrderStorage.js +1 -1
  48. package/lib/cjs/components/PaymentGateway.js +1 -1
  49. package/lib/cjs/components/PaymentMethod.js +1 -1
  50. package/lib/cjs/components/PaymentMethodAmount.js +1 -1
  51. package/lib/cjs/components/PaymentMethodName.js +1 -1
  52. package/lib/cjs/components/PaymentMethodPrice.js +1 -1
  53. package/lib/cjs/components/PaymentMethodRadioButton.js +1 -1
  54. package/lib/cjs/components/PaymentMethodsContainer.js +1 -1
  55. package/lib/cjs/components/PaymentSource.js +1 -1
  56. package/lib/cjs/components/PaymentSourceBrandIcon.js +1 -1
  57. package/lib/cjs/components/PaymentSourceBrandName.js +1 -1
  58. package/lib/cjs/components/PaymentSourceDetail.js +1 -1
  59. package/lib/cjs/components/PaymentSourceEditButton.js +1 -1
  60. package/lib/cjs/components/PaypalPayment.js +1 -1
  61. package/lib/cjs/components/PlaceOrderButton.js +1 -1
  62. package/lib/cjs/components/PlaceOrderContainer.js +1 -1
  63. package/lib/cjs/components/Price.d.ts +2 -0
  64. package/lib/cjs/components/Price.js +1 -1
  65. package/lib/cjs/components/PricesContainer.js +1 -1
  66. package/lib/cjs/components/PrivacyAndTermsCheckbox.js +1 -1
  67. package/lib/cjs/components/QuantitySelector.js +1 -1
  68. package/lib/cjs/components/SaveAddressesButton.js +1 -1
  69. package/lib/cjs/components/SaveCustomerButton.js +1 -1
  70. package/lib/cjs/components/Shipment.js +1 -1
  71. package/lib/cjs/components/ShipmentField.js +1 -1
  72. package/lib/cjs/components/ShipmentsContainer.js +1 -1
  73. package/lib/cjs/components/ShippingAddressContainer.js +1 -1
  74. package/lib/cjs/components/ShippingAddressForm.js +1 -1
  75. package/lib/cjs/components/ShippingAmount.js +1 -1
  76. package/lib/cjs/components/ShippingMethod.js +1 -1
  77. package/lib/cjs/components/ShippingMethodName.js +1 -1
  78. package/lib/cjs/components/ShippingMethodPrice.js +1 -1
  79. package/lib/cjs/components/ShippingMethodRadioButton.d.ts +8 -4
  80. package/lib/cjs/components/ShippingMethodRadioButton.js +1 -1
  81. package/lib/cjs/components/SkuList.js +1 -1
  82. package/lib/cjs/components/SkuListsContainer.js +1 -1
  83. package/lib/cjs/components/SkuOption.js +1 -1
  84. package/lib/cjs/components/SkuOptionInput.js +1 -1
  85. package/lib/cjs/components/SkuOptionsContainer.js +1 -1
  86. package/lib/cjs/components/StockTransfer.js +1 -1
  87. package/lib/cjs/components/StockTransferField.js +1 -1
  88. package/lib/cjs/components/StripePayment.js +1 -1
  89. package/lib/cjs/components/SubTotalAmount.js +1 -1
  90. package/lib/cjs/components/SubmitButton.js +1 -1
  91. package/lib/cjs/components/TaxesAmount.js +1 -1
  92. package/lib/cjs/components/TotalAmount.js +1 -1
  93. package/lib/cjs/components/VariantSelector.js +1 -1
  94. package/lib/cjs/components/VariantsContainer.js +1 -1
  95. package/lib/cjs/components/WireTransferPayment.js +1 -1
  96. package/lib/cjs/components/gateways/AdyenGateway.js +1 -1
  97. package/lib/cjs/components/gateways/BraintreeGateway.js +1 -1
  98. package/lib/cjs/components/gateways/PaypalGateway.js +1 -1
  99. package/lib/cjs/components/gateways/StripeGateway.js +1 -1
  100. package/lib/cjs/components/gateways/WireTransferGateway.js +1 -1
  101. package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -1
  102. package/lib/cjs/components/utils/BaseField.js +1 -1
  103. package/lib/cjs/components/utils/BaseInput.js +1 -1
  104. package/lib/cjs/components/utils/BaseOrderPrice.js +1 -1
  105. package/lib/cjs/components/utils/BaseSelect.js +1 -1
  106. package/lib/cjs/components/utils/Parent.js +1 -1
  107. package/lib/cjs/components/utils/PaymentCardsTemplate.js +1 -1
  108. package/lib/cjs/components/utils/PriceTemplate.js +1 -1
  109. package/lib/cjs/components/utils/VariantTemplate.js +1 -1
  110. package/lib/cjs/components/utils/getAllErrors.js +1 -1
  111. package/lib/cjs/config/components.js +1 -1
  112. package/lib/cjs/config/currency.js +1 -1
  113. package/lib/cjs/context/AddressChildrenContext.js +1 -1
  114. package/lib/cjs/context/AddressContext.js +1 -1
  115. package/lib/cjs/context/AvailabilityContext.js +1 -1
  116. package/lib/cjs/context/BillingAddressContext.js +1 -1
  117. package/lib/cjs/context/BillingAddressFormContext.js +1 -1
  118. package/lib/cjs/context/CommerceLayerContext.js +1 -1
  119. package/lib/cjs/context/CouponAndGiftCardFormContext.js +1 -1
  120. package/lib/cjs/context/CustomerContext.js +1 -1
  121. package/lib/cjs/context/ExternalFunctionContext.js +1 -1
  122. package/lib/cjs/context/GiftCardContext.js +1 -1
  123. package/lib/cjs/context/ItemContext.js +1 -1
  124. package/lib/cjs/context/LineItemChildrenContext.js +1 -1
  125. package/lib/cjs/context/LineItemContext.js +1 -1
  126. package/lib/cjs/context/LineItemOptionChildrenContext.js +1 -1
  127. package/lib/cjs/context/OrderContext.js +1 -1
  128. package/lib/cjs/context/OrderStorageContext.js +1 -1
  129. package/lib/cjs/context/PaymentMethodChildrenContext.js +1 -1
  130. package/lib/cjs/context/PaymentMethodContext.js +1 -1
  131. package/lib/cjs/context/PaymentSourceContext.js +1 -1
  132. package/lib/cjs/context/PlaceOrderContext.js +1 -1
  133. package/lib/cjs/context/PricesContext.js +1 -1
  134. package/lib/cjs/context/ShipmentChildrenContext.js +1 -1
  135. package/lib/cjs/context/ShipmentContext.js +1 -1
  136. package/lib/cjs/context/ShippingAddressContext.js +1 -1
  137. package/lib/cjs/context/ShippingAddressFormContext.js +1 -1
  138. package/lib/cjs/context/ShippingMethodChildrenContext.js +1 -1
  139. package/lib/cjs/context/SkuListsContext.js +1 -1
  140. package/lib/cjs/context/SkuOptionChildrenContext.js +1 -1
  141. package/lib/cjs/context/SkuOptionsContext.js +1 -1
  142. package/lib/cjs/context/StockTransferChildrenContext.js +1 -1
  143. package/lib/cjs/context/VariantsContext.js +1 -1
  144. package/lib/cjs/index.d.ts +1 -0
  145. package/lib/cjs/index.js +1 -1
  146. package/lib/cjs/reducers/AddressReducer.js +1 -1
  147. package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
  148. package/lib/cjs/reducers/BillingAddressReducer.js +1 -1
  149. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  150. package/lib/cjs/reducers/GiftCardReducer.js +1 -1
  151. package/lib/cjs/reducers/ItemReducer.js +1 -1
  152. package/lib/cjs/reducers/LineItemReducer.js +1 -1
  153. package/lib/cjs/reducers/OrderReducer.js +1 -1
  154. package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
  155. package/lib/cjs/reducers/PlaceOrderReducer.js +1 -1
  156. package/lib/cjs/reducers/PriceReducer.js +1 -1
  157. package/lib/cjs/reducers/ShipmentReducer.js +1 -1
  158. package/lib/cjs/reducers/ShippingAddressReducer.js +1 -1
  159. package/lib/cjs/reducers/SkuListsReducer.js +1 -1
  160. package/lib/cjs/reducers/SkuOptionsReducer.js +1 -1
  161. package/lib/cjs/reducers/VariantReducer.js +1 -1
  162. package/lib/cjs/typings/errors.js +1 -1
  163. package/lib/cjs/typings/index.js +1 -1
  164. package/lib/cjs/utils/PropsType.js +1 -1
  165. package/lib/cjs/utils/addressesManager.js +1 -1
  166. package/lib/cjs/utils/baseReducer.js +1 -1
  167. package/lib/cjs/utils/browserInfo.js +1 -1
  168. package/lib/cjs/utils/childrenTypes.js +1 -1
  169. package/lib/cjs/utils/countryStateCity.js +1 -1
  170. package/lib/cjs/utils/customMessages.js +1 -1
  171. package/lib/cjs/utils/customerOrderOptions.js +1 -1
  172. package/lib/cjs/utils/getAmount.js +1 -1
  173. package/lib/cjs/utils/getCurrentItemKey.js +1 -1
  174. package/lib/cjs/utils/getErrors.js +1 -1
  175. package/lib/cjs/utils/getLineItemsCount.js +1 -1
  176. package/lib/cjs/utils/getLoaderComponent.js +1 -1
  177. package/lib/cjs/utils/getPrices.js +1 -1
  178. package/lib/cjs/utils/getSdk.js +1 -1
  179. package/lib/cjs/utils/getSkus.js +1 -1
  180. package/lib/cjs/utils/isEmptyStates.js +1 -1
  181. package/lib/cjs/utils/isJSON.js +1 -1
  182. package/lib/cjs/utils/jwt.js +1 -1
  183. package/lib/cjs/utils/localStorage.js +1 -1
  184. package/lib/cjs/utils/organization.js +1 -1
  185. package/lib/cjs/utils/paypalPayment.js +1 -1
  186. package/lib/cjs/utils/promisify.js +1 -1
  187. package/lib/cjs/utils/shipments.js +1 -1
  188. package/lib/cjs/utils/validateFormFields.js +1 -1
  189. package/lib/esm/components/AddToCartButton.js +1 -1
  190. package/lib/esm/components/Address.js +1 -1
  191. package/lib/esm/components/AddressCountrySelector.js +1 -1
  192. package/lib/esm/components/AddressField.js +1 -1
  193. package/lib/esm/components/AddressInput.js +1 -1
  194. package/lib/esm/components/AddressStateSelector.js +1 -1
  195. package/lib/esm/components/AddressesContainer.js +1 -1
  196. package/lib/esm/components/AdyenPayment.js +1 -1
  197. package/lib/esm/components/AvailabilityContainer.js +1 -1
  198. package/lib/esm/components/AvailabilityTemplate.js +1 -1
  199. package/lib/esm/components/BillingAddressContainer.js +1 -1
  200. package/lib/esm/components/BillingAddressForm.js +1 -1
  201. package/lib/esm/components/BraintreePayment.js +1 -1
  202. package/lib/esm/components/CheckoutLink.js +1 -1
  203. package/lib/esm/components/CommerceLayer.js +1 -1
  204. package/lib/esm/components/CustomerContainer.js +1 -1
  205. package/lib/esm/components/CustomerInput.js +1 -1
  206. package/lib/esm/components/DeliveryLeadTime.js +1 -1
  207. package/lib/esm/components/DiscountAmount.js +1 -1
  208. package/lib/esm/components/Errors.js +1 -1
  209. package/lib/esm/components/ExternalFunction.js +1 -1
  210. package/lib/esm/components/GiftCard.js +1 -1
  211. package/lib/esm/components/GiftCardAmount.js +1 -1
  212. package/lib/esm/components/GiftCardContainer.js +1 -1
  213. package/lib/esm/components/GiftCardCurrencySelector.js +1 -1
  214. package/lib/esm/components/GiftCardInput.js +1 -1
  215. package/lib/esm/components/GiftCardOrCouponCode.js +1 -1
  216. package/lib/esm/components/GiftCardOrCouponForm.js +1 -1
  217. package/lib/esm/components/GiftCardOrCouponInput.js +1 -1
  218. package/lib/esm/components/GiftCardOrCouponRemoveButton.js +1 -1
  219. package/lib/esm/components/GiftCardOrCouponSubmit.js +1 -1
  220. package/lib/esm/components/ItemContainer.js +1 -1
  221. package/lib/esm/components/LineItem.js +1 -1
  222. package/lib/esm/components/LineItemAmount.js +1 -1
  223. package/lib/esm/components/LineItemCode.js +1 -1
  224. package/lib/esm/components/LineItemImage.js +1 -1
  225. package/lib/esm/components/LineItemName.js +1 -1
  226. package/lib/esm/components/LineItemOption.js +1 -1
  227. package/lib/esm/components/LineItemOptions.js +1 -1
  228. package/lib/esm/components/LineItemQuantity.js +1 -1
  229. package/lib/esm/components/LineItemRemoveLink.js +1 -1
  230. package/lib/esm/components/LineItemsContainer.js +1 -1
  231. package/lib/esm/components/LineItemsCount.js +1 -1
  232. package/lib/esm/components/MetadataInput.js +1 -1
  233. package/lib/esm/components/OrderContainer.js +1 -1
  234. package/lib/esm/components/OrderNumber.js +1 -1
  235. package/lib/esm/components/OrderStorage.js +1 -1
  236. package/lib/esm/components/PaymentGateway.js +1 -1
  237. package/lib/esm/components/PaymentMethod.js +1 -1
  238. package/lib/esm/components/PaymentMethodAmount.js +1 -1
  239. package/lib/esm/components/PaymentMethodName.js +1 -1
  240. package/lib/esm/components/PaymentMethodPrice.js +1 -1
  241. package/lib/esm/components/PaymentMethodRadioButton.js +1 -1
  242. package/lib/esm/components/PaymentMethodsContainer.js +1 -1
  243. package/lib/esm/components/PaymentSource.js +1 -1
  244. package/lib/esm/components/PaymentSourceBrandIcon.js +1 -1
  245. package/lib/esm/components/PaymentSourceBrandName.js +1 -1
  246. package/lib/esm/components/PaymentSourceDetail.js +1 -1
  247. package/lib/esm/components/PaymentSourceEditButton.js +1 -1
  248. package/lib/esm/components/PaypalPayment.js +1 -1
  249. package/lib/esm/components/PlaceOrderButton.js +1 -1
  250. package/lib/esm/components/PlaceOrderContainer.js +1 -1
  251. package/lib/esm/components/Price.d.ts +2 -0
  252. package/lib/esm/components/Price.js +1 -1
  253. package/lib/esm/components/PricesContainer.js +1 -1
  254. package/lib/esm/components/PrivacyAndTermsCheckbox.js +1 -1
  255. package/lib/esm/components/QuantitySelector.js +1 -1
  256. package/lib/esm/components/SaveAddressesButton.js +1 -1
  257. package/lib/esm/components/SaveCustomerButton.js +1 -1
  258. package/lib/esm/components/Shipment.js +1 -1
  259. package/lib/esm/components/ShipmentField.js +1 -1
  260. package/lib/esm/components/ShipmentsContainer.js +1 -1
  261. package/lib/esm/components/ShippingAddressContainer.js +1 -1
  262. package/lib/esm/components/ShippingAddressForm.js +1 -1
  263. package/lib/esm/components/ShippingAmount.js +1 -1
  264. package/lib/esm/components/ShippingMethod.js +1 -1
  265. package/lib/esm/components/ShippingMethodName.js +1 -1
  266. package/lib/esm/components/ShippingMethodPrice.js +1 -1
  267. package/lib/esm/components/ShippingMethodRadioButton.d.ts +8 -4
  268. package/lib/esm/components/ShippingMethodRadioButton.js +1 -1
  269. package/lib/esm/components/SkuList.js +1 -1
  270. package/lib/esm/components/SkuListsContainer.js +1 -1
  271. package/lib/esm/components/SkuOption.js +1 -1
  272. package/lib/esm/components/SkuOptionInput.js +1 -1
  273. package/lib/esm/components/SkuOptionsContainer.js +1 -1
  274. package/lib/esm/components/StockTransfer.js +1 -1
  275. package/lib/esm/components/StockTransferField.js +1 -1
  276. package/lib/esm/components/StripePayment.js +1 -1
  277. package/lib/esm/components/SubTotalAmount.js +1 -1
  278. package/lib/esm/components/SubmitButton.js +1 -1
  279. package/lib/esm/components/TaxesAmount.js +1 -1
  280. package/lib/esm/components/TotalAmount.js +1 -1
  281. package/lib/esm/components/VariantSelector.js +1 -1
  282. package/lib/esm/components/VariantsContainer.js +1 -1
  283. package/lib/esm/components/WireTransferPayment.js +1 -1
  284. package/lib/esm/components/gateways/AdyenGateway.js +1 -1
  285. package/lib/esm/components/gateways/BraintreeGateway.js +1 -1
  286. package/lib/esm/components/gateways/PaypalGateway.js +1 -1
  287. package/lib/esm/components/gateways/StripeGateway.js +1 -1
  288. package/lib/esm/components/gateways/WireTransferGateway.js +1 -1
  289. package/lib/esm/components/utils/AddressCardsTemplate.js +1 -1
  290. package/lib/esm/components/utils/BaseField.js +1 -1
  291. package/lib/esm/components/utils/BaseInput.js +1 -1
  292. package/lib/esm/components/utils/BaseOrderPrice.js +1 -1
  293. package/lib/esm/components/utils/BaseSelect.js +1 -1
  294. package/lib/esm/components/utils/Parent.js +1 -1
  295. package/lib/esm/components/utils/PaymentCardsTemplate.js +1 -1
  296. package/lib/esm/components/utils/PriceTemplate.js +1 -1
  297. package/lib/esm/components/utils/VariantTemplate.js +1 -1
  298. package/lib/esm/components/utils/getAllErrors.js +1 -1
  299. package/lib/esm/config/components.js +1 -1
  300. package/lib/esm/context/AddressChildrenContext.js +1 -1
  301. package/lib/esm/context/AddressContext.js +1 -1
  302. package/lib/esm/context/CommerceLayerContext.js +1 -1
  303. package/lib/esm/context/CustomerContext.js +1 -1
  304. package/lib/esm/context/ExternalFunctionContext.js +1 -1
  305. package/lib/esm/context/LineItemChildrenContext.js +1 -1
  306. package/lib/esm/context/LineItemContext.js +1 -1
  307. package/lib/esm/context/LineItemOptionChildrenContext.js +1 -1
  308. package/lib/esm/context/OrderContext.js +1 -1
  309. package/lib/esm/context/OrderStorageContext.js +1 -1
  310. package/lib/esm/context/PaymentMethodChildrenContext.js +1 -1
  311. package/lib/esm/context/PaymentMethodContext.js +1 -1
  312. package/lib/esm/context/PlaceOrderContext.js +1 -1
  313. package/lib/esm/context/ShipmentChildrenContext.js +1 -1
  314. package/lib/esm/context/ShipmentContext.js +1 -1
  315. package/lib/esm/context/ShippingMethodChildrenContext.js +1 -1
  316. package/lib/esm/context/SkuOptionChildrenContext.js +1 -1
  317. package/lib/esm/context/StockTransferChildrenContext.js +1 -1
  318. package/lib/esm/index.d.ts +1 -0
  319. package/lib/esm/reducers/AddressReducer.js +1 -1
  320. package/lib/esm/reducers/AvailabilityReducer.js +1 -1
  321. package/lib/esm/reducers/BillingAddressReducer.js +1 -1
  322. package/lib/esm/reducers/CustomerReducer.js +1 -1
  323. package/lib/esm/reducers/GiftCardReducer.js +1 -1
  324. package/lib/esm/reducers/ItemReducer.js +1 -1
  325. package/lib/esm/reducers/LineItemReducer.js +1 -1
  326. package/lib/esm/reducers/OrderReducer.js +1 -1
  327. package/lib/esm/reducers/PaymentMethodReducer.js +1 -1
  328. package/lib/esm/reducers/PlaceOrderReducer.js +1 -1
  329. package/lib/esm/reducers/PriceReducer.js +1 -1
  330. package/lib/esm/reducers/ShipmentReducer.js +1 -1
  331. package/lib/esm/reducers/ShippingAddressReducer.js +1 -1
  332. package/lib/esm/reducers/SkuListsReducer.js +1 -1
  333. package/lib/esm/reducers/SkuOptionsReducer.js +1 -1
  334. package/lib/esm/reducers/VariantReducer.js +1 -1
  335. package/lib/esm/typings/errors.js +1 -1
  336. package/lib/esm/typings/index.js +1 -1
  337. package/lib/esm/utils/addressesManager.js +1 -1
  338. package/lib/esm/utils/baseReducer.js +1 -1
  339. package/lib/esm/utils/browserInfo.js +1 -1
  340. package/lib/esm/utils/childrenTypes.js +1 -1
  341. package/lib/esm/utils/countryStateCity.js +1 -1
  342. package/lib/esm/utils/customMessages.js +1 -1
  343. package/lib/esm/utils/getAmount.js +1 -1
  344. package/lib/esm/utils/getCurrentItemKey.js +1 -1
  345. package/lib/esm/utils/getErrors.js +1 -1
  346. package/lib/esm/utils/getLineItemsCount.js +1 -1
  347. package/lib/esm/utils/getLoaderComponent.js +1 -1
  348. package/lib/esm/utils/getPrices.js +1 -1
  349. package/lib/esm/utils/getSdk.js +1 -1
  350. package/lib/esm/utils/getSkus.js +1 -1
  351. package/lib/esm/utils/isEmptyStates.js +1 -1
  352. package/lib/esm/utils/isJSON.js +1 -1
  353. package/lib/esm/utils/jwt.js +1 -1
  354. package/lib/esm/utils/localStorage.js +1 -1
  355. package/lib/esm/utils/organization.js +1 -1
  356. package/lib/esm/utils/paypalPayment.js +1 -1
  357. package/lib/esm/utils/promisify.js +1 -1
  358. package/lib/esm/utils/shipments.js +1 -1
  359. package/lib/esm/utils/validateFormFields.js +1 -1
  360. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  361. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  362. package/package.json +18 -18
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const saveCustomerUser=async({customerEmail:e,order:s,updateOrder:t})=>{if(s){const r={customer_email:e,id:s.id};await t({id:s.id,attributes:r})}};export const setCustomerErrors=(e,s)=>{s&&s({type:"setErrors",payload:{errors:e}})};export const setCustomerEmail=(e,s)=>{s&&s({type:"setCustomerEmail",payload:{customerEmail:e}})};export const getCustomerAddresses=async({config:e,dispatch:s})=>{try{const t=[];const r=getSdk(e);const o=await r.customer_addresses.list({include:["address"]});o.forEach((e=>{if(e.address)t.push(e.address)}));s({type:"setAddresses",payload:{addresses:t}})}catch(e){const t=getErrors(e,"addresses");s({type:"setErrors",payload:{errors:t}})}};export const getCustomerPaymentSources=async({dispatch:e,order:s})=>{if(s===null||s===void 0?void 0:s.available_customer_payment_sources){e({type:"setPayments",payload:{payments:s.available_customer_payment_sources}})}};export const customerInitialState={errors:[],addresses:[],payments:[]};const type=["setErrors","setCustomerEmail","setAddresses","setPayments"];const customerReducer=(e,s)=>baseReducer(e,s,type);export default customerReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const saveCustomerUser=async({customerEmail,order,updateOrder})=>{if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}},setCustomerErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},setCustomerEmail=(customerEmail,dispatch)=>{dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})},getCustomerAddresses=async({config,dispatch})=>{try{const addresses=[];(await getSdk(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&addresses.push(customerAddress.address)}),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=getErrors(error,"addresses");dispatch({type:"setErrors",payload:{errors}})}},getCustomerPaymentSources=async({dispatch,order})=>{(order==null?void 0:order.available_customer_payment_sources)&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})},customerInitialState={errors:[],addresses:[],payments:[]};const type=["setErrors","setCustomerEmail","setAddresses","setPayments"],customerReducer=(state,reducer)=>baseReducer(state,reducer,type);export default customerReducer;
@@ -1 +1 @@
1
- import{__rest}from"tslib";import baseReducer from"../utils/baseReducer";import{isEmpty}from"lodash";import getErrors from"../utils/getErrors";import getSdk from"../utils/getSdk";export const giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:false,rechargeable:true,loading:false,expiresAt:null,errors:[]};export const addGiftCardRecipient=async(t,e,r)=>{try{const i=getSdk(e);const a=await i.gift_card_recipients.create(t);r({type:"setGiftCardRecipient",payload:{giftCardRecipient:a}})}catch(t){console.error(t)}};export const addGiftCardLoading=(t,e)=>{e({type:"setGiftCardLoading",payload:{loading:t}})};export const addGiftCard=async(t,{config:e,dispatch:r,getOrder:i,createOrder:a,order:d})=>{var s;try{const o=getSdk(e);addGiftCardLoading(true,r);const{firstName:c,lastName:n,email:f}=t,p=__rest(t,["firstName","lastName","email"]);const l=Object.assign({recipient_email:f},p);const g=await o.gift_cards.create(l,{include:["gift_card_recipient"]});const m={id:(s=g.gift_card_recipient)===null||s===void 0?void 0:s.id};if(c)m["first_name"]=c;if(n)m["last_name"]=n;if(!isEmpty(m)){await o.gift_card_recipients.update(m)}if(a&&i){const t=d?d.id:await a();if(t){const e=o.orders.relationship(t);const r=o.gift_cards.relationship(g.id);await o.line_items.create({quantity:1,order:e,item:r});i&&i(t)}}r({type:"setGiftCardRecipient",payload:Object.assign({},l)});addGiftCardLoading(false,r)}catch(t){const e=getErrors(t,"gift_cards");r({type:"setGiftCardErrors",payload:{errors:e}});addGiftCardLoading(false,r)}};export const addGiftCardError=(t,e)=>{e({type:"setGiftCardErrors",payload:{errors:t}})};const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"];const giftCardReducer=(t,e)=>baseReducer(t,e,type);export default giftCardReducer;
1
+ import{__rest}from"tslib";import baseReducer from"../utils/baseReducer";import{isEmpty}from"lodash";import getErrors from"../utils/getErrors";import getSdk from"../utils/getSdk";export const giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:!1,rechargeable:!0,loading:!1,expiresAt:null,errors:[]},addGiftCardRecipient=async(values,config,dispatch)=>{try{const recipient=await getSdk(config).gift_card_recipients.create(values);dispatch({type:"setGiftCardRecipient",payload:{giftCardRecipient:recipient}})}catch(error){console.error(error)}},addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})},addGiftCard=async(values,{config,dispatch,getOrder,createOrder,order})=>{var _a;try{const sdk=getSdk(config);addGiftCardLoading(!0,dispatch);const{firstName,lastName,email}=values,val=__rest(values,["firstName","lastName","email"]),giftCardValue=Object.assign({recipient_email:email},val),giftCard=await sdk.gift_cards.create(giftCardValue,{include:["gift_card_recipient"]}),recipientValues={id:(_a=giftCard.gift_card_recipient)===null||_a===void 0?void 0:_a.id};if(firstName&&(recipientValues.first_name=firstName),lastName&&(recipientValues.last_name=lastName),isEmpty(recipientValues)||await sdk.gift_card_recipients.update(recipientValues),createOrder&&getOrder){const id=order?order.id:await createOrder();if(id){const order2=sdk.orders.relationship(id),item=sdk.gift_cards.relationship(giftCard.id);await sdk.line_items.create({quantity:1,order:order2,item}),getOrder&&getOrder(id)}}dispatch({type:"setGiftCardRecipient",payload:Object.assign({},giftCardValue)}),addGiftCardLoading(!1,dispatch)}catch(error){const errors=getErrors(error,"gift_cards");dispatch({type:"setGiftCardErrors",payload:{errors}}),addGiftCardLoading(!1,dispatch)}},addGiftCardError=(errors,dispatch)=>{dispatch({type:"setGiftCardErrors",payload:{errors}})};const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"],giftCardReducer=(state,reducer)=>baseReducer(state,reducer,type);export default giftCardReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";export const setItemState=(t,e,s)=>{s({type:e.type,payload:{[`${e.key}`]:t}})};export const unsetItemState=t=>{t({type:"setItem",payload:{item:{}}});t({type:"setItems",payload:{items:{}}});t({type:"setQuantity",payload:{quantity:{}}});t({type:"setOption",payload:{option:{}}});t({type:"setCustomLineItems",payload:{lineItems:{}}});t({type:"setCustomLineItem",payload:{lineItem:{}}})};const actionType=["setItem","setItems","setQuantity","setOption","setPrices","setCustomLineItems","setCustomLineItem","setSkuCode"];export const itemInitialState={items:{},item:{},quantity:{},option:{},prices:{},lineItems:{},lineItem:{},skuCode:""};const itemReducer=(t,e)=>baseReducer(t,e,actionType);export default itemReducer;
1
+ import baseReducer from"../utils/baseReducer";export const setItemState=(data,params,dispatch)=>{dispatch({type:params.type,payload:{[`${params.key}`]:data}})},unsetItemState=dispatch=>{dispatch({type:"setItem",payload:{item:{}}}),dispatch({type:"setItems",payload:{items:{}}}),dispatch({type:"setQuantity",payload:{quantity:{}}}),dispatch({type:"setOption",payload:{option:{}}}),dispatch({type:"setCustomLineItems",payload:{lineItems:{}}}),dispatch({type:"setCustomLineItem",payload:{lineItem:{}}})};const actionType=["setItem","setItems","setQuantity","setOption","setPrices","setCustomLineItems","setCustomLineItem","setSkuCode"];export const itemInitialState={items:{},item:{},quantity:{},option:{},prices:{},lineItems:{},lineItem:{},skuCode:""};const itemReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default itemReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const getLineItems=e=>{const{order:t,dispatch:r,config:s}=e;const o=getSdk(s);let i=[];t&&o.orders.retrieve(t===null||t===void 0?void 0:t.id,{include:["line_items","line_items.line_item_options.sku_option"],fields:{orders:["line_items"]}}).then((e=>{r({type:"setLoading",payload:{loading:false}});const t=e.line_items||[];i=[...i,...t];r({type:"setLineItems",payload:{lineItems:i}})})).catch((e=>{const t=getErrors(e,"line_items");r({type:"setErrors",payload:{errors:t}})}))};export const updateLineItem=async e=>{const{config:t,lineItemId:r,quantity:s,getOrder:o,orderId:i,dispatch:n}=e;const a=getSdk(t);try{await a.line_items.update({id:r,quantity:s});o&&await o(i);n({type:"setErrors",payload:{errors:[]}})}catch(e){const t=getErrors(e,"line_items");n({type:"setErrors",payload:{errors:t}})}};export const deleteLineItem=async e=>{const{config:t,lineItemId:r,getOrder:s,orderId:o,dispatch:i}=e;const n=getSdk(t);try{await n.line_items.delete(r);s&&await s(o);i({type:"setErrors",payload:{errors:[]}})}catch(e){const t=getErrors(e,"line_items");i({type:"setErrors",payload:{errors:t}})}};export const lineItemInitialState={loading:false,lineItems:[],errors:[]};const actionType=["setLineItems","setErrors","setLoading"];const lineItemReducer=(e,t)=>baseReducer(e,t,actionType);export default lineItemReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const getLineItems=params=>{const{order,dispatch,config}=params,sdk=getSdk(config);let allLineItems=[];order&&sdk.orders.retrieve(order==null?void 0:order.id,{include:["line_items","line_items.line_item_options.sku_option"],fields:{orders:["line_items"]}}).then(response=>{dispatch({type:"setLoading",payload:{loading:!1}});const items=response.line_items||[];allLineItems=[...allLineItems,...items],dispatch({type:"setLineItems",payload:{lineItems:allLineItems}})}).catch(error=>{const errors=getErrors(error,"line_items");dispatch({type:"setErrors",payload:{errors}})})},updateLineItem=async params=>{const{config,lineItemId,quantity,getOrder,orderId,dispatch}=params,sdk=getSdk(config);try{await sdk.line_items.update({id:lineItemId,quantity}),getOrder&&await getOrder(orderId),dispatch({type:"setErrors",payload:{errors:[]}})}catch(error){const errors=getErrors(error,"line_items");dispatch({type:"setErrors",payload:{errors}})}},deleteLineItem=async params=>{const{config,lineItemId,getOrder,orderId,dispatch}=params,sdk=getSdk(config);try{await sdk.line_items.delete(lineItemId),getOrder&&await getOrder(orderId),dispatch({type:"setErrors",payload:{errors:[]}})}catch(error){const errors=getErrors(error,"line_items");dispatch({type:"setErrors",payload:{errors}})}},lineItemInitialState={loading:!1,lineItems:[],errors:[]};const actionType=["setLineItems","setErrors","setLoading"],lineItemReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default lineItemReducer;
@@ -1 +1 @@
1
- import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import{isEmpty,size,map}from"lodash";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export const createOrder=async e=>{if(e){const{persistKey:r,state:t,dispatch:s,config:o,orderMetadata:d,orderAttributes:c={},setLocalOrder:n}=e;if(t===null||t===void 0?void 0:t.orderId)return t.orderId;const a=getSdk(o);try{const e=await(a===null||a===void 0?void 0:a.orders.create(Object.assign({metadata:d},c)));s&&s({type:"setOrderId",payload:{orderId:e===null||e===void 0?void 0:e.id}});r&&n&&n(r,e.id);return e.id}catch(e){const r=getErrors(e,"orders");console.error("Create order",r);if(s)setErrors({currentErrors:t===null||t===void 0?void 0:t.errors,newErrors:r,dispatch:s})}}return""};export const getApiOrder=async e=>{const{id:r,dispatch:t,config:s,clearWhenPlaced:o,persistKey:d,deleteLocalOrder:c,state:n}=e;const a=getSdk(s);try{const e={};if((n===null||n===void 0?void 0:n.include)&&n.include.length>0){e.include=n.include}const s=await a.orders.retrieve(r,e);if(o&&s.status==="placed"||s.status==="approved"||s.status==="cancelled"){d&&c&&c(d);t&&t({type:"setOrder",payload:{order:undefined,orderId:""}})}else{t&&t({type:"setOrder",payload:{order:s,orderId:s.id}})}return s}catch(e){const r=getErrors(e,"orders");console.error("Retrieve order",r);if(t)setErrors({currentErrors:n===null||n===void 0?void 0:n.errors,newErrors:r,dispatch:t});return}};export async function updateOrder({id:e,attributes:r,dispatch:t,config:s,include:o}){const d=getSdk(s);try{const s=Object.assign(Object.assign({},r),{id:e});const c=await d.orders.update(s,{include:o});t&&t({type:"setOrder",payload:{order:c}})}catch(e){const r=getErrors(e,"orders");if(t){setOrderErrors({errors:r,dispatch:t});t({type:"setErrors",payload:{errors:r}})}}}export const setOrder=(e,r)=>{r&&r({type:"setOrder",payload:{order:e}})};export function addResourceToInclude({resourcesIncluded:e=[],dispatch:r,newResource:t,newResourceLoaded:s,resourceIncludedLoaded:o}){const d={include:undefined,includeLoaded:undefined};if(t){d.include=[...e,...typeof t==="string"?[t]:t]}else{delete d.include}d.includeLoaded=Object.assign(Object.assign({},o),s);r&&r({type:"setIncludesResource",payload:d})}export const addToCart=async e=>{const{skuCode:r,bundleCode:t,skuId:s,quantity:o,option:d,config:c,dispatch:n,lineItem:a,state:i,errors:u=[]}=e;try{const p=getSdk(c);const l=await createOrder(e);if(l){const c=p.orders.relationship(l);const y=a===null||a===void 0?void 0:a.name;const f=a===null||a===void 0?void 0:a.imageUrl;const g={order:c,sku_code:r,name:y,image_url:f,quantity:o||1,_update_quantity:true,bundle_code:t};if(s){g["item"]=p.skus.relationship(s)}const m=await p.line_items.create(g);if(!isEmpty(d)){let r=0;map(d,(async t=>{const{options:s,skuOptionId:o}=t;const c=p.sku_options.relationship(o);const n=p.line_items.relationship(m.id);const a={quantity:1,options:s,sku_option:c,line_item:n};await p.line_item_options.create(a);r+=1;if(r===size(d)){await getApiOrder(Object.assign({id:l},e))}}))}else{await getApiOrder(Object.assign(Object.assign({id:l},e),{state:i}))}if(!isEmpty(u)&&n){n({type:"setErrors",payload:{errors:[]}})}return{success:true}}return{success:false}}catch(e){const r=getErrors(e,"orders");console.error("Add to cart",r);if(n)setErrors({currentErrors:i===null||i===void 0?void 0:i.errors,newErrors:r,dispatch:n});return{success:false}}};export const unsetOrderState=e=>{e({type:"setOrderId",payload:{orderId:""}});e({type:"setOrder",payload:{order:undefined}})};export function setOrderErrors({dispatch:e,errors:r}){e&&e({type:"setErrors",payload:{errors:r}});return{success:false}}export const saveAddressToCustomerAddressBook=({type:e,value:r,dispatch:t})=>{const s=`_save_${e}_to_customer_address_book`;const o=`${r}`;setCustomerOrderParam(s,o);t&&t({type:"setSaveAddressToCustomerAddressBook",payload:{[s]:o}})};export const setGiftCardOrCouponCode=async({code:e,dispatch:r,config:t,order:s})=>{try{if(t&&s&&e&&r){const o=getSdk(t);const d={id:s.id,gift_card_or_coupon_code:e};const c=await o.orders.update(d);r({type:"setErrors",payload:{errors:[],order:c}});return{success:true}}return{success:false}}catch(e){const t=getErrors(e,"gift_card_or_coupon_code");r&&setOrderErrors({errors:t,dispatch:r});return{success:false}}};export const removeGiftCardOrCouponCode=async({codeType:e,dispatch:r,config:t,order:s})=>{try{if(t&&s&&r){const o=getSdk(t);const d={id:s.id,[e]:""};const c=await o.orders.update(d);r({type:"setErrors",payload:{errors:[],order:c}});return{success:true}}return{success:false}}catch(e){const t=getErrors(e,"gift_card_or_coupon_code");console.error("Remove gift card o coupon code",t);r&&setOrderErrors({errors:t,dispatch:r});return{success:false}}};export const orderInitialState={loading:false,orderId:"",order:undefined,errors:[]};const orderReducer=(e,r)=>baseReducer(e,r,actionType);export default orderReducer;
1
+ import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import{isEmpty,size,map}from"lodash";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export const createOrder=async params=>{if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state==null?void 0:state.orderId)return state.orderId;const sdk=getSdk(config);try{const o=await(sdk==null?void 0:sdk.orders.create(Object.assign({metadata},orderAttributes)));return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o==null?void 0:o.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=getErrors(error,"orders");console.error("Create order",errors),dispatch&&setErrors({currentErrors:state==null?void 0:state.errors,newErrors:errors,dispatch})}}return""},getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=getSdk(config);try{const options={};(state==null?void 0:state.include)&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.status==="placed"||order.status==="approved"||order.status==="cancelled"?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors(error,"orders");console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state==null?void 0:state.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include}){const sdk=getSdk(config);try{const resource=Object.assign(Object.assign({},attributes),{id}),order=await sdk.orders.update(resource,{include});dispatch&&dispatch({type:"setOrder",payload:{order}})}catch(error){const errors=getErrors(error,"orders");dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}}))}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};newResource?payload.include=[...resourcesIncluded,...typeof newResource=="string"?[newResource]:newResource]:delete payload.include,payload.includeLoaded=Object.assign(Object.assign({},resourceIncludedLoaded),newResourceLoaded),dispatch&&dispatch({type:"setIncludesResource",payload})}export const addToCart=async params=>{const{skuCode,bundleCode,skuId,quantity,option,config,dispatch,lineItem,state,errors=[]}=params;try{const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem==null?void 0:lineItem.name,imageUrl=lineItem==null?void 0:lineItem.imageUrl,attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity||1,_update_quantity:!0,bundle_code:bundleCode};skuId&&(attrs.item=sdk.skus.relationship(skuId));const newLineItem=await sdk.line_items.create(attrs);if(isEmpty(option))await getApiOrder(Object.assign(Object.assign({id},params),{state}));else{let c=0;map(option,async opt=>{const{options,skuOptionId}=opt,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),c+=1,c===size(option)&&await getApiOrder(Object.assign({id},params))})}return!isEmpty(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0}}return{success:!1}}catch(error){const errors2=getErrors(error,"orders");return console.error("Add to cart",errors2),dispatch&&setErrors({currentErrors:state==null?void 0:state.errors,newErrors:errors2,dispatch}),{success:!1}}},unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};export function setOrderErrors({dispatch,errors}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}export const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value}`;setCustomerOrderParam(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})},setGiftCardOrCouponCode=async({code,dispatch,config,order})=>{try{if(config&&order&&code&&dispatch){const sdk=getSdk(config),attributes={id:order.id,gift_card_or_coupon_code:code},orderUpdated=await sdk.orders.update(attributes);return dispatch({type:"setErrors",payload:{errors:[],order:orderUpdated}}),{success:!0}}return{success:!1}}catch(error){const errors=getErrors(error,"gift_card_or_coupon_code");return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}},removeGiftCardOrCouponCode=async({codeType,dispatch,config,order})=>{try{if(config&&order&&dispatch){const sdk=getSdk(config),attributes={id:order.id,[codeType]:""},orderUpdated=await sdk.orders.update(attributes);return dispatch({type:"setErrors",payload:{errors:[],order:orderUpdated}}),{success:!0}}return{success:!1}}catch(error){const errors=getErrors(error,"gift_card_or_coupon_code");return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}},orderInitialState={loading:!1,orderId:"",order:void 0,errors:[]};const orderReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default orderReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";import has from"lodash/has";import isEmpty from"lodash/isEmpty";export function setLoading({loading:e,dispatch:t}){t&&t({type:"setLoading",payload:{loading:e}})}export const setPaymentRef=({ref:e,dispatch:t})=>{if(e&&t){t({type:"setPaymentRef",payload:{currentPaymentMethodRef:e}})}};export const paymentMethodInitialState={errors:[]};export const setPaymentMethodErrors=(e,t)=>{t&&t({type:"setErrors",payload:{errors:e}})};export const getPaymentMethods=async({order:e,dispatch:t})=>{const r=e.available_payment_methods;const o=e.payment_method;const a=e.payment_source;t({type:"setPaymentMethods",payload:{paymentMethods:r,currentPaymentMethodId:o===null||o===void 0?void 0:o.id,currentPaymentMethodType:o===null||o===void 0?void 0:o.payment_source_type,paymentSource:a}})};export const setPaymentMethod=async({config:e,dispatch:t,order:r,paymentMethodId:o,updateOrder:a,setOrderErrors:s,paymentResource:n})=>{try{if(e&&r&&t&&n){localStorage.removeItem("_save_payment_source_to_customer_wallet");const d=getSdk(e);const c={payment_method:d.payment_methods.relationship(o)};t({type:"setPaymentMethods",payload:{currentPaymentMethodId:o,currentPaymentMethodType:n,errors:[]}});a&&await a({id:r.id,attributes:c});s&&s([])}}catch(e){const t=getErrors(e,"orders");console.error("Set payment method",t)}};export const setPaymentSource=async({config:e,dispatch:t,getOrder:r,attributes:o={},order:a,paymentResource:s,customerPaymentSourceId:n,paymentSourceId:d,updateOrder:c,errors:y})=>{try{if(e&&a){let y;const p=getSdk(e);if(!n){if(!d){const e=Object.assign(Object.assign({},o),{order:p.orders.relationship(a.id)});y=await p[s].create(e)}else{y=await p[s].update(Object.assign({id:d},o))}t&&t({type:"setPaymentSource",payload:{paymentSource:y,errors:[]}});r&&await r(a.id);return y}else{c&&await c({id:a.id,attributes:{_customer_payment_source_id:n}})}}}catch(e){const r=getErrors(e,"payment_methods");console.error("Set payment source:",r);if(t)setErrors({currentErrors:y,newErrors:r,dispatch:t})}return};export const updatePaymentSource=async({id:e,attributes:t,config:r,dispatch:o,paymentResource:a})=>{if(r){try{const s=getSdk(r);const n=await s[a].update(Object.assign({id:e},t));o&&o({type:"setPaymentSource",payload:{paymentSource:n}})}catch(e){console.error("Update payment source:",e)}}};export const destroyPaymentSource=async({paymentSourceId:e,paymentResource:t,dispatch:r})=>{if(e&&t){r&&r({type:"setPaymentSource",payload:{paymentSource:undefined}})}};export const setPaymentMethodConfig=(e,t)=>{t({type:"setPaymentMethodConfig",payload:{config:e}})};export function getPaymentConfig(e,t){const r=camelCase(e).replace("Payments","Payment").replace("Transfers","Transfer");return!isEmpty(t)&&has(t,r)?t[r]:undefined}const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"];const paymentMethodReducer=(e,t)=>baseReducer(e,t,type);export default paymentMethodReducer;
1
+ import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";import has from"lodash/has";import isEmpty from"lodash/isEmpty";export function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}export const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})},paymentMethodInitialState={errors:[]},setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod==null?void 0:paymentMethod.id,currentPaymentMethodType:paymentMethod==null?void 0:paymentMethod.payment_source_type,paymentSource}})},setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:getSdk(config).payment_methods.relationship(paymentMethodId)};dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),updateOrder&&await updateOrder({id:order.id,attributes}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=getErrors(error,"orders");console.error("Set payment method",errors)}},setPaymentSource=async({config,dispatch,getOrder,attributes={},order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=getSdk(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId)paymentSource=await sdk[paymentResource].update(Object.assign({id:paymentSourceId},attributes));else{const attrs=Object.assign(Object.assign({},attributes),{order:sdk.orders.relationship(order.id)});paymentSource=await sdk[paymentResource].create(attrs)}return dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),getOrder&&await getOrder(order.id),paymentSource}}}catch(error){const errors=getErrors(error,"payment_methods");console.error("Set payment source:",errors),dispatch&&setErrors({currentErrors,newErrors:errors,dispatch})}},updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await getSdk(config)[paymentResource].update(Object.assign({id},attributes));dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}},destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};export function getPaymentConfig(paymentResource,config){const resource=camelCase(paymentResource).replace("Payments","Payment").replace("Transfers","Transfer");return!isEmpty(config)&&has(config,resource)?config[resource]:void 0}const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>baseReducer(state,reducer,type);export default paymentMethodReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import{shipmentsFilled}from"../utils/shipments";import{saveBillingAddress,saveShippingAddress,saveToWallet}from"../utils/customerOrderOptions";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const placeOrderInitialState={errors:[],isPermitted:false};export const setPlaceOrderErrors=(e,t)=>{t&&t({type:"setErrors",payload:{errors:e}})};export const placeOrderPermitted=async({config:e,order:t,dispatch:r,options:s})=>{var a;if(t&&e){let e=true;if(t.privacy_url&&t.terms_url){e=localStorage.getItem("privacy-terms")==="true"}const i=t.billing_address;if(isEmpty(i))e=false;const o=t.shipping_address;if(isEmpty(o))e=false;const d=t.shipments;const p=d&&shipmentsFilled(d);if(!isEmpty(d)&&!p)e=false;const l=t.payment_method;const n=t.payment_source;if(t.total_amount_with_taxes_cents!==0&&isEmpty(l===null||l===void 0?void 0:l.id))e=false;r({type:"setPlaceOrderPermitted",payload:{isPermitted:e,paymentType:l===null||l===void 0?void 0:l.payment_source_type,paymentSecret:n===null||n===void 0?void 0:n.client_secret,paymentId:(a=n===null||n===void 0?void 0:n.options)===null||a===void 0?void 0:a.id,paymentSource:n,options:s}})}};export const setPlaceOrder=async({state:e,order:t,config:r,setOrderErrors:s,paymentSource:a})=>{const i={placed:false};try{if(e&&t&&r&&a){const o=getSdk(r);const{options:d,paymentType:p}=e;if(p==="paypal_payments"){if(!(d===null||d===void 0?void 0:d.paypalPayerId)&&(a===null||a===void 0?void 0:a.approval_url)){window.location.href=a===null||a===void 0?void 0:a.approval_url;return i}await o.paypal_payments.update({id:a.id,paypal_payer_id:d===null||d===void 0?void 0:d.paypalPayerId})}const l={id:t.id,_place:true};if(saveBillingAddress()){await o.orders.update({id:t.id,_save_billing_address_to_customer_address_book:true})}if(saveShippingAddress()){await o.orders.update({id:t.id,_save_shipping_address_to_customer_address_book:true})}switch(p){case"braintree_payments":if(saveToWallet()){await o.orders.update({id:t.id,_save_payment_source_to_customer_wallet:true})}await o.orders.update(l);s&&s([]);return{placed:true};default:if(saveToWallet()){await o.orders.update({id:t.id,_save_payment_source_to_customer_wallet:true})}await o.orders.update(l);s&&s([]);return{placed:true}}}return i}catch(e){const t=getErrors(e,"orders");s&&s(t);return Object.assign(Object.assign({},i),{errors:t})}};const type=["setErrors","setPlaceOrderPermitted"];const placeOrderReducer=(e,t)=>baseReducer(e,t,type);export default placeOrderReducer;
1
+ import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import{shipmentsFilled}from"../utils/shipments";import{saveBillingAddress,saveShippingAddress,saveToWallet}from"../utils/customerOrderOptions";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const placeOrderInitialState={errors:[],isPermitted:!1},setPlaceOrderErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},placeOrderPermitted=async({config,order,dispatch,options})=>{var _a;if(order&&config){let isPermitted=!0;order.privacy_url&&order.terms_url&&(isPermitted=localStorage.getItem("privacy-terms")==="true");const billingAddress=order.billing_address;isEmpty(billingAddress)&&(isPermitted=!1);const shippingAddress=order.shipping_address;isEmpty(shippingAddress)&&(isPermitted=!1);const shipments=order.shipments,shipment=shipments&&shipmentsFilled(shipments);!isEmpty(shipments)&&!shipment&&(isPermitted=!1);const paymentMethod=order.payment_method,paymentSource=order.payment_source;order.total_amount_with_taxes_cents!==0&&isEmpty(paymentMethod==null?void 0:paymentMethod.id)&&(isPermitted=!1),dispatch({type:"setPlaceOrderPermitted",payload:{isPermitted,paymentType:paymentMethod==null?void 0:paymentMethod.payment_source_type,paymentSecret:paymentSource==null?void 0:paymentSource.client_secret,paymentId:(_a=paymentSource==null?void 0:paymentSource.options)===null||_a===void 0?void 0:_a.id,paymentSource,options}})}},setPlaceOrder=async({state,order,config,setOrderErrors,paymentSource})=>{const response={placed:!1};try{if(state&&order&&config&&paymentSource){const sdk=getSdk(config),{options,paymentType}=state;if(paymentType==="paypal_payments"){if(!(options==null?void 0:options.paypalPayerId)&&(paymentSource==null?void 0:paymentSource.approval_url))return window.location.href=paymentSource==null?void 0:paymentSource.approval_url,response;await sdk.paypal_payments.update({id:paymentSource.id,paypal_payer_id:options==null?void 0:options.paypalPayerId})}const updateAttributes={id:order.id,_place:!0};switch(saveBillingAddress()&&await sdk.orders.update({id:order.id,_save_billing_address_to_customer_address_book:!0}),saveShippingAddress()&&await sdk.orders.update({id:order.id,_save_shipping_address_to_customer_address_book:!0}),paymentType){case"braintree_payments":return saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0}),await sdk.orders.update(updateAttributes),setOrderErrors&&setOrderErrors([]),{placed:!0};default:return saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0}),await sdk.orders.update(updateAttributes),setOrderErrors&&setOrderErrors([]),{placed:!0}}}return response}catch(error){const errors=getErrors(error,"orders");return setOrderErrors&&setOrderErrors(errors),Object.assign(Object.assign({},response),{errors})}};const type=["setErrors","setPlaceOrderPermitted"],placeOrderReducer=(state,reducer)=>baseReducer(state,reducer,type);export default placeOrderReducer;
@@ -1 +1 @@
1
- import getPrices from"../utils/getPrices";import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const priceInitialState={loading:true,prices:{},skuCodes:[],errors:[]};export const getSkusPrice=(e,{config:t,dispatch:s,setPrices:r,prices:i,perPage:c,filters:o})=>{let a={};const p=getSdk(t);p.prices.list({filters:Object.assign({sku_code_in:e.join(",")},o),pageSize:c}).then((async t=>{const n=getPrices(t);a=Object.assign(Object.assign(Object.assign({},a),i),n);if(r){r(a)}s({type:"setPrices",payload:{prices:a}});s({type:"setLoading",payload:{loading:false}});const g=t.meta;if(g.pageCount>1){for(let t=g.currentPage+1;t<=g.pageCount;t++){const i=await p.prices.list({filters:Object.assign({sku_code_in:e.join(",")},o),pageSize:c,pageNumber:t});const n=getPrices(i);a=Object.assign(Object.assign({},a),n);if(r){r(a)}s({type:"setPrices",payload:{prices:a}})}}})).catch((e=>{const t=getErrors(e,"prices");s({type:"setErrors",payload:{errors:t}})}))};export const unsetPriceState=e=>{e({type:"setPrices",payload:{prices:{}}});e({type:"setLoading",payload:{loading:false}})};const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"];const priceReducer=(e,t)=>baseReducer(e,t,typeAction);export default priceReducer;
1
+ import getPrices from"../utils/getPrices";import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]},getSkusPrice=(skuCodes,{config,dispatch,setPrices,prices,perPage,filters})=>{let allPrices={};const sdk=getSdk(config);sdk.prices.list({filters:Object.assign({sku_code_in:skuCodes.join(",")},filters),pageSize:perPage}).then(async response=>{const pricesObj=getPrices(response);allPrices=Object.assign(Object.assign(Object.assign({},allPrices),prices),pricesObj),setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}}),dispatch({type:"setLoading",payload:{loading:!1}});const meta=response.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const pageResponse=await sdk.prices.list({filters:Object.assign({sku_code_in:skuCodes.join(",")},filters),pageSize:perPage,pageNumber}),pricesObj2=getPrices(pageResponse);allPrices=Object.assign(Object.assign({},allPrices),pricesObj2),setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}})}}).catch(error=>{const errors=getErrors(error,"prices");dispatch({type:"setErrors",payload:{errors}})})},unsetPriceState=dispatch=>{dispatch({type:"setPrices",payload:{prices:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})};const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"],priceReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default priceReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]};export const setShipmentErrors=(e,t)=>{t&&t({type:"setErrors",payload:{errors:e}})};export const getShipments=async({order:e,dispatch:t,config:s})=>{try{const i=getSdk(s);const o=e.shipments;const r=await i.delivery_lead_times.list({include:["shipping_method","stock_location"]});t({type:"setShipments",payload:{shipments:o,deliveryLeadTimes:r}})}catch(e){console.error(e)}};export const setShippingMethod=async({config:e,shipmentId:t,shippingMethodId:s,getOrder:i,order:o})=>{try{if(s){const r=getSdk(e);await r.shipments.update({id:t,shipping_method:r.shipping_methods.relationship(s)});if(i&&o)i(o.id)}}catch(e){console.error(e)}};const type=["setErrors","setShipments","setShippingMethod"];const shipmentReducer=(e,t)=>baseReducer(e,t,type);export default shipmentReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]},setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getShipments=async({order,dispatch,config})=>{try{const sdk=getSdk(config),shipments=order.shipments,deliveryLeadTimes=await sdk.delivery_lead_times.list({include:["shipping_method","stock_location"]});dispatch({type:"setShipments",payload:{shipments,deliveryLeadTimes}})}catch(error){console.error(error)}},setShippingMethod=async({config,shipmentId,shippingMethodId,getOrder,order})=>{try{if(shippingMethodId){const sdk=getSdk(config);await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(shippingMethodId)}),getOrder&&order&&getOrder(order.id)}}catch(error){console.error(error)}};const type=["setErrors","setShipments","setShippingMethod"],shipmentReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shipmentReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shippingAddressInitialState={_shipping_address_clone_id:""};export const setShippingAddress=async(e,s)=>{try{if(s===null||s===void 0?void 0:s.order){if(s.customerAddressId){const d=getSdk(s.config);const r={id:e,reference:s.customerAddressId};await d.addresses.update(r)}s.dispatch({type:"setShippingAddress",payload:{_shipping_address_clone_id:e}})}}catch(e){console.error(e)}};export const setShippingCustomerAddressId=async({dispatch:e,order:s,setCloneAddress:d})=>{var r;const i=(r=s===null||s===void 0?void 0:s.shipping_address)===null||r===void 0?void 0:r.reference;try{if(i){e({type:"setShippingCustomerAddressId",payload:{shippingCustomerAddressId:i}});d(i,"shipping_address")}}catch(e){console.error("error",e)}};const type=["setShippingAddress","setShippingCustomerAddressId","cleanup"];const shippingAddressReducer=(e,s)=>baseReducer(e,s,type);export default shippingAddressReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shippingAddressInitialState={_shipping_address_clone_id:""},setShippingAddress=async(id,options)=>{try{if(options==null?void 0:options.order){if(options.customerAddressId){const sdk=getSdk(options.config),attributes={id,reference:options.customerAddressId};await sdk.addresses.update(attributes)}options.dispatch({type:"setShippingAddress",payload:{_shipping_address_clone_id:id}})}}catch(error){console.error(error)}},setShippingCustomerAddressId=async({dispatch,order,setCloneAddress})=>{var _a;const customerAddressId=(_a=order==null?void 0:order.shipping_address)===null||_a===void 0?void 0:_a.reference;try{customerAddressId&&(dispatch({type:"setShippingCustomerAddressId",payload:{shippingCustomerAddressId:customerAddressId}}),setCloneAddress(customerAddressId,"shipping_address"))}catch(error){console.error("error",error)}};const type=["setShippingAddress","setShippingCustomerAddressId","cleanup"],shippingAddressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shippingAddressReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";const actionType=["getSkuList","setSkuList"];export const skuListsInitialState={listIds:[]};export const getSkuList=async({listIds:s,config:t,dispatch:e})=>{const c={};try{const i=getSdk(t);s.forEach((async s=>{const t=await i.sku_lists.retrieve(s,{include:["skus"],fields:{skus:["code"]}});const e=t.skus;c[s]=e}));e({payload:{skuLists:c},type:"getSkuList"})}catch(s){console.error(s)}};const skuListsReducer=(s,t)=>baseReducer(s,t,actionType);export default skuListsReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";const actionType=["getSkuList","setSkuList"];export const skuListsInitialState={listIds:[]},getSkuList=async({listIds,config,dispatch})=>{const skuLists={};try{const sdk=getSdk(config);listIds.forEach(async id=>{const skuCodes=(await sdk.sku_lists.retrieve(id,{include:["skus"],fields:{skus:["code"]}})).skus;skuLists[id]=skuCodes}),dispatch({payload:{skuLists},type:"getSkuList"})}catch(error){console.error(error)}};const skuListsReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default skuListsReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";export const getSkuOptions=async t=>{const{skuOptions:s,dispatch:e}=t;e({type:"setSkuOptions",payload:{skuOptions:s}})};export const unsetSkuOptionsState=t=>{t({type:"setSkuOptions",payload:{skuOptions:[]}});t({type:"setErrors",payload:{errors:[]}})};const actionType=["setSkuOptions","setErrors"];export const skuOptionsInitialState={skuCode:"",skuOptions:[]};const skuOptionsReducer=(t,s)=>baseReducer(t,s,actionType);export default skuOptionsReducer;
1
+ import baseReducer from"../utils/baseReducer";export const getSkuOptions=async params=>{const{skuOptions,dispatch}=params;dispatch({type:"setSkuOptions",payload:{skuOptions}})},unsetSkuOptionsState=dispatch=>{dispatch({type:"setSkuOptions",payload:{skuOptions:[]}}),dispatch({type:"setErrors",payload:{errors:[]}})};const actionType=["setSkuOptions","setErrors"];export const skuOptionsInitialState={skuCode:"",skuOptions:[]};const skuOptionsReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default skuOptionsReducer;
@@ -1 +1 @@
1
- import baseReducer from"../utils/baseReducer";import getSkus from"../utils/getSkus";import{isEmpty,has}from"lodash";import getSdk from"../utils/getSdk";export const setVariantSkuCodes=({skuCodes:e,dispatch:t,setCustomLineItems:s})=>{const o={};const a=e.map((e=>{if(has(e,"lineItem")){o[e.code]=e.lineItem}return e.code}));if(!isEmpty(o)){s&&s(o)}t({type:"setSkuCodes",payload:{skuCodes:a}})};export const setSkuCode=e=>{const{id:t,code:s,config:o,setItem:a,dispatch:r}=e;if(t){const e=getSdk(o);e.skus.retrieve(t,{include:["sku_options"]}).then((e=>{a&&a({[`${s}`]:e})})).catch((e=>{debugger;r({type:"setErrors",payload:{errors:e}})}))}};export const getVariants=e=>{const{config:t,state:s,skuCode:o,dispatch:a,setItem:r,filters:n}=e;const i=getSdk(t);i.skus.list({filters:Object.assign({code_in:s.skuCodes.join(",")},n)}).then((e=>{const n=getSkus(e,s.skuCodes);if(o){setSkuCode({code:n[o].code,id:n[o].id,config:t,dispatch:a,setItem:r})}a({type:"setVariants",payload:{variants:n}});a({type:"setLoading",payload:{loading:false}})})).catch((e=>{a({type:"setErrors",payload:{errors:e}})}))};export const unsetVariantState=e=>{e({type:"setSkuCode",payload:{skuCode:""}});e({type:"setVariants",payload:{variants:{}}});e({type:"setLoading",payload:{loading:false}})};export const variantInitialState={loading:false,variants:{},skuCodes:[],skuCode:"",errors:[],currentSkuId:"",currentSkuInventory:{available:false,quantity:0,levels:[]},currentQuantity:1,currentPrices:[]};const actionType=["setLoading","setVariants","setSkuCodes","setSkuCode","setCurrentSkuId","setCurrentSkuInventory","setCurrentPrices","setErrors"];const variantReducer=(e,t)=>baseReducer(e,t,actionType);export default variantReducer;
1
+ import baseReducer from"../utils/baseReducer";import getSkus from"../utils/getSkus";import{isEmpty,has}from"lodash";import getSdk from"../utils/getSdk";export const setVariantSkuCodes=({skuCodes,dispatch,setCustomLineItems})=>{const lineItems={},sCodes=skuCodes.map(s=>(has(s,"lineItem")&&(lineItems[s.code]=s.lineItem),s.code));isEmpty(lineItems)||setCustomLineItems&&setCustomLineItems(lineItems),dispatch({type:"setSkuCodes",payload:{skuCodes:sCodes}})},setSkuCode=params=>{const{id,code,config,setItem,dispatch}=params;id&&getSdk(config).skus.retrieve(id,{include:["sku_options"]}).then(sku=>{setItem&&setItem({[`${code}`]:sku})}).catch(errors=>{debugger;dispatch({type:"setErrors",payload:{errors}})})},getVariants=params=>{const{config,state,skuCode,dispatch,setItem,filters}=params;getSdk(config).skus.list({filters:Object.assign({code_in:state.skuCodes.join(",")},filters)}).then(skus=>{const skusObj=getSkus(skus,state.skuCodes);skuCode&&setSkuCode({code:skusObj[skuCode].code,id:skusObj[skuCode].id,config,dispatch,setItem}),dispatch({type:"setVariants",payload:{variants:skusObj}}),dispatch({type:"setLoading",payload:{loading:!1}})}).catch(errors=>{dispatch({type:"setErrors",payload:{errors}})})},unsetVariantState=dispatch=>{dispatch({type:"setSkuCode",payload:{skuCode:""}}),dispatch({type:"setVariants",payload:{variants:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})},variantInitialState={loading:!1,variants:{},skuCodes:[],skuCode:"",errors:[],currentSkuId:"",currentSkuInventory:{available:!1,quantity:0,levels:[]},currentQuantity:1,currentPrices:[]};const actionType=["setLoading","setVariants","setSkuCodes","setSkuCode","setCurrentSkuId","setCurrentSkuInventory","setCurrentPrices","setErrors"],variantReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default variantReducer;
@@ -1 +1 @@
1
- import PropTypes from"prop-types";const CEType=["EMPTY_ERROR","FILTER_NOT_ALLOWED","FORBIDDEN","INTERNAL_SERVER_ERROR","INVALID_DATA_FORMAT","INVALID_FIELD","INVALID_FIELD_FORMAT","INVALID_FIELD_VALUE","INVALID_FILTERS_SYNTAX","INVALID_FILTER_VALUE","INVALID_INCLUDE","INVALID_LINKS_OBJECT","INVALID_PAGE_OBJECT","INVALID_PAGE_VALUE","INVALID_RESOURCE","INVALID_RESOURCE_ID","INVALID_SORT_CRITERIA","INVALID_TOKEN","KEY_NOT_INCLUDED_IN_URL","KEY_ORDER_MISMATCH","LOCKED","NOT_ACCEPTABLE","PARAM_MISSING","PARAM_NOT_ALLOWED","RECORD_NOT_FOUND","RECORD_NOT_FOUND","RELATION_EXISTS","SAVE_FAILED","TYPE_MISMATCH","UNAUTHORIZED","UNSUPPORTED_MEDIA_TYPE","VALIDATION_ERROR"];export const REType=["gift_cards","line_items","orders","prices","sku_options","variant"];export const BaseErrorObject=PropTypes.shape({code:PropTypes.oneOf(CEType).isRequired,message:PropTypes.string.isRequired,resource:PropTypes.oneOf(REType),field:PropTypes.string,id:PropTypes.string});export const ErrorPropTypes={resource:PropTypes.oneOf(["billing_address","gift_cards","line_items","orders","payment_methods","prices","shipping_address","sku_options","variant"]).isRequired,children:PropTypes.func,field:PropTypes.string};
1
+ import PropTypes from"prop-types";const CEType=["EMPTY_ERROR","FILTER_NOT_ALLOWED","FORBIDDEN","INTERNAL_SERVER_ERROR","INVALID_DATA_FORMAT","INVALID_FIELD","INVALID_FIELD_FORMAT","INVALID_FIELD_VALUE","INVALID_FILTERS_SYNTAX","INVALID_FILTER_VALUE","INVALID_INCLUDE","INVALID_LINKS_OBJECT","INVALID_PAGE_OBJECT","INVALID_PAGE_VALUE","INVALID_RESOURCE","INVALID_RESOURCE_ID","INVALID_SORT_CRITERIA","INVALID_TOKEN","KEY_NOT_INCLUDED_IN_URL","KEY_ORDER_MISMATCH","LOCKED","NOT_ACCEPTABLE","PARAM_MISSING","PARAM_NOT_ALLOWED","RECORD_NOT_FOUND","RECORD_NOT_FOUND","RELATION_EXISTS","SAVE_FAILED","TYPE_MISMATCH","UNAUTHORIZED","UNSUPPORTED_MEDIA_TYPE","VALIDATION_ERROR"];export const REType=["gift_cards","line_items","orders","prices","sku_options","variant"],BaseErrorObject=PropTypes.shape({code:PropTypes.oneOf(CEType).isRequired,message:PropTypes.string.isRequired,resource:PropTypes.oneOf(REType),field:PropTypes.string,id:PropTypes.string}),ErrorPropTypes={resource:PropTypes.oneOf(["billing_address","gift_cards","line_items","orders","payment_methods","prices","shipping_address","sku_options","variant"]).isRequired,children:PropTypes.func,field:PropTypes.string};
@@ -1 +1 @@
1
- import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string};export const PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]);export const BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired};export const BaseInputComponentPropTypes={children:PropTypes.func,name:PropTypes.string.isRequired,type:PropTypes.oneOf(["text","email","number","date","checkbox","textarea"]).isRequired,onChange:PropTypes.func,placeholder:PropTypes.string};export const BMObject=PropTypes.objectOf(PropTypes.string);export const baseOrderPricePropTypes=Object.assign({base:PropTypes.string.isRequired,type:PropTypes.string.isRequired,children:PropTypes.func,format:PropTypes.oneOf(["formatted","cents","float"])},BC);export const baseOrderComponentPricePropTypes=Object.assign({children:baseOrderPricePropTypes["children"],format:baseOrderPricePropTypes["format"]},BC);
1
+ import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string},PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]),BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired},BaseInputComponentPropTypes={children:PropTypes.func,name:PropTypes.string.isRequired,type:PropTypes.oneOf(["text","email","number","date","checkbox","textarea"]).isRequired,onChange:PropTypes.func,placeholder:PropTypes.string},BMObject=PropTypes.objectOf(PropTypes.string),baseOrderPricePropTypes=Object.assign({base:PropTypes.string.isRequired,type:PropTypes.string.isRequired,children:PropTypes.func,format:PropTypes.oneOf(["formatted","cents","float"])},BC),baseOrderComponentPricePropTypes=Object.assign({children:baseOrderPricePropTypes.children,format:baseOrderPricePropTypes.format},BC);
@@ -1 +1 @@
1
- import{isEmpty}from"lodash";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address:i,billingAddressId:s,errors:e,requiresBillingInfo:r})=>{let d=!isEmpty(e)||isEmpty(i);if(isEmpty(e)&&!isEmpty(i)){let s=[...addressFields];if(r)s=[...s,"billing_info"];d=!!(i&&fieldsExist(i,s))}if(d&&!isEmpty(s)&&isEmpty(i)){d=false}return d};export const shippingAddressController=({billingDisable:i,errors:s,shipToDifferentAddress:e,shipping_address:r,shippingAddressId:d})=>{let t=!!(!i&&e);if(t&&isEmpty(s)&&!isEmpty(r)){t=!!(r&&fieldsExist(r))}if(t&&!isEmpty(d)&&isEmpty(r)){t=false}return t};export const countryLockController=({addresses:i,billing_address:s,billingAddressId:e,countryCodeLock:r,shipToDifferentAddress:d,shipping_address:t,shippingAddressId:o})=>{if(r&&!isEmpty(i)&&e&&!d){const s=i===null||i===void 0?void 0:i.find((i=>(i.id===e||i.reference===e)&&i.countryCode!==r));if(!isEmpty(s))return true}if(r&&!isEmpty(s)&&!d){return(s===null||s===void 0?void 0:s["country_code"])!==r}if(r&&!isEmpty(t)&&d){return(t===null||t===void 0?void 0:t["country_code"])!==r}if(r&&!isEmpty(i)&&o&&d){const s=i===null||i===void 0?void 0:i.find((i=>(i.id===o||i.reference===o)&&i.countryCode!==r));if(!isEmpty(s))return true}return false};
1
+ import{isEmpty}from"lodash";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address,billingAddressId,errors,requiresBillingInfo})=>{let billingDisable=!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address)){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),billingDisable=!!(billing_address&&fieldsExist(billing_address,billingInfo))}return billingDisable&&!isEmpty(billingAddressId)&&isEmpty(billing_address)&&(billingDisable=!1),billingDisable},shippingAddressController=({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId})=>{let shippingDisable=!!(!billingDisable&&shipToDifferentAddress);return shippingDisable&&isEmpty(errors)&&!isEmpty(shipping_address)&&(shippingDisable=!!(shipping_address&&fieldsExist(shipping_address))),shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable},countryLockController=({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId})=>{if(countryCodeLock&&!isEmpty(addresses)&&billingAddressId&&!shipToDifferentAddress){const addressLocked=addresses==null?void 0:addresses.find(a=>(a.id===billingAddressId||a.reference===billingAddressId)&&a.countryCode!==countryCodeLock);if(!isEmpty(addressLocked))return!0}if(countryCodeLock&&!isEmpty(billing_address)&&!shipToDifferentAddress)return(billing_address==null?void 0:billing_address.country_code)!==countryCodeLock;if(countryCodeLock&&!isEmpty(shipping_address)&&shipToDifferentAddress)return(shipping_address==null?void 0:shipping_address.country_code)!==countryCodeLock;if(countryCodeLock&&!isEmpty(addresses)&&shippingAddressId&&shipToDifferentAddress){const addressLocked=addresses==null?void 0:addresses.find(a=>(a.id===shippingAddressId||a.reference===shippingAddressId)&&a.countryCode!==countryCodeLock);if(!isEmpty(addressLocked))return!0}return!1};
@@ -1 +1 @@
1
- const baseReducer=(e,s,t)=>{const a=t;if(a.indexOf(s.type)!==-1){const t=s.payload;e=Object.assign(Object.assign({},e),t)}return e};export default baseReducer;
1
+ const baseReducer=(state,action,actionTypes)=>{if(actionTypes.indexOf(action.type)!==-1){const data=action.payload;state=Object.assign(Object.assign({},state),data)}return state};export default baseReducer;
@@ -1 +1 @@
1
- export default function getBrowserInfo(){const n=window&&window.screen?window.screen.width:"";const e=window&&window.screen?window.screen.height:"";const o=window&&window.screen?window.screen.colorDepth:"";const w=window&&window.navigator?window.navigator.userAgent:"";const t=window&&window.navigator?navigator.javaEnabled():false;let i="";if(window&&window.navigator)i=window.navigator.language;const a=new Date;const r=a.getTimezoneOffset();const d={screenWidth:n,screenHeight:e,colorDepth:o,userAgent:w,timeZoneOffset:r,language:i,javaEnabled:t};return d}
1
+ export default function getBrowserInfo(){const screenWidth=window&&window.screen?window.screen.width:"",screenHeight=window&&window.screen?window.screen.height:"",colorDepth=window&&window.screen?window.screen.colorDepth:"",userAgent=window&&window.navigator?window.navigator.userAgent:"",javaEnabled=window&&window.navigator?navigator.javaEnabled():!1;let language="";window&&window.navigator&&(language=window.navigator.language);const timeZoneOffset=new Date().getTimezoneOffset();return{screenWidth,screenHeight,colorDepth,userAgent,timeZoneOffset,language,javaEnabled}}
@@ -1 +1 @@
1
- import{isValidElement,Children}from"react";import{isEmpty,isFunction,has,get}from"lodash";import components from"../config/components";const checkChildrenTypes=(e,i,n)=>{let t=null;const s=e[i];const r=n.replace("CL","");if((isEmpty(s)&&typeof s!=="function"||typeof s==="function"&&!s)&&e["isRequired"]){t=new Error(`The prop '${i}' is marked as required in '${r}', but its value is '${s}'.`)}Children.map(s,(e=>{if(t)return t;const n=e.type;const s=get(components,`${r}.permittedChildren`);const o=`Invalid prop '${i}' supplied to ${r}. Only components ${s.join(", ")} are allowed.`;if(isFunction(n)&&has(n,"displayName")){const e=get(n,"displayName");const i=n.name;if(e&&e===`${i}`){if(!s.includes(i)){t=new Error(o)}}}if(!isValidElement(e)){t=new Error(o)}}));return t};const childrenTypes=checkChildrenTypes;childrenTypes["isRequired"]=(e,i,n,t,s)=>checkChildrenTypes(Object.assign(Object.assign({},e),{isRequired:true}),i,n,t,s);export default childrenTypes;
1
+ import{isValidElement,Children}from"react";import{isEmpty,isFunction,has,get}from"lodash";import components from"../config/components";const checkChildrenTypes=(props,propName,componentName)=>{let error=null;const children=props[propName],cpName=componentName.replace("CL","");return(isEmpty(children)&&typeof children!="function"||typeof children=="function"&&!children)&&props.isRequired&&(error=new Error(`The prop '${propName}' is marked as required in '${cpName}', but its value is '${children}'.`)),Children.map(children,c=>{if(error)return error;const type=c.type,itemTypes=get(components,`${cpName}.permittedChildren`),errorMsg=`Invalid prop '${propName}' supplied to ${cpName}. Only components ${itemTypes.join(", ")} are allowed.`;if(isFunction(type)&&has(type,"displayName")){const displayName=get(type,"displayName"),childComponentName=type.name;displayName&&displayName===`${childComponentName}`&&(itemTypes.includes(childComponentName)||(error=new Error(errorMsg)))}isValidElement(c)||(error=new Error(errorMsg))}),error},childrenTypes=checkChildrenTypes;childrenTypes.isRequired=(props,propName,componentName,location,propFullName)=>checkChildrenTypes(Object.assign(Object.assign({},props),{isRequired:!0}),propName,componentName,location,propFullName);export default childrenTypes;
@@ -1 +1 @@
1
- import{Countries,States}from"countries-states-cities-service";export function getCountries(){return Countries.getCountries({sort:{mode:"alphabetical",key:"name"}}).map((({name:e,iso2:t})=>({label:e,value:t})))}export function getStateOfCountry(e){const t={country_code:e};if(e==="IT")t.is_region=false;return States.getStates({filters:t,sort:{mode:"alphabetical",key:"name"}}).map((({name:e,state_code:t})=>({label:e.replace("Province of",""),value:t})))}export function isValidState(e,t){return States.getStates({filters:{state_code:e,country_code:t}}).length>0}
1
+ import{Countries,States}from"countries-states-cities-service";export function getCountries(){return Countries.getCountries({sort:{mode:"alphabetical",key:"name"}}).map(({name,iso2})=>({label:name,value:iso2}))}export function getStateOfCountry(country_code){const filters={country_code};return country_code==="IT"&&(filters.is_region=!1),States.getStates({filters,sort:{mode:"alphabetical",key:"name"}}).map(({name,state_code})=>({label:name.replace("Province of",""),value:state_code}))}export function isValidState(state_code,country_code){return States.getStates({filters:{state_code,country_code}}).length>0}
@@ -1 +1 @@
1
- import findIndex from"lodash/findIndex";import pick from"lodash/pick";const customMessages=(e=[],o)=>{const s=findIndex(e,pick(o,["field","code","resource"]));return s!==-1?e[s]:null};export default customMessages;
1
+ import findIndex from"lodash/findIndex";import pick from"lodash/pick";const customMessages=(messages=[],v)=>{const i=findIndex(messages,pick(v,["field","code","resource"]));return i!==-1?messages[i]:null};export default customMessages;
@@ -1 +1 @@
1
- import{keys}from"lodash";export default function getAmount(o){const{format:t,type:e,obj:s,base:$}=o;let r;keys(s).map((o=>{const a=o.toLowerCase();const n=`${t}_${e}_${$}`.toLowerCase();const f=`${e}_${$}_${t}`.toLowerCase();const _=`${t}_${$}_${e}`.toLowerCase();const c=`${$}_${e}_${t}`.toLowerCase();if(a===n){r=s[o]}if(a===f){r=s[o]}if(a===_){r=s[o]}if(a===c){r=s[o]}}));return r}
1
+ import{keys}from"lodash";export default function getAmount(args){const{format,type,obj,base}=args;let v;return keys(obj).map(k=>{const key=k.toLowerCase(),typeOne=`${format}_${type}_${base}`.toLowerCase(),typeTwo=`${type}_${base}_${format}`.toLowerCase(),typeThree=`${format}_${base}_${type}`.toLowerCase(),typeFourth=`${base}_${type}_${format}`.toLowerCase();key===typeOne&&(v=obj[k]),key===typeTwo&&(v=obj[k]),key===typeThree&&(v=obj[k]),key===typeFourth&&(v=obj[k])}),v}
@@ -1 +1 @@
1
- import{first,keys}from"lodash";const getCurrentItemKey=e=>first(keys(e))||"";export default getCurrentItemKey;
1
+ import{first,keys}from"lodash";const getCurrentItemKey=item=>first(keys(item))||"";export default getCurrentItemKey;
@@ -1 +1 @@
1
- import differenceBy from"lodash/differenceBy";export default function getErrors(r,e){return r.errors.map((r=>Object.assign(Object.assign({},r),{resource:e})))}export function setErrors({currentErrors:r=[],newErrors:e=[],dispatch:o,filterBy:t="code"}){const s=differenceBy(r,e,t);const n=(r===null||r===void 0?void 0:r.length)===0?e:s;const c=[...r||[],...n];if(!o){return c}o({type:"setErrors",payload:{errors:c}})}
1
+ import differenceBy from"lodash/differenceBy";export default function getErrors(error,resource){return error.errors.map(e=>Object.assign(Object.assign({},e),{resource}))}export function setErrors({currentErrors=[],newErrors=[],dispatch,filterBy="code"}){const errorsDifference=differenceBy(currentErrors,newErrors,filterBy),mergeErrors=(currentErrors==null?void 0:currentErrors.length)===0?newErrors:errorsDifference,errors=[...currentErrors||[],...mergeErrors];if(!dispatch)return errors;dispatch({type:"setErrors",payload:{errors}})}
@@ -1 +1 @@
1
- const getLineItemsCount=(t,e=0)=>{const n=["skus","gift_cards","bundles","adjustments"];t.filter((t=>t.item_type&&n.includes(t.item_type))).forEach((t=>{if(t.quantity)e+=t.quantity}));return e};export default getLineItemsCount;
1
+ const getLineItemsCount=(lineItems,quantity=0)=>{const typeAccepted=["skus","gift_cards","bundles","adjustments"];return lineItems.filter(l=>l.item_type&&typeAccepted.includes(l.item_type)).forEach(l=>{l.quantity&&(quantity+=l.quantity)}),quantity};export default getLineItemsCount;
@@ -1 +1 @@
1
- import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export default function getLoaderComponent(t){return typeof t==="function"?_jsx(t,{},void 0):_jsx(_Fragment,{children:t},void 0)}
1
+ import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export default function getLoaderComponent(Loader){return typeof Loader=="function"?_jsx(Loader,{},void 0):_jsx(_Fragment,{children:Loader},void 0)}
@@ -1 +1 @@
1
- import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export const getPriceByCode=(e,t="")=>t?first(e.filter((e=>e.currency_code===t))):first(e);export const getPricesComponent=(e,t)=>{if(isEmpty(e)){return _jsx(PriceTemplate,Object.assign({},t),void 0)}return e.map(((e,r)=>{const o=typeof t.showCompare==="undefined"&&(e===null||e===void 0?void 0:e.compare_at_amount_cents)>(e===null||e===void 0?void 0:e.amount_cents)||t.showCompare;return _createElement(PriceTemplate,Object.assign({},t,{key:r,showCompare:o,formattedAmount:e.formatted_amount,formattedCompare:e.formatted_compare_at_amount}))}))};export default function getPrices(e){const t={};if(isArray(e)){e.forEach((e=>{const r=e.sku_code;if(has(t,r)){t[r].push(e)}else{t[r]=[e]}}))}return t}
1
+ import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export const getPriceByCode=(skuPrices,code="")=>code?first(skuPrices.filter(p=>p.currency_code===code)):first(skuPrices),getPricesComponent=(skuPrices,props)=>isEmpty(skuPrices)?_jsx(PriceTemplate,Object.assign({},props),void 0):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare=="undefined"&&(p==null?void 0:p.compare_at_amount_cents)>(p==null?void 0:p.amount_cents)||props.showCompare;return _createElement(PriceTemplate,Object.assign({},props,{key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount}))});export default function getPrices(prices){const obj={};return isArray(prices)&&prices.forEach(p=>{const sku=p.sku_code;has(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}
@@ -1 +1 @@
1
- import getOrganizationSlug from"./organization";import Sdk from"@commercelayer/sdk";export default function getSdk({endpoint:e,accessToken:n}){const o=getOrganizationSlug(e);return Sdk(Object.assign({accessToken:n},o))}
1
+ import getOrganizationSlug from"./organization";import Sdk from"@commercelayer/sdk";export default function getSdk({endpoint,accessToken}){const org=getOrganizationSlug(endpoint);return Sdk(Object.assign({accessToken},org))}
@@ -1 +1 @@
1
- const getSkus=(o,e)=>{const t={};e.forEach((e=>{o.forEach((o=>{if((o===null||o===void 0?void 0:o.code)===e)t[o.code]=o}))}));return t};export default getSkus;
1
+ const getSkus=(skus,sortBy)=>{const obj={};return sortBy.forEach(sku=>{skus.forEach(o=>{(o==null?void 0:o.code)===sku&&(obj[o.code]=o)})}),obj};export default getSkus;
@@ -1 +1 @@
1
- const countryLock=["IT","US"];export default function isEmptyStates(t){return!countryLock.includes(t)}
1
+ const countryLock=["IT","US"];export default function isEmptyStates(countryCode){return!countryLock.includes(countryCode)}
@@ -1 +1 @@
1
- export default function isJSON(r){try{JSON.parse(r);return true}catch(r){return false}}
1
+ export default function isJSON(str){try{return JSON.parse(str),!0}catch{return!1}}
@@ -1 +1 @@
1
- import jwtDecode from"jwt-decode";export default function jwt(e){return jwtDecode(e)}
1
+ import jwtDecode from"jwt-decode";export default function jwt(accessToken){return jwtDecode(accessToken)}
@@ -1 +1 @@
1
- export const getLocalOrder=e=>localStorage.getItem(e);export const setLocalOrder=(e,t)=>localStorage.setItem(e,t);export const deleteLocalOrder=e=>{localStorage.removeItem(e)};export const getSavePaymentSourceToCustomerWallet=()=>localStorage.getItem("_save_payment_source_to_customer_wallet")==="true";export const getSaveBillingAddressToAddressBook=()=>localStorage.getItem("_save_billing_address_to_customer_address_book")==="true";export const getSaveShippingAddressToAddressBook=()=>localStorage.getItem("_save_shipping_address_to_customer_address_book")==="true";export function setCustomerOrderParam(e,t){return setLocalOrder(e,t)}
1
+ export const getLocalOrder=key=>localStorage.getItem(key),setLocalOrder=(key,value)=>localStorage.setItem(key,value),deleteLocalOrder=key=>{localStorage.removeItem(key)},getSavePaymentSourceToCustomerWallet=()=>localStorage.getItem("_save_payment_source_to_customer_wallet")==="true",getSaveBillingAddressToAddressBook=()=>localStorage.getItem("_save_billing_address_to_customer_address_book")==="true",getSaveShippingAddressToAddressBook=()=>localStorage.getItem("_save_shipping_address_to_customer_address_book")==="true";export function setCustomerOrderParam(key,value){return setLocalOrder(key,value)}
@@ -1 +1 @@
1
- export default function getOrganizationSlug(e){const o={organization:"",domain:"commercelayer.io"};if(e.search("commercelayer.io")===-1)o.domain="commercelayer.co";o.organization=e.replace("https://","").replace(`.${o.domain}`,"");return o}
1
+ export default function getOrganizationSlug(endpoint){const org={organization:"",domain:"commercelayer.io"};return endpoint.search("commercelayer.io")===-1&&(org.domain="commercelayer.co"),org.organization=endpoint.replace("https://","").replace(`.${org.domain}`,""),org}
@@ -1 +1 @@
1
- import{getPaymentConfig}from"../reducers/PaymentMethodReducer";import pick from"lodash/pick";export default function getPaypalConfig(e,t){const r=getPaymentConfig(e,t);return r&&pick(r,["return_url","cancel_url"])}
1
+ import{getPaymentConfig}from"../reducers/PaymentMethodReducer";import pick from"lodash/pick";export default function getPaypalConfig(paymentResource,config){const attributes=getPaymentConfig(paymentResource,config);return attributes&&pick(attributes,["return_url","cancel_url"])}
@@ -1 +1 @@
1
- import isFunction from"lodash/isFunction";export default function promisify(i,o){return new Promise(((n,e)=>{if(o)i(o,((i,o)=>{if(i)e(i);n(o)}));else if(isFunction(i===null||i===void 0?void 0:i.tokenize)){i===null||i===void 0?void 0:i.tokenize(((i,o)=>{if(i)e(i);n(o)}))}else i(((i,o)=>{if(i)e(i);n(o)}))}))}
1
+ import isFunction from"lodash/isFunction";export default function promisify(cb,params){return new Promise((resolve,reject)=>{params?cb(params,(err,res)=>{err&&reject(err),resolve(res)}):isFunction(cb==null?void 0:cb.tokenize)?cb==null||cb.tokenize((err,payload)=>{err&&reject(err),resolve(payload)}):cb((err,res)=>{err&&reject(err),resolve(res)})})}
@@ -1 +1 @@
1
- import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(t){const m=compact(t.filter((t=>!isEmpty(t.shipping_method))));return!isEmpty(m)}
1
+ import compact from"lodash/compact";import isEmpty from"lodash/isEmpty";export function shipmentsFilled(shipments){const filled=compact(shipments.filter(shipment=>!isEmpty(shipment.shipping_method)));return!isEmpty(filled)}
@@ -1 +1 @@
1
- import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import get from"lodash/get";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/;export const validateValue=(e,t,s,a)=>{if(!e){return{field:t,code:"VALIDATION_ERROR",message:`${t} - is required`,resourceType:a}}if(s==="email"&&isString(e)&&!e.match(EMAIL_PATTERN)){return{field:t,code:"VALIDATION_ERROR",message:`${t} - is not valid`,resourceType:a}}return{}};const validateFormFields=(e,t,s)=>{const a=[];let i={metadata:{}};map(e,(e=>{const r=!!get(e,"checked");const n=r?r:e.value==="on"?false:e.value;const o=e.getAttribute("name");if(o&&t.indexOf(o)!==-1||e.required){const t=validateValue(n,e.name,e.type,s);if(!isEmpty(t)){a.push(t)}i=Object.assign(Object.assign({},i),{[`${e.name}`]:n})}if(e.getAttribute("name")){const t=!!e.getAttribute("data-metadata");i=t?Object.assign(Object.assign({},i),{metadata:Object.assign(Object.assign({},i.metadata),{[`${e.name}`]:n})}):Object.assign(Object.assign({},i),{[`${e.name}`]:n})}}));return{errors:a,values:i}};export const fieldsExist=(e,t=addressFields)=>{if(!e["business"]){const s=without(t,"line_2","company");const a=keys(e).filter((e=>s.includes(e)));return s.length>a.length}else{const s=without(t,"first_name","last_name");const a=keys(e).filter((e=>s.includes(e)));return s.length>a.length}};export default validateFormFields;
1
+ import isEmpty from"lodash/isEmpty";import isString from"lodash/isString";import without from"lodash/without";import keys from"lodash/keys";import map from"lodash/map";import get from"lodash/get";import{addressFields}from"../reducers/AddressReducer";const EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/;export const validateValue=(val,name,type,resourceType)=>val?type==="email"&&isString(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return map(fields,v=>{const isTick=!!get(v,"checked"),val=isTick||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.indexOf(attrName)!==-1||v.required){const error=validateValue(val,v.name,v.type,resourceType);isEmpty(error)||errors.push(error),values=Object.assign(Object.assign({},values),{[`${v.name}`]:val})}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?Object.assign(Object.assign({},values),{metadata:Object.assign(Object.assign({},values.metadata),{[`${v.name}`]:val})}):Object.assign(Object.assign({},values),{[`${v.name}`]:val}))}),{errors,values}};export const fieldsExist=(address,schema=addressFields)=>{if(address.business){const required=without(schema,"first_name","last_name"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=without(schema,"line_2","company"),validAddress=keys(address).filter(k=>required.includes(k));return required.length>validAddress.length}};export default validateFormFields;