@commercelayer/react-components 4.1.0-beta.1 → 4.1.0-beta.3

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 (270) hide show
  1. package/lib/cjs/components/MetadataInput.d.ts +1 -1
  2. package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +1 -1
  3. package/lib/cjs/components/addresses/AddressField.d.ts +2 -2
  4. package/lib/cjs/components/addresses/AddressInput.d.ts +2 -2
  5. package/lib/cjs/components/addresses/AddressInput.js +1 -1
  6. package/lib/cjs/components/addresses/AddressStateSelector.d.ts +1 -1
  7. package/lib/cjs/components/addresses/BillingAddressContainer.d.ts +1 -1
  8. package/lib/cjs/components/addresses/BillingAddressForm.d.ts +1 -1
  9. package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -1
  10. package/lib/cjs/components/customers/CustomerField.d.ts +3 -3
  11. package/lib/cjs/components/customers/CustomerInput.d.ts +1 -1
  12. package/lib/cjs/components/customers/SaveCustomerButton.js +1 -1
  13. package/lib/cjs/components/errors/Errors.d.ts +5 -0
  14. package/lib/cjs/components/errors/Errors.js +1 -0
  15. package/lib/cjs/components/gift_cards/GiftCard.js +1 -1
  16. package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -1
  17. package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -1
  18. package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -1
  19. package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -1
  20. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +1 -1
  21. package/lib/cjs/components/line_items/LineItem.js +1 -1
  22. package/lib/cjs/components/line_items/LineItemAmount.d.ts +1 -1
  23. package/lib/cjs/components/line_items/LineItemField.d.ts +3 -3
  24. package/lib/cjs/components/line_items/LineItemImage.d.ts +1 -1
  25. package/lib/cjs/components/line_items/LineItemOptions.d.ts +1 -1
  26. package/lib/cjs/components/line_items/LineItemQuantity.d.ts +1 -1
  27. package/lib/cjs/components/orders/AddToCartButton.d.ts +4 -4
  28. package/lib/cjs/components/orders/OrderList.d.ts +24 -7
  29. package/lib/cjs/components/orders/OrderList.js +1 -1
  30. package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +44 -0
  31. package/lib/cjs/components/orders/OrderListPaginationButtons.js +1 -0
  32. package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +29 -0
  33. package/lib/cjs/components/orders/OrderListPaginationInfo.js +1 -0
  34. package/lib/cjs/components/orders/OrderListRow.d.ts +3 -0
  35. package/lib/cjs/components/orders/OrderListRow.js +1 -1
  36. package/lib/cjs/components/orders/OrderNumber.d.ts +1 -1
  37. package/lib/cjs/components/parcels/ParcelField.d.ts +3 -3
  38. package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +3 -3
  39. package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -1
  40. package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -1
  41. package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -1
  42. package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -1
  43. package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +2 -2
  44. package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -1
  45. package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -1
  46. package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -1
  47. package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -1
  48. package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.d.ts +1 -1
  49. package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -1
  50. package/lib/cjs/components/payment_source/AdyenPayment.d.ts +2 -2
  51. package/lib/cjs/components/payment_source/BraintreePayment.d.ts +3 -3
  52. package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +2 -2
  53. package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +1 -1
  54. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +1 -1
  55. package/lib/cjs/components/payment_source/PaymentSourceEditButton.d.ts +1 -1
  56. package/lib/cjs/components/payment_source/PaypalPayment.d.ts +2 -2
  57. package/lib/cjs/components/payment_source/StripePayment.d.ts +2 -2
  58. package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +2 -2
  59. package/lib/cjs/components/shipments/ShipmentField.d.ts +2 -2
  60. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +1 -1
  61. package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -1
  62. package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +3 -3
  63. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +2 -2
  64. package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +3 -3
  65. package/lib/cjs/components/skus/SkuField.d.ts +3 -3
  66. package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +3 -3
  67. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +2 -2
  68. package/lib/cjs/components/utils/BaseField.d.ts +1 -1
  69. package/lib/cjs/components/utils/BaseInput.d.ts +2 -2
  70. package/lib/cjs/components/utils/BaseOrderPrice.d.ts +1 -1
  71. package/lib/cjs/components/utils/BaseSelect.d.ts +1 -1
  72. package/lib/cjs/components/utils/GenericFieldComponent.d.ts +3 -3
  73. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +4 -4
  74. package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -1
  75. package/lib/cjs/components/utils/getAllErrors.d.ts +1 -1
  76. package/lib/cjs/context/AddressContext.d.ts +1 -1
  77. package/lib/cjs/context/BillingAddressContext.d.ts +1 -1
  78. package/lib/cjs/context/BillingAddressFormContext.d.ts +1 -1
  79. package/lib/cjs/context/CouponAndGiftCardFormContext.d.ts +1 -1
  80. package/lib/cjs/context/CustomerAddressFormContext.d.ts +1 -1
  81. package/lib/cjs/context/CustomerContext.d.ts +1 -1
  82. package/lib/cjs/context/ExternalFunctionContext.d.ts +1 -1
  83. package/lib/cjs/context/LineItemChildrenContext.d.ts +1 -1
  84. package/lib/cjs/context/OrderListChildrenContext.d.ts +1 -1
  85. package/lib/cjs/context/OrderListPaginationContext.d.ts +19 -0
  86. package/lib/cjs/context/OrderListPaginationContext.js +1 -0
  87. package/lib/cjs/context/PaymentMethodContext.d.ts +1 -1
  88. package/lib/cjs/context/PaymentSourceContext.d.ts +2 -2
  89. package/lib/cjs/context/PlaceOrderContext.d.ts +1 -1
  90. package/lib/cjs/context/ShipmentContext.d.ts +1 -1
  91. package/lib/cjs/context/ShippingAddressContext.d.ts +1 -1
  92. package/lib/cjs/context/SkuChildrenContext.d.ts +1 -1
  93. package/lib/cjs/context/SkuContext.d.ts +1 -1
  94. package/lib/cjs/index.d.ts +1 -1
  95. package/lib/cjs/index.js +1 -1
  96. package/lib/cjs/reducers/AddressReducer.d.ts +10 -10
  97. package/lib/cjs/reducers/AvailabilityReducer.d.ts +4 -4
  98. package/lib/cjs/reducers/BillingAddressReducer.d.ts +4 -4
  99. package/lib/cjs/reducers/CustomerReducer.d.ts +6 -6
  100. package/lib/cjs/reducers/GiftCardReducer.d.ts +3 -3
  101. package/lib/cjs/reducers/GiftCardReducer.js +1 -1
  102. package/lib/cjs/reducers/LineItemReducer.d.ts +4 -4
  103. package/lib/cjs/reducers/OrderReducer.d.ts +19 -19
  104. package/lib/cjs/reducers/OrderReducer.js +1 -1
  105. package/lib/cjs/reducers/PaymentMethodReducer.d.ts +17 -17
  106. package/lib/cjs/reducers/PlaceOrderReducer.d.ts +5 -5
  107. package/lib/cjs/reducers/PriceReducer.d.ts +3 -3
  108. package/lib/cjs/reducers/ShipmentReducer.d.ts +6 -6
  109. package/lib/cjs/reducers/ShippingAddressReducer.d.ts +4 -4
  110. package/lib/cjs/reducers/SkuListsReducer.d.ts +3 -3
  111. package/lib/cjs/reducers/SkuReducer.d.ts +3 -3
  112. package/lib/cjs/typings/errors.d.ts +3 -3
  113. package/lib/cjs/typings/index.d.ts +24 -24
  114. package/lib/cjs/utils/PropsType.d.ts +4 -4
  115. package/lib/cjs/utils/addressesManager.d.ts +3 -3
  116. package/lib/cjs/utils/addressesManager.js +1 -1
  117. package/lib/cjs/utils/checkIncludeResource.d.ts +1 -1
  118. package/lib/cjs/utils/compareObjAttribute.d.ts +2 -2
  119. package/lib/cjs/utils/customMessages.d.ts +1 -1
  120. package/lib/cjs/utils/filterChildren.d.ts +8 -0
  121. package/lib/cjs/utils/filterChildren.js +1 -0
  122. package/lib/cjs/utils/getCardDetails.d.ts +2 -2
  123. package/lib/cjs/utils/getCartLink.d.ts +1 -1
  124. package/lib/cjs/utils/getErrors.d.ts +1 -1
  125. package/lib/cjs/utils/getLineItemsCount.d.ts +1 -1
  126. package/lib/cjs/utils/hooks/useCustomContext.js +1 -1
  127. package/lib/cjs/utils/jwt.d.ts +1 -1
  128. package/lib/cjs/utils/localStorage.d.ts +1 -1
  129. package/lib/cjs/utils/omit.d.ts +1 -0
  130. package/lib/cjs/utils/omit.js +1 -0
  131. package/lib/cjs/utils/validateFormFields.d.ts +6 -12
  132. package/lib/cjs/utils/validateFormFields.js +1 -1
  133. package/lib/esm/components/MetadataInput.d.ts +1 -1
  134. package/lib/esm/components/addresses/AddressCountrySelector.d.ts +1 -1
  135. package/lib/esm/components/addresses/AddressField.d.ts +2 -2
  136. package/lib/esm/components/addresses/AddressInput.d.ts +2 -2
  137. package/lib/esm/components/addresses/AddressInput.js +1 -1
  138. package/lib/esm/components/addresses/AddressStateSelector.d.ts +1 -1
  139. package/lib/esm/components/addresses/BillingAddressContainer.d.ts +1 -1
  140. package/lib/esm/components/addresses/BillingAddressForm.d.ts +1 -1
  141. package/lib/esm/components/addresses/ShippingAddressForm.js +1 -1
  142. package/lib/esm/components/customers/CustomerField.d.ts +3 -3
  143. package/lib/esm/components/customers/CustomerInput.d.ts +1 -1
  144. package/lib/esm/components/customers/SaveCustomerButton.js +1 -1
  145. package/lib/esm/components/errors/Errors.d.ts +5 -0
  146. package/lib/esm/components/errors/Errors.js +1 -0
  147. package/lib/esm/components/gift_cards/GiftCard.js +1 -1
  148. package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -1
  149. package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -1
  150. package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -1
  151. package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -1
  152. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +1 -1
  153. package/lib/esm/components/line_items/LineItem.js +1 -1
  154. package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -1
  155. package/lib/esm/components/line_items/LineItemField.d.ts +3 -3
  156. package/lib/esm/components/line_items/LineItemImage.d.ts +1 -1
  157. package/lib/esm/components/line_items/LineItemOptions.d.ts +1 -1
  158. package/lib/esm/components/line_items/LineItemQuantity.d.ts +1 -1
  159. package/lib/esm/components/orders/AddToCartButton.d.ts +4 -4
  160. package/lib/esm/components/orders/OrderList.d.ts +24 -7
  161. package/lib/esm/components/orders/OrderList.js +1 -1
  162. package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +44 -0
  163. package/lib/esm/components/orders/OrderListPaginationButtons.js +1 -0
  164. package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +29 -0
  165. package/lib/esm/components/orders/OrderListPaginationInfo.js +1 -0
  166. package/lib/esm/components/orders/OrderListRow.d.ts +3 -0
  167. package/lib/esm/components/orders/OrderListRow.js +1 -1
  168. package/lib/esm/components/orders/OrderNumber.d.ts +1 -1
  169. package/lib/esm/components/parcels/ParcelField.d.ts +3 -3
  170. package/lib/esm/components/parcels/ParcelLineItemField.d.ts +3 -3
  171. package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -1
  172. package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -1
  173. package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -1
  174. package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -1
  175. package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +2 -2
  176. package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -1
  177. package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -1
  178. package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -1
  179. package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -1
  180. package/lib/esm/components/payment_methods/PaymentMethodRadioButton.d.ts +1 -1
  181. package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -1
  182. package/lib/esm/components/payment_source/AdyenPayment.d.ts +2 -2
  183. package/lib/esm/components/payment_source/BraintreePayment.d.ts +3 -3
  184. package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +2 -2
  185. package/lib/esm/components/payment_source/KlarnaPayment.d.ts +1 -1
  186. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +1 -1
  187. package/lib/esm/components/payment_source/PaymentSourceEditButton.d.ts +1 -1
  188. package/lib/esm/components/payment_source/PaypalPayment.d.ts +2 -2
  189. package/lib/esm/components/payment_source/StripePayment.d.ts +2 -2
  190. package/lib/esm/components/payment_source/WireTransferPayment.d.ts +2 -2
  191. package/lib/esm/components/shipments/ShipmentField.d.ts +2 -2
  192. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +1 -1
  193. package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -1
  194. package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +3 -3
  195. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +2 -2
  196. package/lib/esm/components/skus/DeliveryLeadTime.d.ts +3 -3
  197. package/lib/esm/components/skus/SkuField.d.ts +3 -3
  198. package/lib/esm/components/stock_transfers/StockTransferField.d.ts +3 -3
  199. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +2 -2
  200. package/lib/esm/components/utils/BaseField.d.ts +1 -1
  201. package/lib/esm/components/utils/BaseInput.d.ts +2 -2
  202. package/lib/esm/components/utils/BaseOrderPrice.d.ts +1 -1
  203. package/lib/esm/components/utils/BaseSelect.d.ts +1 -1
  204. package/lib/esm/components/utils/GenericFieldComponent.d.ts +3 -3
  205. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +4 -4
  206. package/lib/esm/components/utils/PriceTemplate.d.ts +1 -1
  207. package/lib/esm/components/utils/getAllErrors.d.ts +1 -1
  208. package/lib/esm/context/AddressContext.d.ts +1 -1
  209. package/lib/esm/context/BillingAddressContext.d.ts +1 -1
  210. package/lib/esm/context/BillingAddressFormContext.d.ts +1 -1
  211. package/lib/esm/context/CouponAndGiftCardFormContext.d.ts +1 -1
  212. package/lib/esm/context/CustomerAddressFormContext.d.ts +1 -1
  213. package/lib/esm/context/CustomerContext.d.ts +1 -1
  214. package/lib/esm/context/ExternalFunctionContext.d.ts +1 -1
  215. package/lib/esm/context/LineItemChildrenContext.d.ts +1 -1
  216. package/lib/esm/context/OrderListChildrenContext.d.ts +1 -1
  217. package/lib/esm/context/OrderListPaginationContext.d.ts +19 -0
  218. package/lib/esm/context/OrderListPaginationContext.js +1 -0
  219. package/lib/esm/context/PaymentMethodContext.d.ts +1 -1
  220. package/lib/esm/context/PaymentSourceContext.d.ts +2 -2
  221. package/lib/esm/context/PlaceOrderContext.d.ts +1 -1
  222. package/lib/esm/context/ShipmentContext.d.ts +1 -1
  223. package/lib/esm/context/ShippingAddressContext.d.ts +1 -1
  224. package/lib/esm/context/SkuChildrenContext.d.ts +1 -1
  225. package/lib/esm/context/SkuContext.d.ts +1 -1
  226. package/lib/esm/index.d.ts +1 -1
  227. package/lib/esm/index.js +1 -1
  228. package/lib/esm/reducers/AddressReducer.d.ts +10 -10
  229. package/lib/esm/reducers/AvailabilityReducer.d.ts +4 -4
  230. package/lib/esm/reducers/BillingAddressReducer.d.ts +4 -4
  231. package/lib/esm/reducers/CustomerReducer.d.ts +6 -6
  232. package/lib/esm/reducers/GiftCardReducer.d.ts +3 -3
  233. package/lib/esm/reducers/GiftCardReducer.js +1 -1
  234. package/lib/esm/reducers/LineItemReducer.d.ts +4 -4
  235. package/lib/esm/reducers/OrderReducer.d.ts +19 -19
  236. package/lib/esm/reducers/OrderReducer.js +1 -1
  237. package/lib/esm/reducers/PaymentMethodReducer.d.ts +17 -17
  238. package/lib/esm/reducers/PlaceOrderReducer.d.ts +5 -5
  239. package/lib/esm/reducers/PriceReducer.d.ts +3 -3
  240. package/lib/esm/reducers/ShipmentReducer.d.ts +6 -6
  241. package/lib/esm/reducers/ShippingAddressReducer.d.ts +4 -4
  242. package/lib/esm/reducers/SkuListsReducer.d.ts +3 -3
  243. package/lib/esm/reducers/SkuReducer.d.ts +3 -3
  244. package/lib/esm/typings/errors.d.ts +3 -3
  245. package/lib/esm/typings/index.d.ts +24 -24
  246. package/lib/esm/utils/PropsType.d.ts +4 -4
  247. package/lib/esm/utils/addressesManager.d.ts +3 -3
  248. package/lib/esm/utils/addressesManager.js +1 -1
  249. package/lib/esm/utils/checkIncludeResource.d.ts +1 -1
  250. package/lib/esm/utils/compareObjAttribute.d.ts +2 -2
  251. package/lib/esm/utils/filterChildren.d.ts +8 -0
  252. package/lib/esm/utils/filterChildren.js +1 -0
  253. package/lib/esm/utils/getCardDetails.d.ts +2 -2
  254. package/lib/esm/utils/getCartLink.d.ts +1 -1
  255. package/lib/esm/utils/getErrors.d.ts +1 -1
  256. package/lib/esm/utils/getLineItemsCount.d.ts +1 -1
  257. package/lib/esm/utils/hooks/useCustomContext.js +1 -1
  258. package/lib/esm/utils/jwt.d.ts +1 -1
  259. package/lib/esm/utils/localStorage.d.ts +1 -1
  260. package/lib/esm/utils/omit.d.ts +1 -0
  261. package/lib/esm/utils/omit.js +1 -0
  262. package/lib/esm/utils/validateFormFields.d.ts +6 -12
  263. package/lib/esm/utils/validateFormFields.js +1 -1
  264. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  265. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  266. package/package.json +24 -17
  267. package/lib/cjs/components/Errors.d.ts +0 -5
  268. package/lib/cjs/components/Errors.js +0 -1
  269. package/lib/esm/components/Errors.d.ts +0 -5
  270. package/lib/esm/components/Errors.js +0 -1
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { SkuState } from '../reducers/SkuReducer';
3
- export declare type SkuContextValue = SkuState;
3
+ export type SkuContextValue = SkuState;
4
4
  declare const SkuContext: import("react").Context<Partial<{
5
5
  skus: import("@commercelayer/sdk/lib/cjs/resources/skus").Sku[];
6
6
  loading: boolean;
@@ -1,4 +1,4 @@
1
- export * from './components/Errors';
1
+ export * from './components/errors/Errors';
2
2
  export * from './components/ExternalFunction';
3
3
  export * from './components/MetadataInput';
4
4
  export * from './components/SubmitButton';
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");tslib_1.__exportStar(require("./components/Errors"),exports),tslib_1.__exportStar(require("./components/ExternalFunction"),exports),tslib_1.__exportStar(require("./components/MetadataInput"),exports),tslib_1.__exportStar(require("./components/SubmitButton"),exports),tslib_1.__exportStar(require("./components/addresses/Address"),exports),tslib_1.__exportStar(require("./components/addresses/AddressCountrySelector"),exports),tslib_1.__exportStar(require("./components/addresses/AddressField"),exports),tslib_1.__exportStar(require("./components/addresses/AddressInput"),exports),tslib_1.__exportStar(require("./components/addresses/AddressStateSelector"),exports),tslib_1.__exportStar(require("./components/addresses/AddressesContainer"),exports),tslib_1.__exportStar(require("./components/addresses/AddressesEmpty"),exports),tslib_1.__exportStar(require("./components/addresses/BillingAddressContainer"),exports),tslib_1.__exportStar(require("./components/addresses/BillingAddressForm"),exports),tslib_1.__exportStar(require("./components/addresses/SaveAddressesButton"),exports),tslib_1.__exportStar(require("./components/addresses/ShippingAddressContainer"),exports),tslib_1.__exportStar(require("./components/addresses/ShippingAddressForm"),exports),tslib_1.__exportStar(require("./components/auth/CommerceLayer"),exports),tslib_1.__exportStar(require("./components/customers/CustomerAddressForm"),exports),tslib_1.__exportStar(require("./components/customers/CustomerContainer"),exports),tslib_1.__exportStar(require("./components/customers/CustomerField"),exports),tslib_1.__exportStar(require("./components/customers/CustomerInput"),exports),tslib_1.__exportStar(require("./components/customers/SaveCustomerButton"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCard"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardContainer"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardCurrencySelector"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardInput"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponCode"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponForm"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponInput"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponRemoveButton"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponSubmit"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemsContainer"),exports),tslib_1.__exportStar(require("./components/line_items/LineItem"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemAmount"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemCode"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemField"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemImage"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemName"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemOption"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemOptions"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemQuantity"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemRemoveLink"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemsCount"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemsEmpty"),exports),tslib_1.__exportStar(require("./components/orders/AddToCartButton"),exports),tslib_1.__exportStar(require("./components/orders/AdjustmentAmount"),exports),tslib_1.__exportStar(require("./components/orders/CartLink"),exports),tslib_1.__exportStar(require("./components/orders/CheckoutLink"),exports),tslib_1.__exportStar(require("./components/orders/DiscountAmount"),exports),tslib_1.__exportStar(require("./components/orders/GiftCardAmount"),exports),tslib_1.__exportStar(require("./components/orders/OrderContainer"),exports),tslib_1.__exportStar(require("./components/orders/OrderList"),exports),tslib_1.__exportStar(require("./components/orders/OrderListEmpty"),exports),tslib_1.__exportStar(require("./components/orders/OrderListRow"),exports),tslib_1.__exportStar(require("./components/orders/OrderNumber"),exports),tslib_1.__exportStar(require("./components/orders/OrderStorage"),exports),tslib_1.__exportStar(require("./components/orders/PaymentMethodAmount"),exports),tslib_1.__exportStar(require("./components/orders/PlaceOrderButton"),exports),tslib_1.__exportStar(require("./components/orders/PlaceOrderContainer"),exports),tslib_1.__exportStar(require("./components/orders/PrivacyAndTermsCheckbox"),exports),tslib_1.__exportStar(require("./components/orders/ShippingAmount"),exports),tslib_1.__exportStar(require("./components/orders/SubTotalAmount"),exports),tslib_1.__exportStar(require("./components/orders/TaxesAmount"),exports),tslib_1.__exportStar(require("./components/orders/TotalAmount"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelField"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelLineItem"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelLineItemField"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelLineItemsCount"),exports),tslib_1.__exportStar(require("./components/parcels/Parcels"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelsCount"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethod"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodName"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodPrice"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodRadioButton"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodsContainer"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSource"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSourceBrandIcon"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSourceBrandName"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSourceDetail"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSourceEditButton"),exports),tslib_1.__exportStar(require("./components/prices/Price"),exports),tslib_1.__exportStar(require("./components/prices/PricesContainer"),exports),tslib_1.__exportStar(require("./components/shipments/Shipment"),exports),tslib_1.__exportStar(require("./components/shipments/ShipmentField"),exports),tslib_1.__exportStar(require("./components/shipments/ShipmentsContainer"),exports),tslib_1.__exportStar(require("./components/shipments/ShipmentsCount"),exports),tslib_1.__exportStar(require("./components/shipping_methods/ShippingMethod"),exports),tslib_1.__exportStar(require("./components/shipping_methods/ShippingMethodName"),exports),tslib_1.__exportStar(require("./components/shipping_methods/ShippingMethodPrice"),exports),tslib_1.__exportStar(require("./components/shipping_methods/ShippingMethodRadioButton"),exports),tslib_1.__exportStar(require("./components/skus/AvailabilityContainer"),exports),tslib_1.__exportStar(require("./components/skus/AvailabilityTemplate"),exports),tslib_1.__exportStar(require("./components/skus/DeliveryLeadTime"),exports),tslib_1.__exportStar(require("./components/skus/SkuField"),exports),tslib_1.__exportStar(require("./components/skus/SkuList"),exports),tslib_1.__exportStar(require("./components/skus/SkuListsContainer"),exports),tslib_1.__exportStar(require("./components/skus/Skus"),exports),tslib_1.__exportStar(require("./components/skus/SkusContainer"),exports),tslib_1.__exportStar(require("./components/stock_transfers/StockTransfer"),exports),tslib_1.__exportStar(require("./components/stock_transfers/StockTransferField"),exports);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");tslib_1.__exportStar(require("./components/errors/Errors"),exports),tslib_1.__exportStar(require("./components/ExternalFunction"),exports),tslib_1.__exportStar(require("./components/MetadataInput"),exports),tslib_1.__exportStar(require("./components/SubmitButton"),exports),tslib_1.__exportStar(require("./components/addresses/Address"),exports),tslib_1.__exportStar(require("./components/addresses/AddressCountrySelector"),exports),tslib_1.__exportStar(require("./components/addresses/AddressField"),exports),tslib_1.__exportStar(require("./components/addresses/AddressInput"),exports),tslib_1.__exportStar(require("./components/addresses/AddressStateSelector"),exports),tslib_1.__exportStar(require("./components/addresses/AddressesContainer"),exports),tslib_1.__exportStar(require("./components/addresses/AddressesEmpty"),exports),tslib_1.__exportStar(require("./components/addresses/BillingAddressContainer"),exports),tslib_1.__exportStar(require("./components/addresses/BillingAddressForm"),exports),tslib_1.__exportStar(require("./components/addresses/SaveAddressesButton"),exports),tslib_1.__exportStar(require("./components/addresses/ShippingAddressContainer"),exports),tslib_1.__exportStar(require("./components/addresses/ShippingAddressForm"),exports),tslib_1.__exportStar(require("./components/auth/CommerceLayer"),exports),tslib_1.__exportStar(require("./components/customers/CustomerAddressForm"),exports),tslib_1.__exportStar(require("./components/customers/CustomerContainer"),exports),tslib_1.__exportStar(require("./components/customers/CustomerField"),exports),tslib_1.__exportStar(require("./components/customers/CustomerInput"),exports),tslib_1.__exportStar(require("./components/customers/SaveCustomerButton"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCard"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardContainer"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardCurrencySelector"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardInput"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponCode"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponForm"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponInput"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponRemoveButton"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCardOrCouponSubmit"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemsContainer"),exports),tslib_1.__exportStar(require("./components/line_items/LineItem"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemAmount"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemCode"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemField"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemImage"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemName"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemOption"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemOptions"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemQuantity"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemRemoveLink"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemsCount"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemsEmpty"),exports),tslib_1.__exportStar(require("./components/orders/AddToCartButton"),exports),tslib_1.__exportStar(require("./components/orders/AdjustmentAmount"),exports),tslib_1.__exportStar(require("./components/orders/CartLink"),exports),tslib_1.__exportStar(require("./components/orders/CheckoutLink"),exports),tslib_1.__exportStar(require("./components/orders/DiscountAmount"),exports),tslib_1.__exportStar(require("./components/orders/GiftCardAmount"),exports),tslib_1.__exportStar(require("./components/orders/OrderContainer"),exports),tslib_1.__exportStar(require("./components/orders/OrderList"),exports),tslib_1.__exportStar(require("./components/orders/OrderListEmpty"),exports),tslib_1.__exportStar(require("./components/orders/OrderListRow"),exports),tslib_1.__exportStar(require("./components/orders/OrderNumber"),exports),tslib_1.__exportStar(require("./components/orders/OrderStorage"),exports),tslib_1.__exportStar(require("./components/orders/PaymentMethodAmount"),exports),tslib_1.__exportStar(require("./components/orders/PlaceOrderButton"),exports),tslib_1.__exportStar(require("./components/orders/PlaceOrderContainer"),exports),tslib_1.__exportStar(require("./components/orders/PrivacyAndTermsCheckbox"),exports),tslib_1.__exportStar(require("./components/orders/ShippingAmount"),exports),tslib_1.__exportStar(require("./components/orders/SubTotalAmount"),exports),tslib_1.__exportStar(require("./components/orders/TaxesAmount"),exports),tslib_1.__exportStar(require("./components/orders/TotalAmount"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelField"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelLineItem"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelLineItemField"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelLineItemsCount"),exports),tslib_1.__exportStar(require("./components/parcels/Parcels"),exports),tslib_1.__exportStar(require("./components/parcels/ParcelsCount"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethod"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodName"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodPrice"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodRadioButton"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodsContainer"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSource"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSourceBrandIcon"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSourceBrandName"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSourceDetail"),exports),tslib_1.__exportStar(require("./components/payment_source/PaymentSourceEditButton"),exports),tslib_1.__exportStar(require("./components/prices/Price"),exports),tslib_1.__exportStar(require("./components/prices/PricesContainer"),exports),tslib_1.__exportStar(require("./components/shipments/Shipment"),exports),tslib_1.__exportStar(require("./components/shipments/ShipmentField"),exports),tslib_1.__exportStar(require("./components/shipments/ShipmentsContainer"),exports),tslib_1.__exportStar(require("./components/shipments/ShipmentsCount"),exports),tslib_1.__exportStar(require("./components/shipping_methods/ShippingMethod"),exports),tslib_1.__exportStar(require("./components/shipping_methods/ShippingMethodName"),exports),tslib_1.__exportStar(require("./components/shipping_methods/ShippingMethodPrice"),exports),tslib_1.__exportStar(require("./components/shipping_methods/ShippingMethodRadioButton"),exports),tslib_1.__exportStar(require("./components/skus/AvailabilityContainer"),exports),tslib_1.__exportStar(require("./components/skus/AvailabilityTemplate"),exports),tslib_1.__exportStar(require("./components/skus/DeliveryLeadTime"),exports),tslib_1.__exportStar(require("./components/skus/SkuField"),exports),tslib_1.__exportStar(require("./components/skus/SkuList"),exports),tslib_1.__exportStar(require("./components/skus/SkuListsContainer"),exports),tslib_1.__exportStar(require("./components/skus/Skus"),exports),tslib_1.__exportStar(require("./components/skus/SkusContainer"),exports),tslib_1.__exportStar(require("./components/stock_transfers/StockTransfer"),exports),tslib_1.__exportStar(require("./components/stock_transfers/StockTransferField"),exports);
@@ -4,12 +4,12 @@ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
4
4
  import type { Address, AddressCreate, Order } from '@commercelayer/sdk';
5
5
  import { updateOrder } from './OrderReducer';
6
6
  import { TCustomerAddress } from './CustomerReducer';
7
- export declare type AddressActionType = 'setErrors' | 'setAddress' | 'setShipToDifferentAddress' | 'setCloneAddress' | 'cleanup';
8
- export declare type AddressField = 'city' | 'company' | 'country_code' | 'first_name' | 'last_name' | 'line_1' | 'line_2' | 'phone' | 'state_code' | 'zip_code' | 'billing_info';
9
- export declare type AddressFieldView = AddressField | 'full_address' | 'full_name';
7
+ export type AddressActionType = 'setErrors' | 'setAddress' | 'setShipToDifferentAddress' | 'setCloneAddress' | 'cleanup';
8
+ export type AddressField = 'city' | 'company' | 'country_code' | 'first_name' | 'last_name' | 'line_1' | 'line_2' | 'phone' | 'state_code' | 'zip_code' | 'billing_info';
9
+ export type AddressFieldView = AddressField | 'full_address' | 'full_name';
10
10
  export declare const addressFields: AddressField[];
11
- export declare type AddressResource = Extract<ResourceErrorType, 'billing_address' | 'shipping_address'>;
12
- export declare type AddressSchema = Omit<Address, 'created_at' | 'updated_at' | 'id' | 'type'>;
11
+ export type AddressResource = Extract<ResourceErrorType, 'billing_address' | 'shipping_address'>;
12
+ export type AddressSchema = Omit<Address, 'created_at' | 'updated_at' | 'id' | 'type'>;
13
13
  export interface AddressActionPayload {
14
14
  errors: BaseError[];
15
15
  billing_address: TCustomerAddress;
@@ -19,13 +19,13 @@ export interface AddressActionPayload {
19
19
  shippingAddressId: string;
20
20
  isBusiness: boolean;
21
21
  }
22
- export declare type AddressState = Partial<AddressActionPayload>;
22
+ export type AddressState = Partial<AddressActionPayload>;
23
23
  export interface AddressAction {
24
24
  type: AddressActionType;
25
25
  payload: Partial<AddressActionPayload>;
26
26
  }
27
27
  export declare const addressInitialState: AddressState;
28
- export declare type SetAddressErrors = <V extends BaseError[]>(args: {
28
+ export type SetAddressErrors = <V extends BaseError[]>(args: {
29
29
  errors: V;
30
30
  resource: Extract<ResourceErrorType, 'billing_address' | 'shipping_address'>;
31
31
  dispatch?: Dispatch<AddressAction>;
@@ -36,8 +36,8 @@ export interface SetAddressParams<V extends AddressSchema> {
36
36
  resource: AddressResource;
37
37
  dispatch?: Dispatch<AddressAction>;
38
38
  }
39
- export declare type SetAddress = <V extends AddressSchema>(params: SetAddressParams<V>) => void;
40
- export declare type SaveAddresses = (params: {
39
+ export type SetAddress = <V extends AddressSchema>(params: SetAddressParams<V>) => void;
40
+ export type SaveAddresses = (params: {
41
41
  orderId?: string;
42
42
  order?: Order | null;
43
43
  updateOrder?: typeof updateOrder;
@@ -48,7 +48,7 @@ export declare type SaveAddresses = (params: {
48
48
  }) => Promise<void>;
49
49
  export declare const setAddressErrors: SetAddressErrors;
50
50
  export declare const setAddress: SetAddress;
51
- declare type SetCloneAddress = (id: string, resource: AddressResource, dispatch: Dispatch<AddressAction>) => void;
51
+ type SetCloneAddress = (id: string, resource: AddressResource, dispatch: Dispatch<AddressAction>) => void;
52
52
  export declare const setCloneAddress: SetCloneAddress;
53
53
  export declare const saveAddresses: SaveAddresses;
54
54
  declare const addressReducer: (state: AddressState, reducer: AddressAction) => AddressState;
@@ -25,17 +25,17 @@ interface Inventory {
25
25
  levels: Level[];
26
26
  };
27
27
  }
28
- export declare type SkuInventory = Sku & Inventory;
28
+ export type SkuInventory = Sku & Inventory;
29
29
  export interface LeadTimes {
30
30
  hours: number;
31
31
  days: number;
32
32
  }
33
- export declare type AvailabilityPayload = {
33
+ export type AvailabilityPayload = {
34
34
  quantity?: number;
35
35
  errors?: BaseError[];
36
36
  parent?: boolean;
37
37
  } & Partial<DeliveryLeadTime>;
38
- export declare type AvailabilityState = AvailabilityPayload;
38
+ export type AvailabilityState = AvailabilityPayload;
39
39
  export interface AvailabilityAction {
40
40
  type: AvailabilityActionType;
41
41
  payload: AvailabilityPayload;
@@ -46,6 +46,6 @@ export declare function getAvailability({ skuCode, dispatch, config }: {
46
46
  dispatch: Dispatch<AvailabilityAction>;
47
47
  config: CommerceLayerConfig;
48
48
  }): Promise<void>;
49
- export declare type AvailabilityActionType = 'setAvailability' | 'setErrors';
49
+ export type AvailabilityActionType = 'setAvailability' | 'setErrors';
50
50
  declare const availabilityReducer: (state: AvailabilityState, reducer: AvailabilityAction) => AvailabilityState;
51
51
  export default availabilityReducer;
@@ -2,18 +2,18 @@ import { Dispatch } from 'react';
2
2
  import { CommerceLayerConfig } from '../context/CommerceLayerContext';
3
3
  import { Order } from '@commercelayer/sdk';
4
4
  import { AddressResource } from './AddressReducer';
5
- export declare type BillingAddressActionType = 'setBillingAddress' | 'setBillingCustomerAddressId' | 'cleanup';
5
+ export type BillingAddressActionType = 'setBillingAddress' | 'setBillingCustomerAddressId' | 'cleanup';
6
6
  export interface BillingAddressActionPayload {
7
7
  _billing_address_clone_id: string;
8
8
  billingCustomerAddressId: string;
9
9
  }
10
- export declare type BillingAddressState = Partial<BillingAddressActionPayload>;
10
+ export type BillingAddressState = Partial<BillingAddressActionPayload>;
11
11
  export interface BillingAddressAction {
12
12
  type: BillingAddressActionType;
13
13
  payload: Partial<BillingAddressActionPayload>;
14
14
  }
15
15
  export declare const billingAddressInitialState: BillingAddressState;
16
- export declare type SetBillingAddress = (id: string, options?: {
16
+ export type SetBillingAddress = (id: string, options?: {
17
17
  config: CommerceLayerConfig;
18
18
  dispatch: Dispatch<BillingAddressAction>;
19
19
  order?: Order;
@@ -21,7 +21,7 @@ export declare type SetBillingAddress = (id: string, options?: {
21
21
  customerAddressId?: string;
22
22
  }) => Promise<void>;
23
23
  export declare const setBillingAddress: SetBillingAddress;
24
- declare type SetBillingCustomerAddressId = (args: {
24
+ type SetBillingCustomerAddressId = (args: {
25
25
  dispatch: Dispatch<BillingAddressAction>;
26
26
  order: Order;
27
27
  setCloneAddress: (id: string, resource: AddressResource) => void;
@@ -3,7 +3,7 @@ import { BaseError } from '../typings/errors';
3
3
  import type { Address, AddressCreate, AddressUpdate, Customer, CustomerPaymentSource, Order } from '@commercelayer/sdk';
4
4
  import { CommerceLayerConfig } from '../context/CommerceLayerContext';
5
5
  import { updateOrder } from './OrderReducer';
6
- export declare type CustomerActionType = 'setErrors' | 'setCustomerEmail' | 'setAddresses' | 'setPayments' | 'setOrders';
6
+ export type CustomerActionType = 'setErrors' | 'setCustomerEmail' | 'setAddresses' | 'setPayments' | 'setOrders';
7
7
  export interface CustomerActionPayload {
8
8
  addresses: Address[] | null;
9
9
  payments: CustomerPaymentSource[];
@@ -13,12 +13,12 @@ export interface CustomerActionPayload {
13
13
  isGuest: boolean;
14
14
  customers: Customer;
15
15
  }
16
- export declare type CustomerState = Partial<CustomerActionPayload>;
16
+ export type CustomerState = Partial<CustomerActionPayload>;
17
17
  export interface CustomerAction {
18
18
  type: CustomerActionType;
19
19
  payload: Partial<CustomerActionPayload>;
20
20
  }
21
- export declare type SetSaveOnBlur = (args: {
21
+ export type SetSaveOnBlur = (args: {
22
22
  saveOnBlur: boolean;
23
23
  dispatch: Dispatch<CustomerAction>;
24
24
  }) => void;
@@ -45,7 +45,7 @@ export interface SaveCustomerUser {
45
45
  updateOrder: typeof updateOrder;
46
46
  }
47
47
  export declare function saveCustomerUser({ customerEmail, order, updateOrder }: SaveCustomerUser): Promise<void>;
48
- export declare type SetCustomerErrors = <V extends BaseError[]>(errors: V, dispatch?: Dispatch<CustomerAction>) => void;
48
+ export type SetCustomerErrors = <V extends BaseError[]>(errors: V, dispatch?: Dispatch<CustomerAction>) => void;
49
49
  export declare function setCustomerErrors(
50
50
  /**
51
51
  * @param errors - An array of errors
@@ -93,7 +93,7 @@ export interface GetCustomerPaymentSources {
93
93
  order?: Order;
94
94
  }
95
95
  export declare function getCustomerPaymentSources(params?: GetCustomerPaymentSources): void;
96
- export declare type GetCustomerOrders = (params: {
96
+ export type GetCustomerOrders = (params: {
97
97
  /**
98
98
  * The Commerce Layer config
99
99
  */
@@ -104,7 +104,7 @@ export declare type GetCustomerOrders = (params: {
104
104
  dispatch: Dispatch<CustomerAction>;
105
105
  }) => Promise<void>;
106
106
  export declare const getCustomerOrders: GetCustomerOrders;
107
- export declare type TCustomerAddress = AddressCreate & AddressUpdate;
107
+ export type TCustomerAddress = AddressCreate & AddressUpdate;
108
108
  interface TCreateCustomerAddress {
109
109
  /**
110
110
  * Customer address dispatch function
@@ -4,7 +4,7 @@ import { Dispatch } from 'react';
4
4
  import { CommerceLayerConfig } from '../context/CommerceLayerContext';
5
5
  import { BaseError } from '../typings/errors';
6
6
  import { CreateOrder, getOrderContext } from './OrderReducer';
7
- export declare type GiftCardActionType = 'setAvailability' | 'setGiftCardRecipient' | 'setGiftCardErrors' | 'setGiftCardLoading';
7
+ export type GiftCardActionType = 'setAvailability' | 'setGiftCardRecipient' | 'setGiftCardErrors' | 'setGiftCardLoading';
8
8
  export interface GiftCardRecipientI {
9
9
  email: string;
10
10
  firstName?: string;
@@ -50,8 +50,8 @@ export interface GiftCardAction {
50
50
  payload: GiftCardActionPayload;
51
51
  }
52
52
  export declare const giftCardInitialState: GiftCardState;
53
- export declare type AddGiftCardError = <V extends BaseError[]>(errors: V, dispatch: Dispatch<GiftCardAction>) => void;
54
- export declare type AddGiftCardLoading = <V extends boolean>(loading: V, dispatch: Dispatch<GiftCardAction>) => void;
53
+ export type AddGiftCardError = <V extends BaseError[]>(errors: V, dispatch: Dispatch<GiftCardAction>) => void;
54
+ export type AddGiftCardLoading = <V extends boolean>(loading: V, dispatch: Dispatch<GiftCardAction>) => void;
55
55
  export declare function addGiftCardRecipient<V extends GiftCardRecipientCreate>(values: V, config: CommerceLayerConfig, dispatch: Dispatch<GiftCardAction>): Promise<void>;
56
56
  export declare const addGiftCardLoading: AddGiftCardLoading;
57
57
  export declare function addGiftCard<V extends GiftCardI>(values: V, { config, dispatch, getOrder, createOrder, order }: {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addGiftCardError=exports.addGiftCard=exports.addGiftCardLoading=exports.addGiftCardRecipient=exports.giftCardInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),lodash_1=require("lodash"),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:!1,rechargeable:!0,loading:!1,expiresAt:null,errors:[]};async function addGiftCardRecipient(values,config,dispatch){try{const recipient=await(0,getSdk_1.default)(config).gift_card_recipients.create(values);dispatch({type:"setGiftCardRecipient",payload:{giftCardRecipient:recipient}})}catch(error){console.error(error)}}exports.addGiftCardRecipient=addGiftCardRecipient;const addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})};exports.addGiftCardLoading=addGiftCardLoading;async function addGiftCard(values,{config,dispatch,getOrder,createOrder,order}){try{const sdk=(0,getSdk_1.default)(config);(0,exports.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),(0,lodash_1.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}}),(0,exports.addGiftCardLoading)(!1,dispatch)}catch(error){const errors=(0,getErrors_1.default)(error,"gift_cards");dispatch({type:"setGiftCardErrors",payload:{errors}}),(0,exports.addGiftCardLoading)(!1,dispatch)}}exports.addGiftCard=addGiftCard;const addGiftCardError=(errors,dispatch)=>{dispatch({type:"setGiftCardErrors",payload:{errors}})};exports.addGiftCardError=addGiftCardError;const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"],giftCardReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=giftCardReducer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addGiftCardError=exports.addGiftCard=exports.addGiftCardLoading=exports.addGiftCardRecipient=exports.giftCardInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:!1,rechargeable:!0,loading:!1,expiresAt:null,errors:[]};async function addGiftCardRecipient(values,config,dispatch){try{const recipient=await(0,getSdk_1.default)(config).gift_card_recipients.create(values);dispatch({type:"setGiftCardRecipient",payload:{giftCardRecipient:recipient}})}catch(error){console.error(error)}}exports.addGiftCardRecipient=addGiftCardRecipient;const addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})};exports.addGiftCardLoading=addGiftCardLoading;async function addGiftCard(values,{config,dispatch,getOrder,createOrder,order}){try{const sdk=(0,getSdk_1.default)(config);(0,exports.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),(0,isEmpty_1.default)(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}}),(0,exports.addGiftCardLoading)(!1,dispatch)}catch(error){const errors=(0,getErrors_1.default)(error,"gift_cards");dispatch({type:"setGiftCardErrors",payload:{errors}}),(0,exports.addGiftCardLoading)(!1,dispatch)}}exports.addGiftCard=addGiftCard;const addGiftCardError=(errors,dispatch)=>{dispatch({type:"setGiftCardErrors",payload:{errors}})};exports.addGiftCardError=addGiftCardError;const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"],giftCardReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=giftCardReducer;
@@ -4,7 +4,7 @@ import { getOrderContext } from './OrderReducer';
4
4
  import { LoaderType } from '../typings/index';
5
5
  import { BaseError } from '../typings/errors';
6
6
  import { Order, LineItem } from '@commercelayer/sdk';
7
- export declare type UpdateLineItemParams = {
7
+ export type UpdateLineItemParams = {
8
8
  lineItemId: string;
9
9
  quantity?: number;
10
10
  dispatch: Dispatch<LineItemAction>;
@@ -16,11 +16,11 @@ export declare type UpdateLineItemParams = {
16
16
  export interface UpdateLineItem {
17
17
  (params: UpdateLineItemParams): void;
18
18
  }
19
- export declare type DeleteLineItemParam = Record<string, any> & UpdateLineItemParams;
19
+ export type DeleteLineItemParam = Record<string, any> & UpdateLineItemParams;
20
20
  export interface DeleteLineItem {
21
21
  (params: DeleteLineItemParam): void;
22
22
  }
23
- export declare type GetLineItemsParams = {
23
+ export type GetLineItemsParams = {
24
24
  dispatch: Dispatch<LineItemAction>;
25
25
  config: CommerceLayerConfig;
26
26
  order: Order | null;
@@ -47,6 +47,6 @@ export declare const getLineItems: GetLineItems;
47
47
  export declare const updateLineItem: UpdateLineItem;
48
48
  export declare const deleteLineItem: DeleteLineItem;
49
49
  export declare const lineItemInitialState: LineItemState;
50
- export declare type LineItemActionType = 'setLineItems' | 'setErrors' | 'setLoading';
50
+ export type LineItemActionType = 'setLineItems' | 'setErrors' | 'setLoading';
51
51
  declare const lineItemReducer: (state: LineItemState, reducer: LineItemAction) => LineItemState;
52
52
  export default lineItemReducer;
@@ -5,7 +5,7 @@ import { BaseMetadataObject } from '../typings/index';
5
5
  import { BaseError } from '../typings/errors';
6
6
  import { AddressResource } from './AddressReducer';
7
7
  import type { Order, OrderUpdate } from '@commercelayer/sdk';
8
- export declare type GetOrderParams = Partial<{
8
+ export type GetOrderParams = Partial<{
9
9
  clearWhenPlaced: boolean;
10
10
  config: CommerceLayerConfig;
11
11
  deleteLocalOrder: DeleteLocalOrder;
@@ -14,20 +14,20 @@ export declare type GetOrderParams = Partial<{
14
14
  persistKey: string;
15
15
  state: OrderState;
16
16
  }>;
17
- export declare type GetOrder = (params: GetOrderParams) => Promise<undefined | Order>;
18
- declare type CreateOrderParams = Pick<AddToCartParams, 'config' | 'dispatch' | 'persistKey' | 'state' | 'orderMetadata' | 'orderAttributes' | 'setLocalOrder'>;
19
- export declare type CreateOrder = (params?: CreateOrderParams) => Promise<string>;
17
+ export type GetOrder = (params: GetOrderParams) => Promise<undefined | Order>;
18
+ type CreateOrderParams = Pick<AddToCartParams, 'config' | 'dispatch' | 'persistKey' | 'state' | 'orderMetadata' | 'orderAttributes' | 'setLocalOrder'>;
19
+ export type CreateOrder = (params?: CreateOrderParams) => Promise<string>;
20
20
  export interface AddToCartImportParams extends Omit<AddToCartParams, 'skuCode' | 'skuId' | 'quantity' | 'option' | 'lineItem'> {
21
21
  lineItems: CustomLineItem[];
22
22
  }
23
- export declare type AddToCartReturn = Promise<{
23
+ export type AddToCartReturn = Promise<{
24
24
  success: boolean;
25
25
  orderId: string | undefined;
26
26
  }>;
27
- export declare type AddToCartImport = (params: AddToCartImportParams) => AddToCartReturn;
28
- export declare type UnsetOrderState = (dispatch: Dispatch<OrderActions>) => void;
29
- export declare type ResourceIncluded = 'billing_address' | 'shipping_address' | 'line_items.line_item_options.sku_option' | 'line_items.item' | 'available_customer_payment_sources.payment_source' | 'shipments.available_shipping_methods' | 'shipments.stock_transfers' | 'shipments.stock_transfers.line_item' | 'shipments.shipment_line_items.line_item' | 'shipments.shipping_method' | 'shipments.stock_location' | 'shipments.parcels' | 'shipments.parcels.parcel_line_items' | 'payment_source' | 'available_payment_methods' | 'payment_method';
30
- declare type ResourceIncludedLoaded = Partial<Record<ResourceIncluded, boolean>>;
27
+ export type AddToCartImport = (params: AddToCartImportParams) => AddToCartReturn;
28
+ export type UnsetOrderState = (dispatch: Dispatch<OrderActions>) => void;
29
+ export type ResourceIncluded = 'billing_address' | 'shipping_address' | 'line_items.line_item_options.sku_option' | 'line_items.item' | 'available_customer_payment_sources.payment_source' | 'shipments.available_shipping_methods' | 'shipments.stock_transfers' | 'shipments.stock_transfers.line_item' | 'shipments.shipment_line_items.line_item' | 'shipments.shipping_method' | 'shipments.stock_location' | 'shipments.parcels' | 'shipments.parcels.parcel_line_items' | 'payment_source' | 'available_payment_methods' | 'payment_method';
30
+ type ResourceIncludedLoaded = Partial<Record<ResourceIncluded, boolean>>;
31
31
  export interface OrderPayload {
32
32
  loading?: boolean;
33
33
  orderId?: string;
@@ -37,14 +37,14 @@ export interface OrderPayload {
37
37
  includeLoaded?: ResourceIncludedLoaded;
38
38
  withoutIncludes?: boolean;
39
39
  }
40
- export declare type AddToCartImportValues = Pick<AddToCartImportParams, 'lineItems'>;
41
- export declare type getOrderContext = (id: string) => Promise<undefined | Order>;
42
- export declare type OrderState = Partial<OrderPayload>;
40
+ export type AddToCartImportValues = Pick<AddToCartImportParams, 'lineItems'>;
41
+ export type getOrderContext = (id: string) => Promise<undefined | Order>;
42
+ export type OrderState = Partial<OrderPayload>;
43
43
  export interface OrderActions {
44
44
  type: OrderActionType;
45
45
  payload: OrderPayload;
46
46
  }
47
- export declare type OrderActionType = 'setLoading' | 'setOrderId' | 'setOrder' | 'setSingleQuantity' | 'setCurrentSkuCodes' | 'setCurrentSkuPrices' | 'setCurrentItem' | 'setErrors' | 'setSaveAddressToCustomerAddressBook' | 'setGiftCardOrCouponCode' | 'setIncludesResource';
47
+ export type OrderActionType = 'setLoading' | 'setOrderId' | 'setOrder' | 'setSingleQuantity' | 'setCurrentSkuCodes' | 'setCurrentSkuPrices' | 'setCurrentItem' | 'setErrors' | 'setSaveAddressToCustomerAddressBook' | 'setGiftCardOrCouponCode' | 'setIncludesResource';
48
48
  export declare const createOrder: CreateOrder;
49
49
  export declare const getApiOrder: GetOrder;
50
50
  export interface UpdateOrderArgs {
@@ -83,7 +83,7 @@ export interface CustomLineItem {
83
83
  name?: string;
84
84
  imageUrl?: string | null;
85
85
  }
86
- export declare type AddToCartParams = Partial<{
86
+ export type AddToCartParams = Partial<{
87
87
  bundleCode: string;
88
88
  skuCode: string;
89
89
  persistKey: string;
@@ -112,13 +112,13 @@ interface OrderErrors {
112
112
  export declare function setOrderErrors({ dispatch, errors }: OrderErrors): {
113
113
  success: boolean;
114
114
  };
115
- export declare type SaveAddressToCustomerAddressBook = (params: {
115
+ export type SaveAddressToCustomerAddressBook = (params: {
116
116
  dispatch?: Dispatch<OrderActions>;
117
117
  type: AddressResource;
118
118
  value: boolean;
119
119
  }) => void;
120
120
  export declare const saveAddressToCustomerAddressBook: SaveAddressToCustomerAddressBook;
121
- export declare type SetGiftCardOrCouponCode = (args: {
121
+ export type SetGiftCardOrCouponCode = (args: {
122
122
  code: string;
123
123
  codeType: OrderCodeType;
124
124
  dispatch?: Dispatch<OrderActions>;
@@ -130,9 +130,9 @@ export declare type SetGiftCardOrCouponCode = (args: {
130
130
  success: boolean;
131
131
  }>;
132
132
  export declare const setGiftCardOrCouponCode: SetGiftCardOrCouponCode;
133
- export declare type CodeType = 'coupon' | 'gift_card' | 'gift_card_or_coupon';
134
- export declare type OrderCodeType = `${CodeType}_code`;
135
- export declare type RemoveGiftCardOrCouponCode = (args: {
133
+ export type CodeType = 'coupon' | 'gift_card' | 'gift_card_or_coupon';
134
+ export type OrderCodeType = `${CodeType}_code`;
135
+ export type RemoveGiftCardOrCouponCode = (args: {
136
136
  codeType: OrderCodeType;
137
137
  dispatch?: Dispatch<OrderActions>;
138
138
  config?: CommerceLayerConfig;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.orderInitialState=exports.removeGiftCardOrCouponCode=exports.setGiftCardOrCouponCode=exports.saveAddressToCustomerAddressBook=exports.setOrderErrors=exports.unsetOrderState=exports.addToCart=exports.addResourceToInclude=exports.setOrder=exports.updateOrder=exports.getApiOrder=exports.createOrder=void 0;const tslib_1=require("tslib"),localStorage_1=require("../utils/localStorage"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),organization_1=tslib_1.__importDefault(require("../utils/organization")),actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"],createOrder=async params=>{if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=(0,getSdk_1.default)(config);try{const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=(0,getErrors_1.default)(error,"orders");console.error("Create order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""};exports.createOrder=createOrder;const getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=(0,getSdk_1.default)(config);try{const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.status==="placed"||clearWhenPlaced&&order.status==="approved"||clearWhenPlaced&&order.status==="cancelled"?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(0,getErrors_1.default)(error,"orders");console.error("Retrieve order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch});return}};exports.getApiOrder=getApiOrder;async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=(0,getSdk_1.default)(config);try{const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await(0,exports.getApiOrder)({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0}}catch(error){const errors=(0,getErrors_1.default)(error,"orders");return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}exports.updateOrder=updateOrder;const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};exports.setOrder=setOrder;function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...resourcesIncluded,...resources],resources.forEach(resource=>{const includeLoaded={...payload.includeLoaded,[resource]:!0};payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded};payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}exports.addResourceToInclude=addResourceToInclude;async function addToCart(params){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption}=params;try{if(config){const sdk=(0,getSdk_1.default)(config),id=await(0,exports.createOrder)(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items:lineItems}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&await Promise.all(lineItems.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:!0,bundle_code:bundleCode},newLineItem=await sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),await(0,exports.getApiOrder)({id,...params})}else await(0,exports.getApiOrder)({id,...params,state});if(!(0,isEmpty_1.default)(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=(0,organization_1.default)(config.endpoint??""),params2=`${id}?accessToken=${config.accessToken??""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=(0,getErrors_1.default)(error,"orders");return console.error("Add to cart",errors2),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}}exports.addToCart=addToCart;const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};exports.unsetOrderState=unsetOrderState;function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}exports.setOrderErrors=setOrderErrors;const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;(0,localStorage_1.setCustomerOrderParam)(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};exports.saveAddressToCustomerAddressBook=saveAddressToCustomerAddressBook;const setGiftCardOrCouponCode=async({code,codeType,dispatch,config,order,include,state})=>{try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,error}=await updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",codeType);return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}};exports.setGiftCardOrCouponCode=setGiftCardOrCouponCode;const removeGiftCardOrCouponCode=async({codeType,dispatch,config,order,include,state})=>{try{if(config&&order&&dispatch){const attributes={[codeType]:""};return await updateOrder({id:order.id,attributes,config,include,dispatch,state}),dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",codeType);return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}};exports.removeGiftCardOrCouponCode=removeGiftCardOrCouponCode,exports.orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,actionType);exports.default=orderReducer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.orderInitialState=exports.removeGiftCardOrCouponCode=exports.setGiftCardOrCouponCode=exports.saveAddressToCustomerAddressBook=exports.setOrderErrors=exports.unsetOrderState=exports.addToCart=exports.addResourceToInclude=exports.setOrder=exports.updateOrder=exports.getApiOrder=exports.createOrder=void 0;const tslib_1=require("tslib"),localStorage_1=require("../utils/localStorage"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),organization_1=tslib_1.__importDefault(require("../utils/organization")),actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"],createOrder=async params=>{if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=(0,getSdk_1.default)(config);try{const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=(0,getErrors_1.default)(error,"orders");console.error("Create order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""};exports.createOrder=createOrder;const getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=(0,getSdk_1.default)(config);try{const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.editable===!1?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(0,getErrors_1.default)(error,"orders");console.error("Retrieve order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch});return}};exports.getApiOrder=getApiOrder;async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=(0,getSdk_1.default)(config);try{const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await(0,exports.getApiOrder)({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0}}catch(error){const errors=(0,getErrors_1.default)(error,"orders");return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}exports.updateOrder=updateOrder;const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};exports.setOrder=setOrder;function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...resourcesIncluded,...resources],resources.forEach(resource=>{const includeLoaded={...payload.includeLoaded,[resource]:!0};payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded};payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}exports.addResourceToInclude=addResourceToInclude;async function addToCart(params){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption}=params;try{if(config){const sdk=(0,getSdk_1.default)(config),id=await(0,exports.createOrder)(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items:lineItems}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&await Promise.all(lineItems.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:!0,bundle_code:bundleCode},newLineItem=await sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),await(0,exports.getApiOrder)({id,...params})}else await(0,exports.getApiOrder)({id,...params,state});if(!(0,isEmpty_1.default)(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=(0,organization_1.default)(config.endpoint??""),params2=`${id}?accessToken=${config.accessToken??""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=(0,getErrors_1.default)(error,"orders");return console.error("Add to cart",errors2),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}}exports.addToCart=addToCart;const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};exports.unsetOrderState=unsetOrderState;function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}exports.setOrderErrors=setOrderErrors;const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;(0,localStorage_1.setCustomerOrderParam)(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};exports.saveAddressToCustomerAddressBook=saveAddressToCustomerAddressBook;const setGiftCardOrCouponCode=async({code,codeType,dispatch,config,order,include,state})=>{try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,error}=await updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",codeType);return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}};exports.setGiftCardOrCouponCode=setGiftCardOrCouponCode;const removeGiftCardOrCouponCode=async({codeType,dispatch,config,order,include,state})=>{try{if(config&&order&&dispatch){const attributes={[codeType]:""};return await updateOrder({id:order.id,attributes,config,include,dispatch,state}),dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",codeType);return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}};exports.removeGiftCardOrCouponCode=removeGiftCardOrCouponCode,exports.orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,actionType);exports.default=orderReducer;
@@ -9,7 +9,7 @@ import { BaseError } from '../typings/errors';
9
9
  import { Order, PaymentMethod, StripePayment, WireTransfer, AdyenPayment, BraintreePayment, CheckoutComPayment, ExternalPayment, PaypalPayment, KlarnaPayment } from '@commercelayer/sdk';
10
10
  import { Dispatch, MutableRefObject } from 'react';
11
11
  import { CheckoutComConfig } from '../components/payment_source/CheckoutComPayment';
12
- export declare type PaymentSourceType = AdyenPayment | BraintreePayment | CheckoutComPayment | ExternalPayment | PaypalPayment | StripePayment | WireTransfer;
12
+ export type PaymentSourceType = AdyenPayment | BraintreePayment | CheckoutComPayment | ExternalPayment | PaypalPayment | StripePayment | WireTransfer;
13
13
  interface Card {
14
14
  type: string;
15
15
  brand: string;
@@ -52,8 +52,8 @@ export interface PaymentSourceObject {
52
52
  };
53
53
  klarna_payments: KlarnaPayment;
54
54
  }
55
- export declare type PaymentMethodActionType = 'setErrors' | 'setPaymentMethods' | 'setPaymentMethodConfig' | 'setPaymentSource' | 'setPaymentRef' | 'setLoading';
56
- export declare type PaymentRef = MutableRefObject<null | HTMLFormElement>;
55
+ export type PaymentMethodActionType = 'setErrors' | 'setPaymentMethods' | 'setPaymentMethodConfig' | 'setPaymentSource' | 'setPaymentRef' | 'setLoading';
56
+ export type PaymentRef = MutableRefObject<null | HTMLFormElement>;
57
57
  export interface PaymentMethodActionPayload {
58
58
  errors: BaseError[];
59
59
  paymentMethods: PaymentMethod[];
@@ -68,28 +68,28 @@ export declare function setLoading({ loading, dispatch }: {
68
68
  loading: boolean;
69
69
  dispatch?: Dispatch<PaymentMethodAction>;
70
70
  }): void;
71
- export declare type SetPaymentRef = (args: {
71
+ export type SetPaymentRef = (args: {
72
72
  ref: PaymentRef;
73
73
  dispatch?: Dispatch<PaymentMethodAction>;
74
74
  }) => void;
75
75
  export declare const setPaymentRef: SetPaymentRef;
76
- export declare type PaymentMethodState = Partial<PaymentMethodActionPayload>;
76
+ export type PaymentMethodState = Partial<PaymentMethodActionPayload>;
77
77
  export interface PaymentMethodAction {
78
78
  type: PaymentMethodActionType;
79
79
  payload: Partial<PaymentMethodActionPayload>;
80
80
  }
81
81
  export declare const paymentMethodInitialState: PaymentMethodState;
82
- export declare type SetPaymentMethodErrors = <V extends BaseError[]>(errors: V, dispatch?: Dispatch<PaymentMethodAction>) => void;
82
+ export type SetPaymentMethodErrors = <V extends BaseError[]>(errors: V, dispatch?: Dispatch<PaymentMethodAction>) => void;
83
83
  export declare const setPaymentMethodErrors: SetPaymentMethodErrors;
84
- declare type GetPaymentMethods = (args: {
84
+ type GetPaymentMethods = (args: {
85
85
  order: Order;
86
86
  dispatch: Dispatch<PaymentMethodAction>;
87
87
  }) => Promise<void>;
88
88
  export declare const getPaymentMethods: GetPaymentMethods;
89
- export declare type PaymentResource = keyof PaymentSourceObject;
90
- export declare type PaymentResourceKey = 'braintreePayment' | 'stripePayment' | 'klarnaPayment' | 'wireTransfer' | 'paypalPayment' | 'adyenPayment' | 'checkoutComPayment';
91
- export declare type SDKPaymentResource = 'AdyenPayment' | 'BraintreePayment' | 'ExternalPayment' | 'PaypalPayment' | 'StripePayment' | 'WireTransfer' | 'CheckoutComPayment';
92
- export declare type SetPaymentMethod = (args: {
89
+ export type PaymentResource = keyof PaymentSourceObject;
90
+ export type PaymentResourceKey = 'braintreePayment' | 'stripePayment' | 'klarnaPayment' | 'wireTransfer' | 'paypalPayment' | 'adyenPayment' | 'checkoutComPayment';
91
+ export type SDKPaymentResource = 'AdyenPayment' | 'BraintreePayment' | 'ExternalPayment' | 'PaypalPayment' | 'StripePayment' | 'WireTransfer' | 'CheckoutComPayment';
92
+ export type SetPaymentMethod = (args: {
93
93
  config?: CommerceLayerConfig;
94
94
  dispatch?: Dispatch<PaymentMethodAction>;
95
95
  updateOrder?: typeof updateOrder;
@@ -101,12 +101,12 @@ export declare type SetPaymentMethod = (args: {
101
101
  paymentResource?: PaymentResource;
102
102
  }) => Promise<void>;
103
103
  export declare const setPaymentMethod: SetPaymentMethod;
104
- declare type PaymentSourceTypes = (StripePayment & WireTransfer) | (StripePayment | WireTransfer);
105
- export declare type SetPaymentSourceResponse = {
104
+ type PaymentSourceTypes = (StripePayment & WireTransfer) | (StripePayment | WireTransfer);
105
+ export type SetPaymentSourceResponse = {
106
106
  order: Order;
107
107
  paymentSource: PaymentSourceTypes;
108
108
  } | null;
109
- export declare type SetPaymentSource = (args: {
109
+ export type SetPaymentSource = (args: {
110
110
  config?: CommerceLayerConfig;
111
111
  dispatch?: Dispatch<PaymentMethodAction>;
112
112
  getOrder?: getOrderContext;
@@ -118,7 +118,7 @@ export declare type SetPaymentSource = (args: {
118
118
  updateOrder?: typeof updateOrder;
119
119
  } & PaymentMethodState) => Promise<PaymentSourceType | undefined>;
120
120
  export declare const setPaymentSource: SetPaymentSource;
121
- export declare type UpdatePaymentSource = (args: {
121
+ export type UpdatePaymentSource = (args: {
122
122
  id: string;
123
123
  attributes: Record<string, any>;
124
124
  paymentResource: PaymentResource;
@@ -126,7 +126,7 @@ export declare type UpdatePaymentSource = (args: {
126
126
  dispatch?: Dispatch<PaymentMethodAction>;
127
127
  }) => Promise<void>;
128
128
  export declare const updatePaymentSource: UpdatePaymentSource;
129
- export declare type DestroyPaymentSource = (args: {
129
+ export type DestroyPaymentSource = (args: {
130
130
  paymentSourceId: string;
131
131
  paymentResource: PaymentResource;
132
132
  dispatch?: Dispatch<PaymentMethodAction>;
@@ -143,7 +143,7 @@ export interface PaymentMethodConfig {
143
143
  checkoutComPayment?: CheckoutComConfig;
144
144
  klarnaPayment?: Pick<AdyenPaymentConfig, 'placeOrderCallback'> & Pick<StripeConfig, 'containerClassName'>;
145
145
  }
146
- declare type SetPaymentMethodConfig = (config: PaymentMethodConfig, dispatch: Dispatch<PaymentMethodAction>) => void;
146
+ type SetPaymentMethodConfig = (config: PaymentMethodConfig, dispatch: Dispatch<PaymentMethodAction>) => void;
147
147
  export declare const setPaymentMethodConfig: SetPaymentMethodConfig;
148
148
  export declare function getPaymentConfig<K extends PaymentResourceKey>(paymentResource: PaymentResource, config: PaymentMethodConfig): PaymentMethodConfig[K];
149
149
  declare const paymentMethodReducer: (state: PaymentMethodState, reducer: PaymentMethodAction) => PaymentMethodState;
@@ -4,8 +4,8 @@ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
4
4
  import { Order } from '@commercelayer/sdk';
5
5
  import { PaymentResource } from './PaymentMethodReducer';
6
6
  import { PaymentSourceType } from './PaymentMethodReducer';
7
- export declare type PlaceOrderActionType = 'setErrors' | 'setPlaceOrderPermitted' | 'setButtonRef';
8
- export declare type PlaceOrderOptions = {
7
+ export type PlaceOrderActionType = 'setErrors' | 'setPlaceOrderPermitted' | 'setButtonRef';
8
+ export type PlaceOrderOptions = {
9
9
  paypalPayerId?: string;
10
10
  adyen?: {
11
11
  MD?: string;
@@ -27,7 +27,7 @@ export interface PlaceOrderActionPayload {
27
27
  placeOrderButtonRef?: RefObject<HTMLButtonElement>;
28
28
  }
29
29
  export declare function setButtonRef(ref: RefObject<HTMLButtonElement>, dispatch: Dispatch<PlaceOrderAction>): void;
30
- export declare type PlaceOrderState = Partial<PlaceOrderActionPayload>;
30
+ export type PlaceOrderState = Partial<PlaceOrderActionPayload>;
31
31
  export interface PlaceOrderAction {
32
32
  type: PlaceOrderActionType;
33
33
  payload: Partial<PlaceOrderActionPayload>;
@@ -37,14 +37,14 @@ export interface SetPlaceOrderErrors {
37
37
  <V extends BaseError[]>(errors: V, dispatch?: Dispatch<PlaceOrderAction>): void;
38
38
  }
39
39
  export declare const setPlaceOrderErrors: SetPlaceOrderErrors;
40
- declare type PlaceOrderPermitted = (args: {
40
+ type PlaceOrderPermitted = (args: {
41
41
  config?: CommerceLayerConfig;
42
42
  dispatch: Dispatch<PlaceOrderAction>;
43
43
  order?: Order;
44
44
  options?: PlaceOrderOptions;
45
45
  }) => void;
46
46
  export declare const placeOrderPermitted: PlaceOrderPermitted;
47
- export declare type SetPlaceOrder = (args: {
47
+ export type SetPlaceOrder = (args: {
48
48
  config?: CommerceLayerConfig;
49
49
  order?: Order;
50
50
  state?: PlaceOrderState;
@@ -6,7 +6,7 @@ import { BaseError } from '../typings/errors';
6
6
  export interface Prices {
7
7
  [key: string]: Price | Price[];
8
8
  }
9
- declare type SkuCodesPrice = string[];
9
+ type SkuCodesPrice = string[];
10
10
  export interface PriceState {
11
11
  loading: boolean;
12
12
  prices: Prices;
@@ -30,8 +30,8 @@ export declare function getSkusPrice(skuCodes: SkuCodesPrice, { config, dispatch
30
30
  perPage: number;
31
31
  filters: Record<string, any>;
32
32
  }): void;
33
- export declare type UnsetPriceState = (dispatch: Dispatch<PriceAction>) => void;
33
+ export type UnsetPriceState = (dispatch: Dispatch<PriceAction>) => void;
34
34
  export declare const unsetPriceState: UnsetPriceState;
35
- export declare type PriceActionType = 'setLoading' | 'setPrices' | 'setSkuCodes' | 'setErrors';
35
+ export type PriceActionType = 'setLoading' | 'setPrices' | 'setSkuCodes' | 'setErrors';
36
36
  declare const priceReducer: (state: PriceState, reducer: PriceAction) => PriceState;
37
37
  export default priceReducer;