@commercelayer/react-components 4.5.0-beta.3 → 4.5.0-beta.4

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 (487) hide show
  1. package/lib/cjs/components/ExternalFunction.js +1 -0
  2. package/lib/cjs/components/MetadataInput.js +1 -0
  3. package/lib/cjs/components/SubmitButton.js +1 -0
  4. package/lib/cjs/components/addresses/Address.js +1 -0
  5. package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -0
  6. package/lib/cjs/components/addresses/AddressField.js +1 -0
  7. package/lib/cjs/components/addresses/AddressInput.js +1 -0
  8. package/lib/cjs/components/addresses/AddressStateSelector.js +1 -0
  9. package/lib/cjs/components/addresses/AddressesContainer.js +1 -0
  10. package/lib/cjs/components/addresses/AddressesEmpty.js +1 -0
  11. package/lib/cjs/components/addresses/BillingAddressContainer.js +1 -0
  12. package/lib/cjs/components/addresses/BillingAddressForm.js +1 -0
  13. package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -0
  14. package/lib/cjs/components/addresses/ShippingAddressContainer.js +1 -0
  15. package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -0
  16. package/lib/cjs/components/auth/CommerceLayer.js +1 -0
  17. package/lib/cjs/components/customers/CustomerAddressForm.js +1 -0
  18. package/lib/cjs/components/customers/CustomerContainer.js +1 -0
  19. package/lib/cjs/components/customers/CustomerField.js +1 -0
  20. package/lib/cjs/components/customers/CustomerInput.js +1 -0
  21. package/lib/cjs/components/customers/CustomerPaymentSource.js +1 -0
  22. package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.js +1 -0
  23. package/lib/cjs/components/customers/MyAccountLink.js +1 -0
  24. package/lib/cjs/components/customers/MyIdentityLink.d.ts +35 -0
  25. package/lib/cjs/components/customers/MyIdentityLink.js +2 -0
  26. package/lib/cjs/components/customers/SaveCustomerButton.js +1 -0
  27. package/lib/cjs/components/errors/Errors.js +1 -0
  28. package/lib/cjs/components/gift_cards/GiftCard.js +1 -0
  29. package/lib/cjs/components/gift_cards/GiftCardContainer.js +1 -0
  30. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.js +1 -0
  31. package/lib/cjs/components/gift_cards/GiftCardInput.js +1 -0
  32. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.js +1 -0
  33. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.js +1 -0
  34. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.js +1 -0
  35. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -0
  36. package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.js +1 -0
  37. package/lib/cjs/components/gift_cards/GiftCardRecipientInput.js +1 -0
  38. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.js +1 -0
  39. package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.js +1 -0
  40. package/lib/cjs/components/line_items/LineItem.js +1 -0
  41. package/lib/cjs/components/line_items/LineItemAmount.js +1 -0
  42. package/lib/cjs/components/line_items/LineItemCode.js +1 -0
  43. package/lib/cjs/components/line_items/LineItemField.js +1 -0
  44. package/lib/cjs/components/line_items/LineItemImage.js +1 -0
  45. package/lib/cjs/components/line_items/LineItemName.js +1 -0
  46. package/lib/cjs/components/line_items/LineItemOption.js +1 -0
  47. package/lib/cjs/components/line_items/LineItemOptions.js +1 -0
  48. package/lib/cjs/components/line_items/LineItemQuantity.js +1 -0
  49. package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -0
  50. package/lib/cjs/components/line_items/LineItemsContainer.js +1 -0
  51. package/lib/cjs/components/line_items/LineItemsCount.js +1 -0
  52. package/lib/cjs/components/line_items/LineItemsEmpty.js +1 -0
  53. package/lib/cjs/components/orders/AddToCartButton.js +1 -0
  54. package/lib/cjs/components/orders/AdjustmentAmount.js +1 -0
  55. package/lib/cjs/components/orders/CartLink.d.ts +8 -0
  56. package/lib/cjs/components/orders/CartLink.js +2 -1
  57. package/lib/cjs/components/orders/CheckoutLink.js +1 -0
  58. package/lib/cjs/components/orders/DiscountAmount.js +1 -0
  59. package/lib/cjs/components/orders/GiftCardAmount.js +1 -0
  60. package/lib/cjs/components/orders/HostedCart.js +1 -0
  61. package/lib/cjs/components/orders/OrderContainer.js +1 -0
  62. package/lib/cjs/components/orders/OrderList.js +1 -0
  63. package/lib/cjs/components/orders/OrderListEmpty.js +1 -0
  64. package/lib/cjs/components/orders/OrderListPaginationButtons.js +1 -0
  65. package/lib/cjs/components/orders/OrderListPaginationInfo.js +1 -0
  66. package/lib/cjs/components/orders/OrderListRow.js +1 -0
  67. package/lib/cjs/components/orders/OrderNumber.js +1 -0
  68. package/lib/cjs/components/orders/OrderStorage.js +1 -0
  69. package/lib/cjs/components/orders/PaymentMethodAmount.js +1 -0
  70. package/lib/cjs/components/orders/PlaceOrderButton.js +1 -0
  71. package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -0
  72. package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -0
  73. package/lib/cjs/components/orders/ShippingAmount.js +1 -0
  74. package/lib/cjs/components/orders/SubTotalAmount.js +1 -0
  75. package/lib/cjs/components/orders/TaxesAmount.js +1 -0
  76. package/lib/cjs/components/orders/TotalAmount.js +1 -0
  77. package/lib/cjs/components/parcels/ParcelField.js +1 -0
  78. package/lib/cjs/components/parcels/ParcelLineItem.js +1 -0
  79. package/lib/cjs/components/parcels/ParcelLineItemField.js +1 -0
  80. package/lib/cjs/components/parcels/ParcelLineItemsCount.js +1 -0
  81. package/lib/cjs/components/parcels/Parcels.js +1 -0
  82. package/lib/cjs/components/parcels/ParcelsCount.js +1 -0
  83. package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -0
  84. package/lib/cjs/components/payment_gateways/BraintreeGateway.js +1 -0
  85. package/lib/cjs/components/payment_gateways/CheckoutComGateway.js +1 -0
  86. package/lib/cjs/components/payment_gateways/ExternalGateway.js +1 -0
  87. package/lib/cjs/components/payment_gateways/KlarnaGateway.js +1 -0
  88. package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -0
  89. package/lib/cjs/components/payment_gateways/PaypalGateway.js +1 -0
  90. package/lib/cjs/components/payment_gateways/StripeGateway.js +1 -0
  91. package/lib/cjs/components/payment_gateways/WireTransferGateway.js +1 -0
  92. package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -0
  93. package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -0
  94. package/lib/cjs/components/payment_methods/PaymentMethodPrice.js +1 -0
  95. package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -0
  96. package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -0
  97. package/lib/cjs/components/payment_source/AdyenPayment.js +1 -0
  98. package/lib/cjs/components/payment_source/BraintreePayment.js +1 -0
  99. package/lib/cjs/components/payment_source/CheckoutComPayment.js +1 -0
  100. package/lib/cjs/components/payment_source/ExternalPayment.js +1 -0
  101. package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -0
  102. package/lib/cjs/components/payment_source/PaymentSource.js +1 -0
  103. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.js +1 -0
  104. package/lib/cjs/components/payment_source/PaymentSourceBrandName.js +1 -0
  105. package/lib/cjs/components/payment_source/PaymentSourceDetail.js +1 -0
  106. package/lib/cjs/components/payment_source/PaymentSourceEditButton.js +1 -0
  107. package/lib/cjs/components/payment_source/PaypalPayment.js +1 -0
  108. package/lib/cjs/components/payment_source/StripeExpressPayment.js +1 -0
  109. package/lib/cjs/components/payment_source/StripePayment.js +1 -0
  110. package/lib/cjs/components/payment_source/WireTransferPayment.js +1 -0
  111. package/lib/cjs/components/prices/Price.js +1 -0
  112. package/lib/cjs/components/prices/PricesContainer.js +1 -0
  113. package/lib/cjs/components/shipments/Shipment.js +1 -0
  114. package/lib/cjs/components/shipments/ShipmentField.js +1 -0
  115. package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -0
  116. package/lib/cjs/components/shipments/ShipmentsCount.js +1 -0
  117. package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -0
  118. package/lib/cjs/components/shipping_methods/ShippingMethodName.js +1 -0
  119. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.js +1 -0
  120. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -0
  121. package/lib/cjs/components/skus/AvailabilityContainer.js +1 -0
  122. package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -0
  123. package/lib/cjs/components/skus/DeliveryLeadTime.js +1 -0
  124. package/lib/cjs/components/skus/SkuField.js +1 -0
  125. package/lib/cjs/components/skus/SkuList.js +1 -0
  126. package/lib/cjs/components/skus/SkuListsContainer.js +1 -0
  127. package/lib/cjs/components/skus/Skus.js +1 -0
  128. package/lib/cjs/components/skus/SkusContainer.js +1 -0
  129. package/lib/cjs/components/stock_transfers/StockTransfer.js +1 -0
  130. package/lib/cjs/components/stock_transfers/StockTransferField.js +1 -0
  131. package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -0
  132. package/lib/cjs/components/utils/BaseField.js +1 -0
  133. package/lib/cjs/components/utils/BaseInput.js +1 -0
  134. package/lib/cjs/components/utils/BaseOrderPrice.js +1 -0
  135. package/lib/cjs/components/utils/BaseSelect.js +1 -0
  136. package/lib/cjs/components/utils/ErrorBoundary.js +1 -0
  137. package/lib/cjs/components/utils/GenericFieldComponent.js +1 -0
  138. package/lib/cjs/components/utils/Parent.js +1 -0
  139. package/lib/cjs/components/utils/PaymentCardsTemplate.js +1 -0
  140. package/lib/cjs/components/utils/PriceTemplate.js +1 -0
  141. package/lib/cjs/components/utils/getAllErrors.js +1 -0
  142. package/lib/cjs/config/currency.js +1 -0
  143. package/lib/cjs/context/AddressChildrenContext.js +1 -0
  144. package/lib/cjs/context/AddressContext.js +1 -0
  145. package/lib/cjs/context/AvailabilityContext.js +1 -0
  146. package/lib/cjs/context/BillingAddressContext.js +1 -0
  147. package/lib/cjs/context/BillingAddressFormContext.js +1 -0
  148. package/lib/cjs/context/CommerceLayerContext.js +1 -0
  149. package/lib/cjs/context/CouponAndGiftCardFormContext.js +1 -0
  150. package/lib/cjs/context/CustomerAddressFormContext.js +1 -0
  151. package/lib/cjs/context/CustomerContext.js +1 -0
  152. package/lib/cjs/context/CustomerPaymentSourceContext.js +1 -0
  153. package/lib/cjs/context/ExternalFunctionContext.js +1 -0
  154. package/lib/cjs/context/GiftCardContext.js +1 -0
  155. package/lib/cjs/context/InStockSubscriptionContext.js +1 -0
  156. package/lib/cjs/context/LineItemChildrenContext.js +1 -0
  157. package/lib/cjs/context/LineItemContext.js +1 -0
  158. package/lib/cjs/context/LineItemOptionChildrenContext.js +1 -0
  159. package/lib/cjs/context/OrderContext.js +1 -0
  160. package/lib/cjs/context/OrderListChildrenContext.js +1 -0
  161. package/lib/cjs/context/OrderListPaginationContext.js +1 -0
  162. package/lib/cjs/context/OrderStorageContext.js +1 -0
  163. package/lib/cjs/context/ParcelChildrenContext.js +1 -0
  164. package/lib/cjs/context/ParcelLineItemChildrenContext.js +1 -0
  165. package/lib/cjs/context/PaymentMethodChildrenContext.js +1 -0
  166. package/lib/cjs/context/PaymentMethodContext.js +1 -0
  167. package/lib/cjs/context/PaymentSourceContext.js +1 -0
  168. package/lib/cjs/context/PlaceOrderContext.js +1 -0
  169. package/lib/cjs/context/PricesContext.js +1 -0
  170. package/lib/cjs/context/ShipmentChildrenContext.js +1 -0
  171. package/lib/cjs/context/ShipmentContext.js +1 -0
  172. package/lib/cjs/context/ShippingAddressContext.js +1 -0
  173. package/lib/cjs/context/ShippingAddressFormContext.js +1 -0
  174. package/lib/cjs/context/ShippingMethodChildrenContext.js +1 -0
  175. package/lib/cjs/context/SkuChildrenContext.js +1 -0
  176. package/lib/cjs/context/SkuContext.js +1 -0
  177. package/lib/cjs/context/SkuListsContext.js +1 -0
  178. package/lib/cjs/context/StockTransferChildrenContext.js +1 -0
  179. package/lib/cjs/hooks/useCommerceLayer.js +1 -0
  180. package/lib/cjs/hooks/useOrderContainer.js +1 -0
  181. package/lib/cjs/index.js +1 -0
  182. package/lib/cjs/reducers/AddressReducer.js +1 -0
  183. package/lib/cjs/reducers/AvailabilityReducer.js +1 -0
  184. package/lib/cjs/reducers/BillingAddressReducer.js +1 -0
  185. package/lib/cjs/reducers/CustomerReducer.js +1 -0
  186. package/lib/cjs/reducers/GiftCardReducer.js +1 -0
  187. package/lib/cjs/reducers/InStockSubscriptionReducer.js +1 -0
  188. package/lib/cjs/reducers/LineItemReducer.js +1 -0
  189. package/lib/cjs/reducers/OrderReducer.js +1 -0
  190. package/lib/cjs/reducers/PaymentMethodReducer.js +1 -0
  191. package/lib/cjs/reducers/PlaceOrderReducer.js +1 -0
  192. package/lib/cjs/reducers/PriceReducer.js +1 -0
  193. package/lib/cjs/reducers/ShipmentReducer.js +1 -0
  194. package/lib/cjs/reducers/ShippingAddressReducer.js +1 -0
  195. package/lib/cjs/reducers/SkuListsReducer.js +1 -0
  196. package/lib/cjs/reducers/SkuReducer.js +1 -0
  197. package/lib/cjs/typings/errors.js +1 -0
  198. package/lib/cjs/typings/globals.js +1 -0
  199. package/lib/cjs/typings/index.js +1 -0
  200. package/lib/cjs/utils/PropsType.js +1 -0
  201. package/lib/cjs/utils/addressesManager.js +1 -0
  202. package/lib/cjs/utils/baseReducer.js +1 -0
  203. package/lib/cjs/utils/browserInfo.js +1 -0
  204. package/lib/cjs/utils/checkIncludeResource.js +1 -0
  205. package/lib/cjs/utils/compareObjAttribute.js +1 -0
  206. package/lib/cjs/utils/countryStateCity.js +1 -0
  207. package/lib/cjs/utils/customMessages.js +1 -0
  208. package/lib/cjs/utils/customerOrderOptions.js +1 -0
  209. package/lib/cjs/utils/events.js +1 -0
  210. package/lib/cjs/utils/expressPaymentHelper.js +1 -0
  211. package/lib/cjs/utils/filterChildren.js +1 -0
  212. package/lib/cjs/utils/getAmount.js +1 -0
  213. package/lib/cjs/utils/getApplicationLink.d.ts +22 -7
  214. package/lib/cjs/utils/getApplicationLink.js +2 -1
  215. package/lib/cjs/utils/getCardDetails.js +1 -0
  216. package/lib/cjs/utils/getDomain.js +1 -0
  217. package/lib/cjs/utils/getErrors.js +1 -0
  218. package/lib/cjs/utils/getLineItemsCount.js +1 -0
  219. package/lib/cjs/utils/getLoaderComponent.js +1 -0
  220. package/lib/cjs/utils/getPaymentAttributes.js +1 -0
  221. package/lib/cjs/utils/getPrices.js +1 -0
  222. package/lib/cjs/utils/getSdk.js +1 -0
  223. package/lib/cjs/utils/getSkus.js +1 -0
  224. package/lib/cjs/utils/hasSubscriptions.js +1 -0
  225. package/lib/cjs/utils/hooks/useCustomContext.js +1 -0
  226. package/lib/cjs/utils/hooks/useExternalScript.js +1 -0
  227. package/lib/cjs/utils/icons.js +1 -0
  228. package/lib/cjs/utils/isDate.js +1 -0
  229. package/lib/cjs/utils/isEmpty.js +1 -0
  230. package/lib/cjs/utils/isEmptyStates.js +1 -0
  231. package/lib/cjs/utils/isJSON.js +1 -0
  232. package/lib/cjs/utils/jwt.js +1 -0
  233. package/lib/cjs/utils/localStorage.js +1 -0
  234. package/lib/cjs/utils/omit.js +1 -0
  235. package/lib/cjs/utils/organization.js +1 -0
  236. package/lib/cjs/utils/pick.js +1 -0
  237. package/lib/cjs/utils/placeholderImages.js +1 -0
  238. package/lib/cjs/utils/promisify.js +1 -0
  239. package/lib/cjs/utils/replace.js +1 -0
  240. package/lib/cjs/utils/scrollbarWidth.js +1 -0
  241. package/lib/cjs/utils/shipments.js +1 -0
  242. package/lib/cjs/utils/snakeToCamelCase.js +1 -0
  243. package/lib/cjs/utils/validateFormFields.js +1 -0
  244. package/lib/esm/components/ExternalFunction.js +1 -0
  245. package/lib/esm/components/MetadataInput.js +1 -0
  246. package/lib/esm/components/SubmitButton.js +1 -0
  247. package/lib/esm/components/addresses/Address.js +1 -0
  248. package/lib/esm/components/addresses/AddressCountrySelector.js +1 -0
  249. package/lib/esm/components/addresses/AddressField.js +1 -0
  250. package/lib/esm/components/addresses/AddressInput.js +1 -0
  251. package/lib/esm/components/addresses/AddressStateSelector.js +1 -0
  252. package/lib/esm/components/addresses/AddressesContainer.js +1 -0
  253. package/lib/esm/components/addresses/AddressesEmpty.js +1 -0
  254. package/lib/esm/components/addresses/BillingAddressContainer.js +1 -0
  255. package/lib/esm/components/addresses/BillingAddressForm.js +1 -0
  256. package/lib/esm/components/addresses/SaveAddressesButton.js +1 -0
  257. package/lib/esm/components/addresses/ShippingAddressContainer.js +1 -0
  258. package/lib/esm/components/addresses/ShippingAddressForm.js +1 -0
  259. package/lib/esm/components/auth/CommerceLayer.js +1 -0
  260. package/lib/esm/components/customers/CustomerAddressForm.js +1 -0
  261. package/lib/esm/components/customers/CustomerContainer.js +1 -0
  262. package/lib/esm/components/customers/CustomerField.js +1 -0
  263. package/lib/esm/components/customers/CustomerInput.js +1 -0
  264. package/lib/esm/components/customers/CustomerPaymentSource.js +1 -0
  265. package/lib/esm/components/customers/CustomerPaymentSourceEmpty.js +1 -0
  266. package/lib/esm/components/customers/MyAccountLink.js +1 -0
  267. package/lib/esm/components/customers/MyIdentityLink.d.ts +35 -0
  268. package/lib/esm/components/customers/MyIdentityLink.js +2 -0
  269. package/lib/esm/components/customers/SaveCustomerButton.js +1 -0
  270. package/lib/esm/components/errors/Errors.js +1 -0
  271. package/lib/esm/components/gift_cards/GiftCard.js +1 -0
  272. package/lib/esm/components/gift_cards/GiftCardContainer.js +1 -0
  273. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.js +1 -0
  274. package/lib/esm/components/gift_cards/GiftCardInput.js +1 -0
  275. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.js +1 -0
  276. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.js +1 -0
  277. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.js +1 -0
  278. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -0
  279. package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.js +1 -0
  280. package/lib/esm/components/gift_cards/GiftCardRecipientInput.js +1 -0
  281. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.js +1 -0
  282. package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.js +1 -0
  283. package/lib/esm/components/line_items/LineItem.js +1 -0
  284. package/lib/esm/components/line_items/LineItemAmount.js +1 -0
  285. package/lib/esm/components/line_items/LineItemCode.js +1 -0
  286. package/lib/esm/components/line_items/LineItemField.js +1 -0
  287. package/lib/esm/components/line_items/LineItemImage.js +1 -0
  288. package/lib/esm/components/line_items/LineItemName.js +1 -0
  289. package/lib/esm/components/line_items/LineItemOption.js +1 -0
  290. package/lib/esm/components/line_items/LineItemOptions.js +1 -0
  291. package/lib/esm/components/line_items/LineItemQuantity.js +1 -0
  292. package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -0
  293. package/lib/esm/components/line_items/LineItemsContainer.js +1 -0
  294. package/lib/esm/components/line_items/LineItemsCount.js +1 -0
  295. package/lib/esm/components/line_items/LineItemsEmpty.js +1 -0
  296. package/lib/esm/components/orders/AddToCartButton.js +1 -0
  297. package/lib/esm/components/orders/AdjustmentAmount.js +1 -0
  298. package/lib/esm/components/orders/CartLink.d.ts +8 -0
  299. package/lib/esm/components/orders/CartLink.js +2 -1
  300. package/lib/esm/components/orders/CheckoutLink.js +1 -0
  301. package/lib/esm/components/orders/DiscountAmount.js +1 -0
  302. package/lib/esm/components/orders/GiftCardAmount.js +1 -0
  303. package/lib/esm/components/orders/HostedCart.js +1 -0
  304. package/lib/esm/components/orders/OrderContainer.js +1 -0
  305. package/lib/esm/components/orders/OrderList.js +1 -0
  306. package/lib/esm/components/orders/OrderListEmpty.js +1 -0
  307. package/lib/esm/components/orders/OrderListPaginationButtons.js +1 -0
  308. package/lib/esm/components/orders/OrderListPaginationInfo.js +1 -0
  309. package/lib/esm/components/orders/OrderListRow.js +1 -0
  310. package/lib/esm/components/orders/OrderNumber.js +1 -0
  311. package/lib/esm/components/orders/OrderStorage.js +1 -0
  312. package/lib/esm/components/orders/PaymentMethodAmount.js +1 -0
  313. package/lib/esm/components/orders/PlaceOrderButton.js +1 -0
  314. package/lib/esm/components/orders/PlaceOrderContainer.js +1 -0
  315. package/lib/esm/components/orders/PrivacyAndTermsCheckbox.js +1 -0
  316. package/lib/esm/components/orders/ShippingAmount.js +1 -0
  317. package/lib/esm/components/orders/SubTotalAmount.js +1 -0
  318. package/lib/esm/components/orders/TaxesAmount.js +1 -0
  319. package/lib/esm/components/orders/TotalAmount.js +1 -0
  320. package/lib/esm/components/parcels/ParcelField.js +1 -0
  321. package/lib/esm/components/parcels/ParcelLineItem.js +1 -0
  322. package/lib/esm/components/parcels/ParcelLineItemField.js +1 -0
  323. package/lib/esm/components/parcels/ParcelLineItemsCount.js +1 -0
  324. package/lib/esm/components/parcels/Parcels.js +1 -0
  325. package/lib/esm/components/parcels/ParcelsCount.js +1 -0
  326. package/lib/esm/components/payment_gateways/AdyenGateway.js +1 -0
  327. package/lib/esm/components/payment_gateways/BraintreeGateway.js +1 -0
  328. package/lib/esm/components/payment_gateways/CheckoutComGateway.js +1 -0
  329. package/lib/esm/components/payment_gateways/ExternalGateway.js +1 -0
  330. package/lib/esm/components/payment_gateways/KlarnaGateway.js +1 -0
  331. package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -0
  332. package/lib/esm/components/payment_gateways/PaypalGateway.js +1 -0
  333. package/lib/esm/components/payment_gateways/StripeGateway.js +1 -0
  334. package/lib/esm/components/payment_gateways/WireTransferGateway.js +1 -0
  335. package/lib/esm/components/payment_methods/PaymentMethod.js +1 -0
  336. package/lib/esm/components/payment_methods/PaymentMethodName.js +1 -0
  337. package/lib/esm/components/payment_methods/PaymentMethodPrice.js +1 -0
  338. package/lib/esm/components/payment_methods/PaymentMethodRadioButton.js +1 -0
  339. package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -0
  340. package/lib/esm/components/payment_source/AdyenPayment.js +1 -0
  341. package/lib/esm/components/payment_source/BraintreePayment.js +1 -0
  342. package/lib/esm/components/payment_source/CheckoutComPayment.js +1 -0
  343. package/lib/esm/components/payment_source/ExternalPayment.js +1 -0
  344. package/lib/esm/components/payment_source/KlarnaPayment.js +1 -0
  345. package/lib/esm/components/payment_source/PaymentSource.js +1 -0
  346. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.js +1 -0
  347. package/lib/esm/components/payment_source/PaymentSourceBrandName.js +1 -0
  348. package/lib/esm/components/payment_source/PaymentSourceDetail.js +1 -0
  349. package/lib/esm/components/payment_source/PaymentSourceEditButton.js +1 -0
  350. package/lib/esm/components/payment_source/PaypalPayment.js +1 -0
  351. package/lib/esm/components/payment_source/StripeExpressPayment.js +1 -0
  352. package/lib/esm/components/payment_source/StripePayment.js +1 -0
  353. package/lib/esm/components/payment_source/WireTransferPayment.js +1 -0
  354. package/lib/esm/components/prices/Price.js +1 -0
  355. package/lib/esm/components/prices/PricesContainer.js +1 -0
  356. package/lib/esm/components/shipments/Shipment.js +1 -0
  357. package/lib/esm/components/shipments/ShipmentField.js +1 -0
  358. package/lib/esm/components/shipments/ShipmentsContainer.js +1 -0
  359. package/lib/esm/components/shipments/ShipmentsCount.js +1 -0
  360. package/lib/esm/components/shipping_methods/ShippingMethod.js +1 -0
  361. package/lib/esm/components/shipping_methods/ShippingMethodName.js +1 -0
  362. package/lib/esm/components/shipping_methods/ShippingMethodPrice.js +1 -0
  363. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.js +1 -0
  364. package/lib/esm/components/skus/AvailabilityContainer.js +1 -0
  365. package/lib/esm/components/skus/AvailabilityTemplate.js +1 -0
  366. package/lib/esm/components/skus/DeliveryLeadTime.js +1 -0
  367. package/lib/esm/components/skus/SkuField.js +1 -0
  368. package/lib/esm/components/skus/SkuList.js +1 -0
  369. package/lib/esm/components/skus/SkuListsContainer.js +1 -0
  370. package/lib/esm/components/skus/Skus.js +1 -0
  371. package/lib/esm/components/skus/SkusContainer.js +1 -0
  372. package/lib/esm/components/stock_transfers/StockTransfer.js +1 -0
  373. package/lib/esm/components/stock_transfers/StockTransferField.js +1 -0
  374. package/lib/esm/components/utils/AddressCardsTemplate.js +1 -0
  375. package/lib/esm/components/utils/BaseField.js +1 -0
  376. package/lib/esm/components/utils/BaseInput.js +1 -0
  377. package/lib/esm/components/utils/BaseOrderPrice.js +1 -0
  378. package/lib/esm/components/utils/BaseSelect.js +1 -0
  379. package/lib/esm/components/utils/ErrorBoundary.js +1 -0
  380. package/lib/esm/components/utils/GenericFieldComponent.js +1 -0
  381. package/lib/esm/components/utils/Parent.js +1 -0
  382. package/lib/esm/components/utils/PaymentCardsTemplate.js +1 -0
  383. package/lib/esm/components/utils/PriceTemplate.js +1 -0
  384. package/lib/esm/components/utils/getAllErrors.js +1 -0
  385. package/lib/esm/config/currency.js +1 -0
  386. package/lib/esm/context/AddressChildrenContext.js +1 -0
  387. package/lib/esm/context/AddressContext.js +1 -0
  388. package/lib/esm/context/AvailabilityContext.js +1 -0
  389. package/lib/esm/context/BillingAddressContext.js +1 -0
  390. package/lib/esm/context/BillingAddressFormContext.js +1 -0
  391. package/lib/esm/context/CommerceLayerContext.js +1 -0
  392. package/lib/esm/context/CouponAndGiftCardFormContext.js +1 -0
  393. package/lib/esm/context/CustomerAddressFormContext.js +1 -0
  394. package/lib/esm/context/CustomerContext.js +1 -0
  395. package/lib/esm/context/CustomerPaymentSourceContext.js +1 -0
  396. package/lib/esm/context/ExternalFunctionContext.js +1 -0
  397. package/lib/esm/context/GiftCardContext.js +1 -0
  398. package/lib/esm/context/InStockSubscriptionContext.js +1 -0
  399. package/lib/esm/context/LineItemChildrenContext.js +1 -0
  400. package/lib/esm/context/LineItemContext.js +1 -0
  401. package/lib/esm/context/LineItemOptionChildrenContext.js +1 -0
  402. package/lib/esm/context/OrderContext.js +1 -0
  403. package/lib/esm/context/OrderListChildrenContext.js +1 -0
  404. package/lib/esm/context/OrderListPaginationContext.js +1 -0
  405. package/lib/esm/context/OrderStorageContext.js +1 -0
  406. package/lib/esm/context/ParcelChildrenContext.js +1 -0
  407. package/lib/esm/context/ParcelLineItemChildrenContext.js +1 -0
  408. package/lib/esm/context/PaymentMethodChildrenContext.js +1 -0
  409. package/lib/esm/context/PaymentMethodContext.js +1 -0
  410. package/lib/esm/context/PaymentSourceContext.js +1 -0
  411. package/lib/esm/context/PlaceOrderContext.js +1 -0
  412. package/lib/esm/context/PricesContext.js +1 -0
  413. package/lib/esm/context/ShipmentChildrenContext.js +1 -0
  414. package/lib/esm/context/ShipmentContext.js +1 -0
  415. package/lib/esm/context/ShippingAddressContext.js +1 -0
  416. package/lib/esm/context/ShippingAddressFormContext.js +1 -0
  417. package/lib/esm/context/ShippingMethodChildrenContext.js +1 -0
  418. package/lib/esm/context/SkuChildrenContext.js +1 -0
  419. package/lib/esm/context/SkuContext.js +1 -0
  420. package/lib/esm/context/SkuListsContext.js +1 -0
  421. package/lib/esm/context/StockTransferChildrenContext.js +1 -0
  422. package/lib/esm/hooks/useCommerceLayer.js +1 -0
  423. package/lib/esm/hooks/useOrderContainer.js +1 -0
  424. package/lib/esm/index.js +1 -0
  425. package/lib/esm/reducers/AddressReducer.js +1 -0
  426. package/lib/esm/reducers/AvailabilityReducer.js +1 -0
  427. package/lib/esm/reducers/BillingAddressReducer.js +1 -0
  428. package/lib/esm/reducers/CustomerReducer.js +1 -0
  429. package/lib/esm/reducers/GiftCardReducer.js +1 -0
  430. package/lib/esm/reducers/InStockSubscriptionReducer.js +1 -0
  431. package/lib/esm/reducers/LineItemReducer.js +1 -0
  432. package/lib/esm/reducers/OrderReducer.js +1 -0
  433. package/lib/esm/reducers/PaymentMethodReducer.js +1 -0
  434. package/lib/esm/reducers/PlaceOrderReducer.js +1 -0
  435. package/lib/esm/reducers/PriceReducer.js +1 -0
  436. package/lib/esm/reducers/ShipmentReducer.js +1 -0
  437. package/lib/esm/reducers/ShippingAddressReducer.js +1 -0
  438. package/lib/esm/reducers/SkuListsReducer.js +1 -0
  439. package/lib/esm/reducers/SkuReducer.js +1 -0
  440. package/lib/esm/typings/errors.js +1 -0
  441. package/lib/esm/typings/globals.js +1 -0
  442. package/lib/esm/typings/index.js +1 -0
  443. package/lib/esm/utils/PropsType.js +1 -0
  444. package/lib/esm/utils/addressesManager.js +1 -0
  445. package/lib/esm/utils/baseReducer.js +1 -0
  446. package/lib/esm/utils/browserInfo.js +1 -0
  447. package/lib/esm/utils/checkIncludeResource.js +1 -0
  448. package/lib/esm/utils/compareObjAttribute.js +1 -0
  449. package/lib/esm/utils/countryStateCity.js +1 -0
  450. package/lib/esm/utils/customMessages.js +1 -0
  451. package/lib/esm/utils/customerOrderOptions.js +1 -0
  452. package/lib/esm/utils/events.js +1 -0
  453. package/lib/esm/utils/expressPaymentHelper.js +1 -0
  454. package/lib/esm/utils/filterChildren.js +1 -0
  455. package/lib/esm/utils/getAmount.js +1 -0
  456. package/lib/esm/utils/getApplicationLink.d.ts +22 -7
  457. package/lib/esm/utils/getApplicationLink.js +2 -1
  458. package/lib/esm/utils/getCardDetails.js +1 -0
  459. package/lib/esm/utils/getDomain.js +1 -0
  460. package/lib/esm/utils/getErrors.js +1 -0
  461. package/lib/esm/utils/getLineItemsCount.js +1 -0
  462. package/lib/esm/utils/getLoaderComponent.js +1 -0
  463. package/lib/esm/utils/getPaymentAttributes.js +1 -0
  464. package/lib/esm/utils/getPrices.js +1 -0
  465. package/lib/esm/utils/getSdk.js +1 -0
  466. package/lib/esm/utils/getSkus.js +1 -0
  467. package/lib/esm/utils/hasSubscriptions.js +1 -0
  468. package/lib/esm/utils/hooks/useCustomContext.js +1 -0
  469. package/lib/esm/utils/hooks/useExternalScript.js +1 -0
  470. package/lib/esm/utils/icons.js +1 -0
  471. package/lib/esm/utils/isDate.js +1 -0
  472. package/lib/esm/utils/isEmpty.js +1 -0
  473. package/lib/esm/utils/isEmptyStates.js +1 -0
  474. package/lib/esm/utils/isJSON.js +1 -0
  475. package/lib/esm/utils/jwt.js +1 -0
  476. package/lib/esm/utils/localStorage.js +1 -0
  477. package/lib/esm/utils/omit.js +1 -0
  478. package/lib/esm/utils/organization.js +1 -0
  479. package/lib/esm/utils/pick.js +1 -0
  480. package/lib/esm/utils/placeholderImages.js +1 -0
  481. package/lib/esm/utils/promisify.js +1 -0
  482. package/lib/esm/utils/replace.js +1 -0
  483. package/lib/esm/utils/scrollbarWidth.js +1 -0
  484. package/lib/esm/utils/shipments.js +1 -0
  485. package/lib/esm/utils/snakeToCamelCase.js +1 -0
  486. package/lib/esm/utils/validateFormFields.js +1 -0
  487. package/package.json +23 -23
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import useExternalScript from"../../utils/hooks/useExternalScript";import PlaceOrderContext from"../../context/PlaceOrderContext";function typeOfLine(lineItemType){switch(lineItemType){case"percentage_discount_promotions":return"discount";case"shipments":return"shipping_fee";case"skus":return"physical";case"payment_methods":default:return null}}function klarnaOrderLines(lineItems){return lineItems?lineItems?.map(item=>{const type=item.item_type?typeOfLine(item.item_type):null;return{quantity:item.quantity,total_amount:item.total_amount_cents,unit_price:item.unit_amount_cents,type}}):[]}export default function KlarnaPayment({clientToken,placeOrderCallback,locale="EN",...p}){const ref=useRef(null),{paymentSource,currentPaymentMethodType,setPaymentRef,setPaymentSource,setPaymentMethodErrors}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),{setPlaceOrder}=useContext(PlaceOrderContext),loaded=useExternalScript("https://x.klarnacdn.net/kp/lib/v1/api.js"),[klarna,setKlarna]=useState(),{containerClassName,...divProps}=p;useEffect(()=>{loaded&&window?.Klarna!==void 0&&setKlarna(window.Klarna)},[loaded,window.Klarna]),useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&loaded&&klarna&&(ref.current.onsubmit=async()=>{await handleClick(klarna)},setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType,loaded,klarna]);const handleClick=async kl=>{const[first]=paymentSource?.payment_methods||void 0,paymentMethodCategory=first?.identifier,billingAddress={given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:null,organization_name:null,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shippingAddress={given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,email:order?.customer_email,street_address:order?.shipping_address?.line_1,street_address2:null,postal_code:order?.shipping_address?.zip_code,organization_name:null,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code},klarnaData={merchant_data:order?.id,purchase_country:order?.country_code,purchase_currency:order?.currency_code,locale,shipping_address:shippingAddress,billing_address:billingAddress,order_amount:order?.total_amount_cents,order_lines:klarnaOrderLines(order?.line_items)};try{kl.Payments.load({container:"#klarna-payments-container",payment_method_category:paymentMethodCategory},{billing_address:billingAddress,shipping_address:shippingAddress},async function({show_form}){if(show_form)try{await kl.Payments.authorize({payment_method_category:paymentMethodCategory},klarnaData,async function(res){if(res.approved&&paymentSource&&currentPaymentMethodType){const ps=await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{auth_token:res.authorization_token}}),{placed}=setPlaceOrder&&ps&&await setPlaceOrder({paymentSource:ps})||{placed:!1};placed&&placeOrderCallback&&placeOrderCallback({placed})}})}catch(e){console.error("e",e),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:"Authorization error"}])}})}catch(e){console.error("Load Klarna libray",e)}};if(klarna&&clientToken){const[first]=paymentSource?.payment_methods||void 0;klarna.Payments.init({client_token:clientToken}),klarna.Payments.load({container:"#klarna-payments-container",payment_method_category:first?.identifier},{billing_address:{given_name:order?.billing_address?.first_name,family_name:order?.billing_address?.last_name,email:order?.customer_email,street_address:order?.billing_address?.line_1,street_address2:order?.billing_address?.line_2,postal_code:order?.billing_address?.zip_code,city:order?.billing_address?.city,region:order?.billing_address?.state_code,phone:order?.billing_address?.phone,country:order?.billing_address?.country_code},shipping_address:{given_name:order?.shipping_address?.first_name,family_name:order?.shipping_address?.last_name,street_address:order?.shipping_address?.line_1,street_address2:order?.shipping_address?.line_2,postal_code:order?.shipping_address?.zip_code,city:order?.shipping_address?.city,region:order?.shipping_address?.state_code,phone:order?.shipping_address?.phone,country:order?.shipping_address?.country_code}})}return _jsx("form",{ref,children:_jsx("div",{className:containerClassName,...divProps,children:_jsx("div",{id:"klarna-payments-container"})})})}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!!expressPayments),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const gatewayProps={...props,show,showCard,handleEditClick:async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},readonly};return _jsx(PaymentGateway,{...gatewayProps})}export default PaymentSource;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import{useContext,useRef}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandIcon({src,width=32,children,...p}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,ref=useRef(null),defaultSrc="//data.commercelayer.app/assets/images/icons/credit-cards/color/credit-card.svg",url=src||`//data.commercelayer.app/assets/images/icons/credit-cards/color/${cardBrand??"credit-card"}.svg`,handleError=()=>{ref.current&&(ref.current.src=defaultSrc)},parentProps={brand:cardBrand,defaultSrc,url,width,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("img",{ref,src:url,onError:handleError,width,...p})}export default PaymentSourceBrandIcon;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import capitalize from"lodash/capitalize";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandName({children,label,...props}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,brandName=cardBrand&&capitalize(cardBrand.replace(/_|-/gm," ")),parentProps={brand:brandName,label,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...props,children:label||capitalize(brandName)})}export default PaymentSourceBrandName;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceDetail({type,children,...p}){const card=useContext(PaymentSourceContext),customerCard=useContext(CustomerPaymentSourceContext),cardObj=Object.keys(card).length>0?card:customerCard,text=type in cardObj?cardObj[type]:type==="last4"?"****":"**",parentProps={type,text,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:text})}export default PaymentSourceDetail;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import{useContext}from"react";import Parent from"../utils/Parent";export function PaymentSourceEditButton({children,label="Edit",...props}){const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps={showCard,label,handleEditClick,...props};return children?_jsx(Parent,{...parentProps,children}):readonly?null:_jsx("button",{...props,onClick:handleEditClick,children:label})}export default PaymentSourceEditButton;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext from"../../context/PaymentMethodContext";import isFunction from"lodash/isFunction";import{useContext,useEffect,useRef}from"react";const defaultMessage="by placing the order, you will be redirected to the PayPal website to sign in and authorize the payment";export function PaypalPayment({infoMessage,...p}){const ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&paymentSource?.approval_url&&(ref.current.onsubmit=async()=>await handleClick(),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType]);const handleClick=async()=>{if(paymentSource&&currentPaymentMethodType)try{return await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{metadata:{card:{id:paymentSource.id,brand:"paypal",last4:""}}}}),!0}catch{return!1}return!1};return _jsx("form",{ref,children:_jsx("div",{...p,children:_jsx("span",{className:infoMessage?.className,children:isFunction(infoMessage?.text)?infoMessage?.text():infoMessage?.text||defaultMessage})})})}export default PaypalPayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{getAvailableExpressPayments,getExpressShippingMethods,setExpressFakeAddress,setExpressPlaceOrder,setExpressShippingMethod,expressRedirectUrl}from"../../utils/expressPaymentHelper";import{isEmpty}from"../../utils/isEmpty";import{PaymentRequestButtonElement,useStripe}from"@stripe/react-stripe-js";import{useContext,useEffect,useState}from"react";export function StripeExpressPayment({clientSecret}){const stripe=useStripe(),[paymentRequest,setPaymentRequest]=useState(null),{accessToken,endpoint}=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{paymentMethods,paymentSource}=useContext(PaymentMethodContext);return useEffect(()=>{if(stripe==null||order==null)return;const pr=stripe.paymentRequest({country:order?.country_code??"US",currency:order?.currency_code?.toLowerCase()??"",total:{label:`#${order?.number??""}`,amount:order?.total_amount_with_taxes_cents??0},requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:!0,requestShipping:!0});pr.canMakePayment().then(result=>{console.log("available payment:",result),result&&setPaymentRequest(pr)}).catch(err=>{console.error("Can make payment:",err)})},[isEmpty(stripe),isEmpty(order)]),paymentRequest!=null&&stripe!=null?(paymentRequest.on("shippingaddresschange",async ev=>{if(order!=null&&accessToken!=null&&endpoint!=null){const requiresBillingInfo=order?.requires_billing_info??!1,orderWithShipments=await setExpressFakeAddress({orderId:order.id,config:{accessToken,endpoint},address:{first_name:"Fake name",last_name:"Fake lastname",country_code:ev.shippingAddress.country??"",line_1:"Fake street 123",city:ev.shippingAddress.city??"Fake city",zip_code:ev.shippingAddress.postalCode??"12345",state_code:ev.shippingAddress.region??"Fake state",phone:"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0}}),shippingOptions=getExpressShippingMethods(orderWithShipments);shippingOptions!=null&&!isEmpty(shippingOptions)?ev.updateWith({status:"success",shippingOptions,total:{label:`#${orderWithShipments?.number??""}`,amount:orderWithShipments?.total_amount_with_taxes_cents??0}}):ev.updateWith({status:"invalid_shipping_address"})}else ev.updateWith({status:"fail"})}),paymentRequest.on("shippingoptionchange",async ev=>{if(order!=null&&accessToken!=null&&endpoint!=null){const updatedOrder=await setExpressShippingMethod({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev.shippingOption.id,params:{include:["shipments.available_shipping_methods"]}});ev.updateWith({status:"success",total:{label:`#${updatedOrder?.number??""}`,amount:updatedOrder?.total_amount_with_taxes_cents??0}})}else ev.updateWith({status:"fail"})}),paymentRequest.on("paymentmethod",async ev=>{if(order?.id==null)throw new Error("Order is null");if(paymentMethods==null)throw new Error("Payment methods are null");const[paymentMethod]=getAvailableExpressPayments(paymentMethods);if(paymentMethod==null)throw new Error("Payment method is null");if(paymentSource==null)throw new Error("Payment source is null");const requiresBillingInfo=order?.requires_billing_info??!1,paymentResource=paymentMethod?.payment_source_type;if(accessToken!=null&&endpoint!=null){const[firstName,lastName]=ev.payerName?.split(" ")??[],[line]=ev.shippingAddress?.addressLine??"",email=ev.payerEmail??"";await setExpressFakeAddress({orderId:order.id,config:{accessToken,endpoint},address:{first_name:firstName??"Fake name",last_name:lastName??"Fake lastname",country_code:ev?.shippingAddress?.country??"",line_1:line??"Fake street 123",city:ev?.shippingAddress?.city??"Fake city",zip_code:ev?.shippingAddress?.postalCode??"12345",state_code:ev?.shippingAddress?.region??"Fake state",phone:ev?.payerPhone??"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0},email}),await setExpressShippingMethod({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev?.shippingOption?.id,params:{include:["shipments.available_shipping_methods"]}});const placeOrderParams={config:{accessToken,endpoint},orderId:order?.id,paymentResource,paymentSourceId:paymentSource?.id};await setExpressPlaceOrder(placeOrderParams);const{paymentIntent,error:confirmError}=await stripe.confirmCardPayment(clientSecret,{payment_method:ev.paymentMethod.id},{handleActions:!1});if(confirmError)ev.complete("fail"),console.error("Confirm card payment:",confirmError);else if(ev.complete("success"),paymentIntent.status==="requires_action"){const{error}=await stripe.confirmCardPayment(clientSecret);if(error)console.error("Confirm card payment:",error);else{const placeOrderParams2={config:{accessToken,endpoint},orderId:order?.id,placeTheOrder:!0};try{const order2=await setExpressPlaceOrder(placeOrderParams2);ev.complete("success"),expressRedirectUrl({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}else{const placeOrderParams2={config:{accessToken,endpoint},orderId:order?.id,placeTheOrder:!0};try{const order2=await setExpressPlaceOrder(placeOrderParams2);ev.complete("success"),expressRedirectUrl({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}}),_jsx(PaymentRequestButtonElement,{className:"",options:{paymentRequest}})):null}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import{Elements,PaymentElement,useElements,useStripe}from"@stripe/react-stripe-js";import Parent from"../utils/Parent";import{setCustomerOrderParam}from"../../utils/localStorage";import OrderContext from"../../context/OrderContext";import{StripeExpressPayment}from"./StripeExpressPayment";const defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet}){const ref=useRef(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),stripe=useStripe(),elements=useElements();useEffect(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=async()=>await onSubmit({event:ref.current,stripe,elements}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=async({event,stripe:stripe2,elements:elements2})=>{if(!stripe2)return!1;const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=order?.customer_email??"",billingDetails={name:billingInfo?.full_name??"",email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:billingInfo?.line_2??"",postal_code:billingInfo?.zip_code??"",state:billingInfo?.state_code}},{error}=await stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:window.location.href,payment_method_data:{billing_details:billingDetails}},redirect:"if_required"});return error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1):!0}return!1};return _jsxs("form",{ref,children:[_jsx(PaymentElement,{id:"payment-element",options:{...defaultOptions,...options}}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}export function StripePayment({publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1,...p}){const[isLoaded,setIsLoaded]=useState(!1),[stripe,setStripe]=useState(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance,...divProps}=p;useEffect(()=>(show&&publishableKey&&import("@stripe/stripe-js").then(({loadStripe})=>{(async()=>{const res=await loadStripe(publishableKey,{locale});res!=null&&(setStripe(res),setIsLoaded(!0))})()}),()=>{setIsLoaded(!1)}),[show,publishableKey]);const elementsOptions={clientSecret,appearance:{...defaultAppearance,...appearance},fonts};return isLoaded&&stripe!=null&&clientSecret!=null?_jsx("div",{className:containerClassName,...divProps,children:_jsx(Elements,{stripe,options:elementsOptions,children:expressPayments?_jsx(StripeExpressPayment,{clientSecret}):_jsx(StripePaymentForm,{options,templateCustomerSaveToWallet})})}):null}export default StripePayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useRef}from"react";const defaultMessage="after placing the order, you will need to manually complete the payment with your bank";export function WireTransferPayment({infoMessage,...p}){const{className,"data-testid":dataTestId}=p,ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&&currentPaymentMethodType&&(ref.current.onsubmit=async()=>await handleClick(),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType]);const handleClick=async()=>{if(paymentSource&&currentPaymentMethodType)try{return await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{metadata:{card:{id:paymentSource.id,brand:"wire-transfer",last4:""}}}}),!0}catch{return!1}return!1};return _jsx("form",{ref,children:_jsx("div",{className,"data-testid":dataTestId,children:_jsx("span",{className:infoMessage?.className,children:infoMessage?.text??defaultMessage})})})}export default WireTransferPayment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import Parent from"../utils/Parent";import PricesContext from"../../context/PricesContext";import{useState,useEffect,useContext}from"react";import{getPricesComponent}from"../../utils/getPrices";import SkuChildrenContext from"../../context/SkuChildrenContext";export function Price(props){const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=useContext(PricesContext),{sku}=useContext(SkuChildrenContext),[skuPrices,setSkuPrices]=useState([]),sCode=pricesSkuCode||skuCode||sku?.code;useEffect(()=>(prices!=null&&`${sCode}`in prices?setSkuPrices(prices[sCode]):sCode&&!skuCodes.includes(sCode)&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes({skuCodes})),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps={loading,loader,prices:skuPrices,...props},pricesComponent=prices==null||skuPrices==null?null:getPricesComponent(skuPrices,props);return children?_jsx(Parent,{...parentProps,children}):_jsx(_Fragment,{children:loading||pricesComponent==null?loader:pricesComponent})}export default Price;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useContext,useReducer}from"react";import CommerceLayerContext from"../../context/CommerceLayerContext";import priceReducer,{priceInitialState,getSkusPrice,setSkuCodes}from"../../reducers/PriceReducer";import PricesContext from"../../context/PricesContext";import SkuContext from"../../context/SkuContext";export function PricesContainer(props){const{children,skuCode="",loader="Loading...",perPage=10,filters={}}=props,[state,dispatch]=useReducer(priceReducer,priceInitialState),config=useContext(CommerceLayerContext),{skuCodes}=useContext(SkuContext);!state.skuCodes.includes(skuCode)&&skuCode&&state.skuCodes.push(skuCode);const sCode=skuCodes&&skuCodes?.length>0?"":skuCode??"";useEffect(()=>{state.skuCodes.length===0&&skuCodes!=null&&skuCodes.length>0&&state.setSkuCodes!=null&&state.setSkuCodes({skuCodes,dispatch}),config.accessToken&&(state.skuCodes.length>0||sCode)&&getSkusPrice(sCode&&[sCode]||state.skuCodes,{config,dispatch,perPage,filters})},[config.accessToken,sCode,state.skuCodes.length]);const priceValue={...state,skuCode:sCode,loader,setSkuCodes:params=>{setSkuCodes({...params,dispatch})}};return _jsx(PricesContext.Provider,{value:priceValue,children})}export default PricesContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import ShipmentContext from"../../context/ShipmentContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import OrderContext from"../../context/OrderContext";export function Shipment({children,loader="Loading...",autoSelectSingleShippingMethod=!1}){const[loading,setLoading]=useState(!0),{shipments,deliveryLeadTimes,setShippingMethod}=useContext(ShipmentContext),{order}=useContext(OrderContext);useEffect(()=>(shipments!=null&&(autoSelectSingleShippingMethod?(async()=>{for(const shipment of shipments){const isSingle=shipment?.available_shipping_methods?.length===1;if(!shipment?.shipping_method&&isSingle){const[shippingMethod]=shipment?.available_shipping_methods||[];if(shippingMethod&&setShippingMethod!=null){const{success,order:order2}=await setShippingMethod(shipment.id,shippingMethod.id);typeof autoSelectSingleShippingMethod=="function"&&success&&autoSelectSingleShippingMethod(order2)}}else setTimeout(()=>{setLoading(!1)},200)}})():setLoading(!1)),()=>{setLoading(!0)}),[shipments!=null,shipments?.length,order?.gift_card_or_coupon_code]);const components=shipments?.map((shipment,k)=>{const lineItems=shipment.stock_line_items?.map(shipmentLineItem=>{const l=shipmentLineItem.line_item;return l&&(l.quantity=shipmentLineItem.quantity),l}),shippingMethods=shipment.available_shipping_methods,currentShippingMethodId=autoSelectSingleShippingMethod&&shippingMethods&&shippingMethods.length===1?shippingMethods[0]?.id:shipment.shipping_method?.id,stockTransfers=shipment.stock_transfers,parcels=shipment.parcels,times=deliveryLeadTimes?.filter(time=>time.stock_location?.id===shipment.stock_location?.id),shipmentProps={parcels,lineItems,shippingMethods,currentShippingMethodId,stockTransfers,deliveryLeadTimes:times,shipment,keyNumber:k+1};return _jsx(ShipmentChildrenContext.Provider,{value:shipmentProps,children},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default Shipment;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import Parent from"../utils/Parent";import get from"lodash/get";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";export function ShipmentField(props){const{name}=props,{shipment,keyNumber}=useContext(ShipmentChildrenContext),key=name,text=key!=="key_number"?get(shipment,key):keyNumber,parentProps={shipment,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...props,children:text})}export default ShipmentField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import ShipmentContext,{defaultShipmentContext}from"../../context/ShipmentContext";import{useContext,useEffect,useMemo,useReducer}from"react";import shipmentReducer,{shipmentInitialState,setShipmentErrors,getShipments,setShippingMethod}from"../../reducers/ShipmentReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import isEmpty from"lodash/isEmpty";export function ShipmentsContainer(props){const{children}=props,[state,dispatch]=useReducer(shipmentReducer,shipmentInitialState),{order,getOrder,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{include?.includes("shipments.available_shipping_methods")?includeLoaded?.["shipments.available_shipping_methods"]||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.stock_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0,"shipments.parcels.parcel_line_items":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.stock_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location","shipments.parcels.parcel_line_items"]})},[include?.length,includeLoaded!=null]),useEffect(()=>{order!=null&&!isEmpty(config)&&order.shipments&&getShipments({order,dispatch,config})},[order!=null,order?.shipments?.length]),useEffect(()=>(order&&(order.shipments&&order.shipments.length>0&&order.shipments.map(shipment=>shipment.available_shipping_methods&&shipment.available_shipping_methods.length>0).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"NO_SHIPPING_METHODS",message:"No shipping methods",resource:"shipments"}],dispatch),order.line_items&&order.line_items.length>0&&order.line_items.filter(({item_type:itemType})=>itemType==="skus").map(lineItem=>!!(lineItem.item?.do_not_ship||lineItem.item?.do_not_track||lineItem.item?.inventory?.quantity>=lineItem?.quantity)).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"OUT_OF_STOCK",message:"No stock available",resource:"line_items"}],dispatch)),()=>{setShipmentErrors([],dispatch)}),[order?.shipments]);const contextValue=useMemo(()=>({...state,setShipmentErrors:errors=>{defaultShipmentContext.setShipmentErrors(errors,dispatch)},setShippingMethod:async(shipmentId,shippingMethodId)=>await setShippingMethod({shippingMethodId,shipmentId,config,getOrder,order})}),[state]);return _jsx(ShipmentContext.Provider,{value:contextValue,children})}export default ShipmentsContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import ShipmentContext from"../../context/ShipmentContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function ShipmentsCount({children,...p}){const{shipments}=useCustomContext({context:ShipmentContext,contextComponentName:"ShipmentsContainer",currentComponentName:"ShipmentsCount",key:"shipments"}),quantity=shipments?.length??0,childrenProps={...p,quantity,shipments};return children?_jsx(Parent,{...childrenProps,children}):_jsx("span",{...p,children:quantity})}export default ShipmentsCount;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import isEmpty from"lodash/isEmpty";export function ShippingMethod(props){const{children,readonly,emptyText="There are not any shipping method available"}=props,{shippingMethods,currentShippingMethodId,deliveryLeadTimes,shipment}=useContext(ShipmentChildrenContext),[items,setItems]=useState([]);useEffect(()=>{const methods=shippingMethods?.filter(s=>readonly?s.id===currentShippingMethodId:!0).map((shippingMethod,k)=>{const[deliveryLeadTimeForShipment]=deliveryLeadTimes?.filter(delivery=>{const deliveryShippingMethodId=delivery.shipping_method?.id;return shippingMethod.id===deliveryShippingMethodId}),shippingProps={shipmentId:shipment?.id,shippingMethod,currentShippingMethodId,deliveryLeadTimeForShipment};return _jsx(ShippingMethodChildrenContext.Provider,{value:shippingProps,children},k)});methods&&setItems(methods)},[currentShippingMethodId,deliveryLeadTimes,shippingMethods]);const components=!isEmpty(items)&&items||emptyText;return _jsx(_Fragment,{children:components})}export default ShippingMethod;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";export function ShippingMethodName(props){const{shippingMethod,deliveryLeadTimeForShipment,shipmentId}=useContext(ShippingMethodChildrenContext),htmlFor=`shipment-${shipmentId??""}-${shippingMethod?.id??""}`||"",labelName=shippingMethod?.name,parentProps={shippingMethod,deliveryLeadTimeForShipment,label:labelName,htmlFor,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("label",{htmlFor,...props,children:labelName})}export default ShippingMethodName;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../../utils/getAmount";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";export function ShippingMethodPrice(props){const{base="price_amount",type="for_shipment",format="formatted",labelFreeOver="Free",...p}=props,{shippingMethod}=useContext(ShippingMethodChildrenContext),[price,setPrice]=useState(""),[priceCents,setPriceCents]=useState(0);useEffect(()=>{if(shippingMethod){const p2=getAmount({base,type,format,obj:shippingMethod});setPrice(p2);const pCents=getAmount({base:"price_amount",type:"for_shipment",format:"cents",obj:shippingMethod});setPriceCents(pCents)}return()=>{setPrice(""),setPriceCents(0)}},[shippingMethod]);const parentProps={price,...p},finalPrice=priceCents===0?labelFreeOver:price;return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:finalPrice})}export default ShippingMethodPrice;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";import ShipmentContext from"../../context/ShipmentContext";export function ShippingMethodRadioButton(props){const{onChange,...p}=props,[checked,setChecked]=useState(!1),{shippingMethod,currentShippingMethodId,shipmentId}=useContext(ShippingMethodChildrenContext),{setShippingMethod}=useContext(ShipmentContext),shippingMethodId=shippingMethod?.id,name=`shipment-${shipmentId??""}`,id=`${name}-${shippingMethodId??""}`;useEffect(()=>(setChecked(shippingMethodId===currentShippingMethodId),()=>{setChecked(!1)}),[currentShippingMethodId]);const handleOnChange=async()=>{if(shipmentId&&shippingMethodId&&setShippingMethod!=null){setChecked(!0);const{order}=await setShippingMethod(shipmentId,shippingMethodId);shippingMethod&&onChange!=null&&onChange({shippingMethod,shipmentId,order})}},parentProps={shippingMethod,shipmentId,handleOnChange,name,id,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("input",{type:"radio",name,id,onChange:()=>{handleOnChange()},checked,...p})}export default ShippingMethodRadioButton;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useReducer,useEffect,useMemo}from"react";import availabilityReducer,{availabilityInitialState,getAvailability}from"../../reducers/AvailabilityReducer";import AvailabilityContext from"../../context/AvailabilityContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import SkuChildrenContext from"../../context/SkuChildrenContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function AvailabilityContainer({children,skuCode,getQuantity}){const{lineItem}=useContext(LineItemChildrenContext),{sku}=useContext(SkuChildrenContext),{accessToken,endpoint}=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"AvailabilityContainer",key:"accessToken"}),[state,dispatch]=useReducer(availabilityReducer,availabilityInitialState),sCode=skuCode||lineItem?.sku_code||sku?.code;useEffect(()=>(accessToken!=null&&accessToken!==""&&sCode&&getAvailability({skuCode:sCode,config:{accessToken,endpoint},dispatch}),()=>{dispatch({type:"setAvailability",payload:{}})}),[accessToken,sCode]),useEffect(()=>{getQuantity!=null&&state?.quantity!=null&&getQuantity(state?.quantity)},[state.quantity]);const memoized=useMemo(()=>({...state,parent:!0}),[state]);return _jsx(AvailabilityContext.Provider,{value:memoized,children})}export default AvailabilityContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import AvailabilityContext from"../../context/AvailabilityContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function AvailabilityTemplate(props){const{timeFormat,showShippingMethodName,showShippingMethodPrice,children,...p}=props,{min,max,shipping_method:shippingMethod,quantity,skuCode}=useCustomContext({context:AvailabilityContext,contextComponentName:"AvailabilityContainer",currentComponentName:"AvailabilityTemplate",key:"parent"}),text=[],mn=min!=null&&timeFormat!=null?min?.[timeFormat]:"",mx=max!=null&&timeFormat!=null?max?.[timeFormat]:"",shippingMethodPrice=showShippingMethodPrice&&shippingMethod?.formatted_price_amount?`(${shippingMethod?.formatted_price_amount})`:"",name=showShippingMethodName&&shippingMethod?`with ${shippingMethod.name}`:"";quantity&&quantity>0?(text.push("Available"),mn&&mx&&timeFormat&&text.push(`in ${mn} - ${mx} ${timeFormat} ${name} ${shippingMethodPrice}`)):quantity===0&&text.push("Out of stock");const parentProps={min,max,shipping_method:shippingMethod,quantity,text:text.join(" "),...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{"data-testid":skuCode?`availability-${skuCode}`:"",...p,children:text.join(" ")})}export default AvailabilityTemplate;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import ShippingMethodChildrenContext from"../../context/ShippingMethodChildrenContext";import Parent from"../utils/Parent";export function DeliveryLeadTime(props){const{type,...p}=props,[text,setText]=useState(),{deliveryLeadTimeForShipment}=useContext(ShippingMethodChildrenContext);useEffect(()=>(deliveryLeadTimeForShipment?.[type]&&setText(deliveryLeadTimeForShipment[type]),()=>{setText("")}),[deliveryLeadTimeForShipment]);const parentProps={text,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:text})}export default DeliveryLeadTime;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function SkuField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"sku",attribute,tagElement,context:SkuChildrenContext,...p,children})}export default SkuField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{Fragment as _Fragment,jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect}from"react";import SkuListsContext from"../../context/SkuListsContext";export function SkuList(props){const{id,children}=props,{listIds}=useContext(SkuListsContext);return useEffect(()=>{listIds&&!listIds.includes(id)&&listIds.push(id)},[]),_jsx(_Fragment,{children})}export default SkuList;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{useReducer,useContext,useEffect}from"react";import SkuListsContext from"../../context/SkuListsContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import skuListsReducer,{skuListsInitialState,getSkuList}from"../../reducers/SkuListsReducer";export function SkuListsContainer(props){const{children}=props,[state,dispatch]=useReducer(skuListsReducer,skuListsInitialState),config=useContext(CommerceLayerContext);return useEffect(()=>{state.listIds&&state.listIds.length>0&&config.accessToken&&getSkuList({listIds:state.listIds,dispatch,config,state})},[config.accessToken]),_jsx(SkuListsContext.Provider,{value:state,children})}export default SkuListsContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import SkuContext from"../../context/SkuContext";import{useContext}from"react";export function Skus({children}){const{skus}=useContext(SkuContext),components=skus?.map((sku,key)=>{const value={sku};return _jsx(SkuChildrenContext.Provider,{value,children},key)});return _jsx(_Fragment,{children:components})}export default Skus;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import SkuContext from"../../context/SkuContext";import skuReducer,{getSku,skuInitialState}from"../../reducers/SkuReducer";import{useContext,useEffect,useMemo,useReducer}from"react";export function SkusContainer(props){const{skus,children,queryParams}=props,[state,dispatch]=useReducer(skuReducer,skuInitialState),config=useContext(CommerceLayerContext),loadSkus=async()=>{await getSku({config,dispatch,skus,queryParams})};useEffect(()=>(config.accessToken&&state?.skus&&state?.skus.length===0&&loadSkus(),()=>{dispatch({type:"setLoading",payload:{loading:!0}})}),[config,skus]);const contextValue=useMemo(()=>state,[state]);return _jsx(SkuContext.Provider,{value:contextValue,children})}export default SkusContainer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import StockTransferChildrenContext from"../../context/StockTransferChildrenContext";export function StockTransfer(props){const{children}=props,{stockTransfers,lineItems}=useContext(ShipmentChildrenContext),components=stockTransfers?.filter(st=>!!lineItems?.find(l=>l?.sku_code!==st?.sku_code)).map((stockTransfer,k)=>{const stockTransferProps={stockTransfer:stockTransfer.type==="line_items"?stockTransfer:stockTransfer?.line_item};return _jsx(StockTransferChildrenContext.Provider,{value:stockTransferProps,children},k)});return _jsx(_Fragment,{children:components})}export default StockTransfer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import StockTransferChildrenContext from"../../context/StockTransferChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function StockTransferField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"stock_transfers",attribute,tagElement,context:StockTransferChildrenContext,...p,children})}export default StockTransferField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import{useContext}from"react";import AddressChildrenContext from"../../context/AddressChildrenContext";import ShippingAddressContext from"../../context/ShippingAddressContext";export default function AddressCardsTemplate({customerAddresses,children,deselect,countryLock,selected,selectedClassName,className,disabledClassName,handleSelect}){const{setShippingAddress}=useContext(ShippingAddressContext),value={customerAddresses:customerAddresses.map((address,k)=>{const attributes=address,disabled=setShippingAddress&&countryLock&&countryLock!==address.country_code||!1,addressSelectedClass=selected===k?`${className??""} ${(deselect?"":selectedClassName)??""}`:className,finalClassName=disabled?`${className??""} ${disabledClassName??""}`:addressSelectedClass,customerAddressId=address?.reference||"";return{...attributes,className:finalClassName,onClick:async()=>{await handleSelect(k,address.id,customerAddressId,disabled,address)}}}),AddressProvider:AddressChildrenContext.Provider};return _jsx(Parent,{...value,children})}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import{useContext,useEffect,useState}from"react";import Parent from"./Parent";const BaseField=({children,attribute,...p})=>{const{order}=useContext(OrderContext),[field,setField]=useState("");useEffect(()=>(order&&attribute in order&&setField(order[attribute]),()=>{setField("")}),[order]);const parentProps={attribute:field,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:field})};export default BaseField;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import React from"react";import Parent from"./Parent";const BaseInput=(props,ref)=>{const{children,...p}=props,input=props.type==="textarea"?_jsx("textarea",{ref,...p}):_jsx("input",{ref,...p});return children?_jsx(Parent,{parentRef:ref,...p,children}):input};export default React.forwardRef(BaseInput);
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import getAmount from"../../utils/getAmount";import Parent from"./Parent";import{useState,useEffect,useContext}from"react";import isEmpty from"lodash/isEmpty";export function BaseOrderPrice(props){const{format="formatted",base,type,children,...p}=props,{order}=useContext(OrderContext),[price,setPrice]=useState(""),[cents,setCents]=useState(0);useEffect(()=>{const p2=getAmount({base,type,format,obj:order||{}}),c=getAmount({base,type,format:"cents",obj:order||{}});return setPrice(p2),setCents(c),()=>{isEmpty(order)&&setPrice("")}},[order]);const parentProps={priceCents:cents,price,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:price})}export default BaseOrderPrice;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import React from"react";import Parent from"./Parent";import{findIndex}from"lodash";const BaseSelect=(props,ref)=>{const{options=[],children,placeholder={label:"Select an option",value:""},value="",...p}=props;findIndex(options,placeholder)===-1?options.unshift(placeholder):options[0]=placeholder;const Options=options.map((o,k)=>{const{label,...option}=o;return _jsx("option",{...option,children:label},k)}),parentProps={options,ref,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("select",{ref,defaultValue:value,...p,children:Options})};export default React.forwardRef(BaseSelect);
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import{Component}from"react";export class ErrorBoundary extends Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(error,errorInfo){if(process.env.NODE_ENV!=="test")console.error("Uncaught error:",error,errorInfo);else throw error}render(){return this.state.hasError?_jsx("h1",{children:"Sorry.. there was an error, check the console."}):this.props.children}}export default ErrorBoundary;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"./Parent";import{useContext}from"react";import{defaultImgUrl}from"../../utils/placeholderImages";export default function GenericFieldComponent(props){const{children,tagElement,attribute,context,resource,...p}=props,resourceContext=useContext(context);let attributeValue="";const keysContext=Object.keys(resourceContext).filter(key=>key===resource);if(keysContext.length===1){const[keyResource]=keysContext;keyResource&&attribute&&(attributeValue=resourceContext[keyResource][attribute])}const Tag=tagElement||"span";if(Tag==="img"&&!children)return _jsx("img",{alt:"",src:attributeValue||defaultImgUrl,...p});const parentProps={attributeValue,tagElement,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx(Tag,{"data-testid":attributeValue,...p,children:attributeValue},attributeValue)}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";export default function Parent({children,...p}){const Child=children;return Child!==void 0?_jsx(Child,{...p}):null}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import{useContext}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import getCardDetails from"../../utils/getCardDetails";export default function PaymentCardsTemplate({customerPayments,children,paymentResource}){const{setPaymentSource}=useContext(PaymentMethodContext),value={customerPayments:customerPayments.map(customerPayment=>{const attributes=customerPayment,card=getCardDetails({customerPayment,paymentType:paymentResource});return{...attributes,card,handleClick:async e=>{e.stopPropagation(),await setPaymentSource({paymentResource,customerPaymentSourceId:customerPayment.id})}}}),PaymentSourceProvider:PaymentSourceContext.Provider};return _jsx(Parent,{...value,children})}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export function PriceTemplate(props){const{showCompare,formattedCompare,compareClassName,className,formattedAmount,skuCode,...p}=props;return _jsxs(_Fragment,{children:[_jsx("span",{"data-testid":`price-${skuCode??""}`,className,...p,children:formattedAmount}),showCompare&&_jsx("span",{"data-testid":`compare-${skuCode??""}`,className:compareClassName||"",...p,children:formattedCompare})]})}export default PriceTemplate;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{jsx as _jsx}from"react/jsx-runtime";import customMessages from"../../utils/customMessages";const getAllErrors=params=>{const{allErrors,messages,field,props,lineItem,resource,returnHtml=!0}=params;return allErrors.map((v,k)=>{const objMsg=customMessages(messages,v);let text=v?.title&&v?.detail!=null&&!v.detail?.includes(v.title)?`${v.title} - ${v.detail}`:`${v?.detail||v.message}`;if(objMsg?.message&&(text=objMsg?.message),field){if(v.resource==="line_items"&&lineItem&&v.id===lineItem.id)return returnHtml?_jsx("span",{...props,children:text},k):text;if(field===v.field&&resource===v.resource)return returnHtml?_jsx("span",{...props,children:text},k):text}if(resource===v.resource&&!field)return returnHtml?_jsx("span",{...props,children:text},k):text}).filter(v=>v!==void 0)};export default getAllErrors;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  export default[{value:"AED",label:"AED"},{value:"AFN",label:"AFN"},{value:"ALL",label:"ALL"},{value:"AMD",label:"AMD"},{value:"ANG",label:"ANG"},{value:"AOA",label:"AOA"},{value:"ARS",label:"ARS"},{value:"AUD",label:"AUD"},{value:"AWG",label:"AWG"},{value:"AZN",label:"AZN"},{value:"BAM",label:"BAM"},{value:"BBD",label:"BBD"},{value:"BDT",label:"BDT"},{value:"BGN",label:"BGN"},{value:"BHD",label:"BHD"},{value:"BIF",label:"BIF"},{value:"BMD",label:"BMD"},{value:"BND",label:"BND"},{value:"BOB",label:"BOB"},{value:"BRL",label:"BRL"},{value:"BSD",label:"BSD"},{value:"BTN",label:"BTN"},{value:"BWP",label:"BWP"},{value:"BYN",label:"BYN"},{value:"BYR",label:"BYR"},{value:"BZD",label:"BZD"},{value:"CAD",label:"CAD"},{value:"CDF",label:"CDF"},{value:"CHF",label:"CHF"},{value:"CLF",label:"CLF"},{value:"CLP",label:"CLP"},{value:"CNY",label:"CNY"},{value:"COP",label:"COP"},{value:"CRC",label:"CRC"},{value:"CUC",label:"CUC"},{value:"CUP",label:"CUP"},{value:"CVE",label:"CVE"},{value:"CZK",label:"CZK"},{value:"DJF",label:"DJF"},{value:"DKK",label:"DKK"},{value:"DOP",label:"DOP"},{value:"DZD",label:"DZD"},{value:"EGP",label:"EGP"},{value:"ERN",label:"ERN"},{value:"ETB",label:"ETB"},{value:"EUR",label:"EUR"},{value:"FJD",label:"FJD"},{value:"FKP",label:"FKP"},{value:"GBP",label:"GBP"},{value:"GEL",label:"GEL"},{value:"GHS",label:"GHS"},{value:"GIP",label:"GIP"},{value:"GMD",label:"GMD"},{value:"GNF",label:"GNF"},{value:"GTQ",label:"GTQ"},{value:"GYD",label:"GYD"},{value:"HKD",label:"HKD"},{value:"HNL",label:"HNL"},{value:"HRK",label:"HRK"},{value:"HTG",label:"HTG"},{value:"HUF",label:"HUF"},{value:"IDR",label:"IDR"},{value:"ILS",label:"ILS"},{value:"INR",label:"INR"},{value:"IQD",label:"IQD"},{value:"IRR",label:"IRR"},{value:"ISK",label:"ISK"},{value:"JMD",label:"JMD"},{value:"JOD",label:"JOD"},{value:"JPY",label:"JPY"},{value:"KES",label:"KES"},{value:"KGS",label:"KGS"},{value:"KHR",label:"KHR"},{value:"KMF",label:"KMF"},{value:"KPW",label:"KPW"},{value:"KRW",label:"KRW"},{value:"KWD",label:"KWD"},{value:"KYD",label:"KYD"},{value:"KZT",label:"KZT"},{value:"LAK",label:"LAK"},{value:"LBP",label:"LBP"},{value:"LKR",label:"LKR"},{value:"LRD",label:"LRD"},{value:"LSL",label:"LSL"},{value:"LTL",label:"LTL"},{value:"LVL",label:"LVL"},{value:"LYD",label:"LYD"},{value:"MAD",label:"MAD"},{value:"MDL",label:"MDL"},{value:"MGA",label:"MGA"},{value:"MKD",label:"MKD"},{value:"MMK",label:"MMK"},{value:"MNT",label:"MNT"},{value:"MOP",label:"MOP"},{value:"MRO",label:"MRO"},{value:"MUR",label:"MUR"},{value:"MVR",label:"MVR"},{value:"MWK",label:"MWK"},{value:"MXN",label:"MXN"},{value:"MYR",label:"MYR"},{value:"MZN",label:"MZN"},{value:"NAD",label:"NAD"},{value:"NGN",label:"NGN"},{value:"NIO",label:"NIO"},{value:"NOK",label:"NOK"},{value:"NPR",label:"NPR"},{value:"NZD",label:"NZD"},{value:"OMR",label:"OMR"},{value:"PAB",label:"PAB"},{value:"PEN",label:"PEN"},{value:"PGK",label:"PGK"},{value:"PHP",label:"PHP"},{value:"PKR",label:"PKR"},{value:"PLN",label:"PLN"},{value:"PYG",label:"PYG"},{value:"QAR",label:"QAR"},{value:"RON",label:"RON"},{value:"RSD",label:"RSD"},{value:"RUB",label:"RUB"},{value:"RWF",label:"RWF"},{value:"SAR",label:"SAR"},{value:"SBD",label:"SBD"},{value:"SCR",label:"SCR"},{value:"SDG",label:"SDG"},{value:"SEK",label:"SEK"},{value:"SGD",label:"SGD"},{value:"SHP",label:"SHP"},{value:"SKK",label:"SKK"},{value:"SLL",label:"SLL"},{value:"SOS",label:"SOS"},{value:"SRD",label:"SRD"},{value:"SSP",label:"SSP"},{value:"STD",label:"STD"},{value:"SVC",label:"SVC"},{value:"SYP",label:"SYP"},{value:"SZL",label:"SZL"},{value:"THB",label:"THB"},{value:"TJS",label:"TJS"},{value:"TMT",label:"TMT"},{value:"TND",label:"TND"},{value:"TOP",label:"TOP"},{value:"TRY",label:"TRY"},{value:"TTD",label:"TTD"},{value:"TWD",label:"TWD"},{value:"TZS",label:"TZS"},{value:"UAH",label:"UAH"},{value:"UGX",label:"UGX"},{value:"USD",label:"USD"},{value:"UYU",label:"UYU"},{value:"UZS",label:"UZS"},{value:"VEF",label:"VEF"},{value:"VND",label:"VND"},{value:"VUV",label:"VUV"},{value:"WST",label:"WST"},{value:"XAF",label:"XAF"},{value:"XAG",label:"XAG"},{value:"XAU",label:"XAU"},{value:"XBA",label:"XBA"},{value:"XBB",label:"XBB"},{value:"XBC",label:"XBC"},{value:"XBD",label:"XBD"},{value:"XCD",label:"XCD"},{value:"XDR",label:"XDR"},{value:"XOF",label:"XOF"},{value:"XPD",label:"XPD"},{value:"XPF",label:"XPF"},{value:"XPT",label:"XPT"},{value:"XTS",label:"XTS"},{value:"YER",label:"YER"},{value:"ZAR",label:"ZAR"},{value:"ZMK",label:"ZMK"},{value:"ZMW",label:"ZMW"},{value:"BTC",label:"BTC"},{value:"JEP",label:"JEP"},{value:"GGP",label:"GGP"},{value:"IMP",label:"IMP"},{value:"XFU",label:"XFU"},{value:"GBX",label:"GBX"},{value:"CNH",label:"CNH"},{value:"EEK",label:"EEK"},{value:"GHS",label:"GHS"},{value:"MTL",label:"MTL"},{value:"TMM",label:"TMM"},{value:"JPY",label:"JPY"},{value:"ZWD",label:"ZWD"},{value:"ZWL",label:"ZWL"},{value:"ZWN",label:"ZWN"},{value:"ZWR",label:"ZWR"}];
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={address:void 0},AddressChildrenContext=createContext(initial);export default AddressChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{setAddress}from"../reducers/AddressReducer";export const defaultAddressContext={setCloneAddress:()=>{},setAddress,setAddressErrors:()=>{}};const AddressesContext=createContext(defaultAddressContext);export default AddressesContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{availabilityInitialState}from"../reducers/AvailabilityReducer";const AvailabilityContext=createContext(availabilityInitialState);export default AvailabilityContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";export const defaultBillingAddressContext={};const BillingAddressContext=createContext(defaultBillingAddressContext);export default BillingAddressContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const BillingAddressFormContext=createContext({});export default BillingAddressFormContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={},CommerceLayerContext=createContext(initial);export default CommerceLayerContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const CouponAndGiftCardFormContext=createContext({});export default CouponAndGiftCardFormContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const CustomerAddressFormContext=createContext({});export default CustomerAddressFormContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";export const defaultCustomerContext={};const CustomerContext=createContext(defaultCustomerContext);export default CustomerContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";export const defaultCustomerPaymentSourceContext={};const CustomerPaymentSourceContext=createContext(defaultCustomerPaymentSourceContext);export default CustomerPaymentSourceContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import axios from"axios";export const callExternalFunction=async({url,data})=>await axios.post(url,data);const ExternalFunctionContext=createContext({url:null,callExternalFunction});export default ExternalFunctionContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{giftCardInitialState}from"../reducers/GiftCardReducer";const GiftCardContext=createContext(giftCardInitialState);export default GiftCardContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={},InStockSubscriptionContext=createContext(initial);export default InStockSubscriptionContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={},LineItemChildrenContext=createContext(initial);export default LineItemChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={},LineItemContext=createContext(initial);export default LineItemContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={lineItemOption:{}},LineItemOptionChildrenContext=createContext(initial);export default LineItemOptionChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{createOrder,setGiftCardOrCouponCode,removeGiftCardOrCouponCode,saveAddressToCustomerAddressBook,addResourceToInclude,updateOrder}from"../reducers/OrderReducer";export const defaultOrderContext={createOrder,setOrderErrors:()=>{},setOrder:()=>{},setGiftCardOrCouponCode,removeGiftCardOrCouponCode,saveAddressToCustomerAddressBook,addResourceToInclude,getOrder:async()=>{},updateOrder};const OrderContext=createContext(defaultOrderContext);export default OrderContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={showActions:!1},OrderListChildrenContext=createContext(initial);export default OrderListChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const ctx=createContext(null);export default ctx;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{getLocalOrder,setLocalOrder,deleteLocalOrder}from"../utils/localStorage";const initial={persistKey:"",clearWhenPlaced:!0,getLocalOrder,setLocalOrder,deleteLocalOrder},OrderStorageContext=createContext(initial);export default OrderStorageContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={};export default createContext(initial);
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={};export default createContext(initial);
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={},PaymentMethodChildrenContext=createContext(initial);export default PaymentMethodChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{updatePaymentSource,setPaymentMethodErrors,setPaymentSource,setPaymentMethod,destroyPaymentSource,setPaymentRef,setLoading}from"../reducers/PaymentMethodReducer";export const defaultPaymentMethodContext={setPaymentMethodErrors,setPaymentMethod,setPaymentSource,setPaymentRef,destroyPaymentSource,updatePaymentSource,setLoading};const PaymentMethodContext=createContext(defaultPaymentMethodContext);export default PaymentMethodContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";export const defaultPaymentSourceContext={};const PaymentSourceContext=createContext(defaultPaymentSourceContext);export default PaymentSourceContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{setPlaceOrderErrors}from"../reducers/PlaceOrderReducer";export const defaultPlaceOrderContext={setPlaceOrderErrors};const PlaceOrderContext=createContext(defaultPlaceOrderContext);export default PlaceOrderContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{priceInitialState}from"../reducers/PriceReducer";const PricesContext=createContext(priceInitialState);export default PricesContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={keyNumber:0,lineItems:[],shippingMethods:[],stockTransfers:[]},ShipmentChildrenContext=createContext(initial);export default ShipmentChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{setShipmentErrors}from"../reducers/ShipmentReducer";export const defaultShipmentContext={setShipmentErrors};const ShipmentContext=createContext(defaultShipmentContext);export default ShipmentContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";export const defaultShippingAddressContext={};const ShippingAddressContext=createContext(defaultShippingAddressContext);export default ShippingAddressContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const ShippingAddressFormContext=createContext({});export default ShippingAddressFormContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={},ShippingMethodChildrenContext=createContext(initial);export default ShippingMethodChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={},SkuChildrenContext=createContext(initial);export default SkuChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const SkuContext=createContext({});export default SkuContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";import{skuListsInitialState}from"../reducers/SkuListsReducer";export const SkuListsContext=createContext(skuListsInitialState);export default SkuListsContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import{createContext}from"react";const initial={},StockTransferChildrenContext=createContext(initial);export default StockTransferChildrenContext;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import CommerceLayerContext from"../context/CommerceLayerContext";import getSdk from"../utils/getSdk";import{useContext}from"react";export function useCommerceLayer(){const ctx=useContext(CommerceLayerContext);if("accessToken"in ctx)return{accessToken:ctx.accessToken,sdkClient:()=>{if(ctx?.accessToken!=null&&ctx?.endpoint!=null)return getSdk({accessToken:ctx.accessToken,endpoint:ctx.endpoint})}};throw new Error("Cannot use `useCommerceLayer` outside of <CommerceLayer/>")}export default useCommerceLayer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import OrderContext from"../context/OrderContext";import{useContext}from"react";export function useOrderContainer(){const ctx=useContext(OrderContext);if("order"in ctx)return{order:ctx.order,reloadOrder:async()=>{if(ctx?.order?.id)return await ctx?.getOrder(ctx?.order?.id)}};throw new Error("Cannot use `useOrderContainer` outside of <OrderContainer/>")}export default useOrderContainer;
package/lib/esm/index.js CHANGED
@@ -1 +1,2 @@
1
+ "use client";
1
2
  export*from"./components/ExternalFunction";export*from"./components/MetadataInput";export*from"./components/SubmitButton";export*from"./components/addresses/Address";export*from"./components/addresses/AddressCountrySelector";export*from"./components/addresses/AddressField";export*from"./components/addresses/AddressInput";export*from"./components/addresses/AddressStateSelector";export*from"./components/addresses/AddressesContainer";export*from"./components/addresses/AddressesEmpty";export*from"./components/addresses/BillingAddressContainer";export*from"./components/addresses/BillingAddressForm";export*from"./components/addresses/SaveAddressesButton";export*from"./components/addresses/ShippingAddressContainer";export*from"./components/addresses/ShippingAddressForm";export*from"./components/auth/CommerceLayer";export*from"./components/customers/CustomerAddressForm";export*from"./components/customers/CustomerContainer";export*from"./components/customers/CustomerField";export*from"./components/customers/CustomerInput";export*from"./components/customers/SaveCustomerButton";export*from"./components/errors/Errors";export*from"./components/gift_cards/GiftCard";export*from"./components/gift_cards/GiftCardContainer";export*from"./components/gift_cards/GiftCardCurrencySelector";export*from"./components/gift_cards/GiftCardInput";export*from"./components/gift_cards/GiftCardOrCouponCode";export*from"./components/gift_cards/GiftCardOrCouponForm";export*from"./components/gift_cards/GiftCardOrCouponInput";export*from"./components/gift_cards/GiftCardOrCouponRemoveButton";export*from"./components/gift_cards/GiftCardOrCouponSubmit";export*from"./components/in_stock_subscriptions/InStockSubscriptionButton";export*from"./components/in_stock_subscriptions/InStockSubscriptionsContainer";export*from"./components/line_items/LineItem";export*from"./components/line_items/LineItemAmount";export*from"./components/line_items/LineItemCode";export*from"./components/line_items/LineItemField";export*from"./components/line_items/LineItemImage";export*from"./components/line_items/LineItemName";export*from"./components/line_items/LineItemOption";export*from"./components/line_items/LineItemOptions";export*from"./components/line_items/LineItemQuantity";export*from"./components/line_items/LineItemRemoveLink";export*from"./components/line_items/LineItemsContainer";export*from"./components/line_items/LineItemsCount";export*from"./components/line_items/LineItemsEmpty";export*from"./components/orders/AddToCartButton";export*from"./components/orders/AdjustmentAmount";export*from"./components/orders/CartLink";export*from"./components/orders/CheckoutLink";export*from"./components/orders/DiscountAmount";export*from"./components/orders/GiftCardAmount";export*from"./components/orders/OrderContainer";export*from"./components/orders/OrderList";export*from"./components/orders/OrderListEmpty";export*from"./components/orders/OrderListRow";export*from"./components/orders/OrderNumber";export*from"./components/orders/OrderStorage";export*from"./components/orders/PaymentMethodAmount";export*from"./components/orders/PlaceOrderButton";export*from"./components/orders/PlaceOrderContainer";export*from"./components/orders/PrivacyAndTermsCheckbox";export*from"./components/orders/ShippingAmount";export*from"./components/orders/SubTotalAmount";export*from"./components/orders/TaxesAmount";export*from"./components/orders/TotalAmount";export*from"./components/parcels/ParcelField";export*from"./components/parcels/ParcelLineItem";export*from"./components/parcels/ParcelLineItemField";export*from"./components/parcels/ParcelLineItemsCount";export*from"./components/parcels/Parcels";export*from"./components/parcels/ParcelsCount";export*from"./components/payment_methods/PaymentMethod";export*from"./components/payment_methods/PaymentMethodName";export*from"./components/payment_methods/PaymentMethodPrice";export*from"./components/payment_methods/PaymentMethodRadioButton";export*from"./components/payment_methods/PaymentMethodsContainer";export*from"./components/payment_source/PaymentSource";export*from"./components/payment_source/PaymentSourceBrandIcon";export*from"./components/payment_source/PaymentSourceBrandName";export*from"./components/payment_source/PaymentSourceDetail";export*from"./components/payment_source/PaymentSourceEditButton";export*from"./components/prices/Price";export*from"./components/prices/PricesContainer";export*from"./components/shipments/Shipment";export*from"./components/shipments/ShipmentField";export*from"./components/shipments/ShipmentsContainer";export*from"./components/shipments/ShipmentsCount";export*from"./components/shipping_methods/ShippingMethod";export*from"./components/shipping_methods/ShippingMethodName";export*from"./components/shipping_methods/ShippingMethodPrice";export*from"./components/shipping_methods/ShippingMethodRadioButton";export*from"./components/skus/AvailabilityContainer";export*from"./components/skus/AvailabilityTemplate";export*from"./components/skus/DeliveryLeadTime";export*from"./components/skus/SkuField";export*from"./components/skus/SkuList";export*from"./components/skus/SkuListsContainer";export*from"./components/skus/Skus";export*from"./components/skus/SkusContainer";export*from"./components/stock_transfers/StockTransfer";export*from"./components/stock_transfers/StockTransferField";export*from"./hooks/useOrderContainer";export*from"./hooks/useCommerceLayer";export*from"./typings/errors";
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";export const addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],addressInitialState={errors:[]},setAddressErrors=({errors,dispatch,currentErrors=[],resource})=>{const billingErrors=resource==="billing_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="billing_address"),shippingErrors=resource==="shipping_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="shipping_address"),finalErrors=[...billingErrors,...shippingErrors];dispatch&&dispatch({type:"setErrors",payload:{errors:finalErrors}})},setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})},setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${camelCase(resource)}Id`]:id}})};export async function saveAddresses({config,updateOrder,order,state,customerEmail}){const{shipToDifferentAddress,billing_address:billingAddress,shipping_address:shippingAddress,billingAddressId,shippingAddressId}=state;try{const sdk=getSdk(config);if(order){const currentBillingAddressRef=order?.billing_address?.reference,orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId,customer_email:customerEmail};if(currentBillingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),!isEmpty(billingAddress)&&billingAddress){delete orderAttributes._billing_address_clone_id,delete orderAttributes._shipping_address_clone_id,orderAttributes._shipping_address_same_as_billing=!0;const address=await sdk.addresses.create(billingAddress);orderAttributes.billing_address=sdk.addresses.relationship(address.id)}if(shipToDifferentAddress&&(delete orderAttributes._shipping_address_same_as_billing,shippingAddressId&&(orderAttributes._shipping_address_clone_id=shippingAddressId),!isEmpty(shippingAddress)&&shippingAddress)){delete orderAttributes._shipping_address_clone_id;const address=await sdk.addresses.create(shippingAddress);orderAttributes.shipping_address=sdk.addresses.relationship(address.id)}if(!isEmpty(orderAttributes)&&updateOrder)return{success:!0,order:(await updateOrder({id:order.id,attributes:orderAttributes}))?.order}}return{success:!1}}catch(error){return console.error(error),{success:!1,error}}}const type=["setErrors","setAddress","setShipToDifferentAddress","setCloneAddress","cleanup"],addressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default addressReducer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const availabilityInitialState={};export async function getAvailability({skuCode,dispatch,config}){const sdk=getSdk(config);try{const[sku]=await sdk.skus.list({fields:{skus:["id"]},filters:{code_in:skuCode}});if(sku){const skuInventory=await sdk.skus.retrieve(sku.id,{fields:{skus:["inventory"]}}),[level]=skuInventory.inventory?.levels||[],[delivery]=level?.delivery_lead_times||[];dispatch({type:"setAvailability",payload:{...delivery,quantity:skuInventory.inventory.quantity,skuCode}})}}catch(error){console.error("Get SKU availability",error)}}const typeAction=["setAvailability","setErrors"],availabilityReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default availabilityReducer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const billingAddressInitialState={_billing_address_clone_id:""},setBillingAddress=async(id,options)=>{try{if(options?.order){if(options.customerAddressId){const sdk=getSdk(options.config),attributes={id,reference:options.customerAddressId};await sdk.addresses.update(attributes)}options.dispatch({type:"setBillingAddress",payload:{_billing_address_clone_id:id}})}}catch(error){console.error("Set billing address",error)}};export function setBillingCustomerAddressId({dispatch,order,setCloneAddress}){const customerAddressId=order?.billing_address?.reference;try{customerAddressId&&(dispatch({type:"setBillingCustomerAddressId",payload:{billingCustomerAddressId:customerAddressId}}),setCloneAddress(customerAddressId,"billing_address"))}catch(error){console.error("error",error)}}const type=["setBillingAddress","setBillingCustomerAddressId","cleanup"],billingAddressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default billingAddressReducer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";import jwtDecode from"../utils/jwt";export async function saveCustomerUser({customerEmail,order,updateOrder}){if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}}export function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}export function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}export async function getCustomerAddresses({config,dispatch,isOrderAvailable}){try{const addresses=[];(await getSdk(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&(customerAddress.id!==customerAddress.address.reference&&!isOrderAvailable&&(customerAddress.address.reference=customerAddress.id),addresses.push(customerAddress.address))}),addresses.sort((a,b)=>a.full_name&&b.full_name?a.full_name.localeCompare(b.full_name):0),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=getErrors({error,resource:"addresses"});dispatch({type:"setErrors",payload:{errors}})}}export async function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){if(config&&addresses&&dispatch&&config)try{await getSdk(config).customer_addresses.delete(customerAddressId);const newAddresses=addresses.filter(({reference})=>reference!==customerAddressId);dispatch({type:"setAddresses",payload:{addresses:newAddresses}})}catch{throw new Error("Couldn't delete address")}}export function getCustomerPaymentSources(params){if(params){const{order,dispatch}=params;order?.available_customer_payment_sources&&dispatch&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})}}export async function getCustomerOrders({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const orders=await getSdk(config).customers.orders(owner.id,{filters:{status_not_in:"draft,pending"},pageSize,pageNumber});dispatch({type:"setOrders",payload:{orders}})}}}export async function getCustomerSubscriptions({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const subscriptions=await getSdk(config).customers.order_subscriptions(owner.id,{pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}}}export async function createCustomerAddress({address,config,dispatch,state}){if(config&&address){const sdk=getSdk(config),{id}=address;try{if(id){const upAddress=await sdk.addresses.update(address),updatedAddresses=state?.addresses?.map(a=>a.id===upAddress.id?upAddress:a);dispatch&&dispatch({type:"setAddresses",payload:{addresses:updatedAddresses}})}else{const newAddress=await sdk.addresses.create(address);if(state?.customers?.id&&newAddress?.id){const newCustomerAddress=await sdk.customer_addresses.create({customer:sdk.customers.relationship(state?.customers?.id),address:sdk.addresses.relationship(newAddress.id)});await sdk.addresses.update({id:newAddress.id,reference:newCustomerAddress.id}),dispatch&&state?.addresses&&(newAddress.reference=newCustomerAddress.id,dispatch({type:"setAddresses",payload:{addresses:[...state.addresses,newAddress]}}))}}}catch{throw new Error("Couldn't create customer address")}}}export async function getCustomerPayments({config,dispatch}){if(config!=null&&dispatch!=null){const payments=await getSdk(config).customer_payment_sources.list({include:["payment_source"]});dispatch({type:"setPayments",payload:{payments}})}}export const customerInitialState={errors:[],addresses:null,payments:null};const type=["setErrors","setCustomerEmail","setAddresses","setPayments","setOrders","setSubscriptions"],customerReducer=(state,reducer)=>baseReducer(state,reducer,type);export default customerReducer;
@@ -1 +1,2 @@
1
+ "use client";
1
2
  import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";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:[]};export async function addGiftCardRecipient(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)}}export const addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})};export async function addGiftCard(values,{config,dispatch,getOrder,createOrder,order}){try{const sdk=getSdk(config);addGiftCardLoading(!0,dispatch);const{firstName,lastName,email,...val}=values,giftCardValue={recipient_email:email,...val},giftCard=await sdk.gift_cards.create(giftCardValue,{include:["gift_card_recipient"]}),recipientValues={id:giftCard.gift_card_recipient?.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}),await getOrder(id)}}dispatch({type:"setGiftCardRecipient",payload:{...giftCardValue}}),addGiftCardLoading(!1,dispatch)}catch(error){const errors=getErrors({error,resource:"gift_cards"});dispatch({type:"setGiftCardErrors",payload:{errors}}),addGiftCardLoading(!1,dispatch)}}export const 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,2 @@
1
+ "use client";
1
2
  import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";const actionType=["setErrors"];export const inStockSubscriptionInitialState={errors:[]};export async function setInStockSubscription({config,customerEmail,skuCode,dispatch}){try{if(config==null)throw new Error("Access token and endpoint is required");const sdk=getSdk(config),attributes={sku_code:skuCode};return customerEmail!=null&&(attributes.customer_email=customerEmail),await sdk.in_stock_subscriptions.create(attributes),{success:!0}}catch(error){const errors=getErrors({error,resource:"in_stock_subscriptions"});return dispatch?.({type:"setErrors",payload:{errors}}),{success:!1}}}export default function inStockSubscriptionReducer(state,reducer){return baseReducer(state,reducer,actionType)}
@@ -1 +1,2 @@
1
+ "use client";
1
2
  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?.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,resource:"line_items"});dispatch({type:"setErrors",payload:{errors}})})};export async function updateLineItem(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,resource:"line_items",attributes:{id:lineItemId}});dispatch({type:"setErrors",payload:{errors}})}}export const 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,resource:"line_items"});dispatch({type:"setErrors",payload:{errors}})}},lineItemInitialState={loading:!1,errors:[]};const actionType=["setLineItems","setErrors","setLoading"],lineItemReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default lineItemReducer;