@commercelayer/react-components 4.0.0-alpha.5 → 4.0.0-alpha.7

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 (233) hide show
  1. package/lib/cjs/components/SubmitButton.d.ts +6 -15
  2. package/lib/cjs/components/SubmitButton.js +1 -1
  3. package/lib/cjs/components/addresses/Address.d.ts +4 -9
  4. package/lib/cjs/components/addresses/Address.js +1 -1
  5. package/lib/cjs/components/addresses/AddressField.d.ts +8 -12
  6. package/lib/cjs/components/addresses/AddressField.js +1 -1
  7. package/lib/cjs/components/addresses/AddressInput.d.ts +0 -11
  8. package/lib/cjs/components/addresses/AddressInput.js +1 -1
  9. package/lib/cjs/components/addresses/AddressesContainer.d.ts +2 -9
  10. package/lib/cjs/components/addresses/AddressesContainer.js +1 -1
  11. package/lib/cjs/components/addresses/AddressesEmpty.d.ts +14 -0
  12. package/lib/cjs/components/addresses/AddressesEmpty.js +1 -0
  13. package/lib/cjs/components/addresses/SaveAddressesButton.d.ts +4 -3
  14. package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -1
  15. package/lib/cjs/components/auth/CommerceLayer.d.ts +2 -9
  16. package/lib/cjs/components/auth/CommerceLayer.js +1 -1
  17. package/lib/cjs/components/customers/CustomerContainer.d.ts +2 -2
  18. package/lib/cjs/components/customers/CustomerContainer.js +1 -1
  19. package/lib/cjs/components/customers/SaveCustomerButton.d.ts +6 -7
  20. package/lib/cjs/components/customers/SaveCustomerButton.js +1 -1
  21. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +8 -16
  22. package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.js +1 -1
  23. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +4 -12
  24. package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -1
  25. package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.d.ts +6 -12
  26. package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.js +1 -1
  27. package/lib/cjs/components/line_items/LineItemOption.d.ts +2 -2
  28. package/lib/cjs/components/line_items/LineItemQuantity.d.ts +4 -16
  29. package/lib/cjs/components/line_items/LineItemQuantity.js +1 -1
  30. package/lib/cjs/components/line_items/LineItemRemoveLink.d.ts +6 -16
  31. package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
  32. package/lib/cjs/components/line_items/LineItemsCount.d.ts +4 -14
  33. package/lib/cjs/components/line_items/LineItemsCount.js +1 -1
  34. package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +6 -17
  35. package/lib/cjs/components/line_items/LineItemsEmpty.js +1 -1
  36. package/lib/cjs/components/orders/AddToCartButton.d.ts +4 -5
  37. package/lib/cjs/components/orders/AddToCartButton.js +1 -1
  38. package/lib/cjs/components/orders/CartLink.d.ts +6 -6
  39. package/lib/cjs/components/orders/CartLink.js +1 -1
  40. package/lib/cjs/components/orders/CheckoutLink.d.ts +4 -4
  41. package/lib/cjs/components/orders/CheckoutLink.js +1 -1
  42. package/lib/cjs/components/orders/ItemContainer.d.ts +2 -13
  43. package/lib/cjs/components/orders/ItemContainer.js +1 -1
  44. package/lib/cjs/components/orders/OrderContainer.d.ts +4 -18
  45. package/lib/cjs/components/orders/OrderContainer.js +1 -1
  46. package/lib/cjs/components/orders/OrderList.d.ts +11 -12
  47. package/lib/cjs/components/orders/OrderList.js +1 -1
  48. package/lib/cjs/components/orders/OrderListEmpty.d.ts +14 -0
  49. package/lib/cjs/components/orders/OrderListEmpty.js +1 -0
  50. package/lib/cjs/components/orders/OrderListRow.d.ts +9 -5
  51. package/lib/cjs/components/orders/OrderListRow.js +1 -1
  52. package/lib/cjs/components/orders/PlaceOrderButton.d.ts +4 -14
  53. package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
  54. package/lib/cjs/components/parcels/Parcel.d.ts +6 -0
  55. package/lib/cjs/components/parcels/Parcel.js +1 -0
  56. package/lib/cjs/components/payment_source/AdyenPayment.js +1 -1
  57. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +4 -14
  58. package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.js +1 -1
  59. package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +4 -11
  60. package/lib/cjs/components/payment_source/PaymentSourceBrandName.js +1 -1
  61. package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +6 -12
  62. package/lib/cjs/components/payment_source/PaymentSourceDetail.js +1 -1
  63. package/lib/cjs/components/payment_source/PaymentSourceEditButton.d.ts +4 -10
  64. package/lib/cjs/components/payment_source/PaymentSourceEditButton.js +1 -1
  65. package/lib/cjs/components/prices/Price.d.ts +6 -18
  66. package/lib/cjs/components/prices/Price.js +1 -1
  67. package/lib/cjs/components/prices/PricesContainer.d.ts +4 -20
  68. package/lib/cjs/components/prices/PricesContainer.js +1 -1
  69. package/lib/cjs/components/shipments/Shipment.d.ts +2 -8
  70. package/lib/cjs/components/shipments/Shipment.js +1 -1
  71. package/lib/cjs/components/shipments/ShipmentField.d.ts +0 -7
  72. package/lib/cjs/components/shipments/ShipmentField.js +1 -1
  73. package/lib/cjs/components/shipments/ShipmentsContainer.d.ts +2 -8
  74. package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -1
  75. package/lib/cjs/components/shipping_methods/ShippingMethod.d.ts +2 -9
  76. package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -1
  77. package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +0 -6
  78. package/lib/cjs/components/shipping_methods/ShippingMethodName.js +1 -1
  79. package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +4 -13
  80. package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -1
  81. package/lib/cjs/components/skus/QuantitySelector.d.ts +4 -18
  82. package/lib/cjs/components/skus/QuantitySelector.js +1 -1
  83. package/lib/cjs/components/skus/VariantSelector.d.ts +4 -27
  84. package/lib/cjs/components/skus/VariantSelector.js +1 -1
  85. package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +8 -8
  86. package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -1
  87. package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
  88. package/lib/cjs/components/utils/ErrorBoundary.d.ts +14 -0
  89. package/lib/cjs/components/utils/ErrorBoundary.js +1 -0
  90. package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +2 -2
  91. package/lib/cjs/components/utils/PriceTemplate.d.ts +2 -2
  92. package/lib/cjs/components/utils/PriceTemplate.js +1 -1
  93. package/lib/cjs/context/BillingAddressFormContext.d.ts +2 -2
  94. package/lib/cjs/context/OrderContext.d.ts +3 -3
  95. package/lib/cjs/context/OrderListChildrenContext.d.ts +8 -0
  96. package/lib/cjs/context/ParcelChildrenContext.d.ts +7 -0
  97. package/lib/cjs/context/ParcelChildrenContext.js +1 -0
  98. package/lib/cjs/context/ShipmentChildrenContext.d.ts +6 -5
  99. package/lib/cjs/context/ShipmentChildrenContext.js +1 -1
  100. package/lib/cjs/index.d.ts +36 -34
  101. package/lib/cjs/index.js +1 -1
  102. package/lib/cjs/reducers/AddressReducer.d.ts +17 -23
  103. package/lib/cjs/reducers/AddressReducer.js +1 -1
  104. package/lib/cjs/reducers/CustomerReducer.d.ts +18 -20
  105. package/lib/cjs/reducers/CustomerReducer.js +1 -1
  106. package/lib/cjs/reducers/OrderReducer.d.ts +16 -29
  107. package/lib/cjs/reducers/OrderReducer.js +1 -1
  108. package/lib/cjs/reducers/ShipmentReducer.d.ts +1 -3
  109. package/lib/cjs/typings/errors.d.ts +2 -2
  110. package/lib/cjs/typings/index.d.ts +8 -16
  111. package/lib/cjs/utils/addressesManager.d.ts +5 -4
  112. package/lib/cjs/utils/getPrices.d.ts +4 -15
  113. package/lib/cjs/utils/getPrices.js +1 -1
  114. package/lib/cjs/utils/getSdk.d.ts +1 -1
  115. package/lib/cjs/utils/organization.d.ts +2 -2
  116. package/lib/esm/components/SubmitButton.d.ts +6 -15
  117. package/lib/esm/components/SubmitButton.js +1 -1
  118. package/lib/esm/components/addresses/Address.d.ts +4 -9
  119. package/lib/esm/components/addresses/Address.js +1 -1
  120. package/lib/esm/components/addresses/AddressField.d.ts +8 -12
  121. package/lib/esm/components/addresses/AddressField.js +1 -1
  122. package/lib/esm/components/addresses/AddressInput.d.ts +0 -11
  123. package/lib/esm/components/addresses/AddressInput.js +1 -1
  124. package/lib/esm/components/addresses/AddressesContainer.d.ts +2 -9
  125. package/lib/esm/components/addresses/AddressesContainer.js +1 -1
  126. package/lib/esm/components/addresses/AddressesEmpty.d.ts +14 -0
  127. package/lib/esm/components/addresses/AddressesEmpty.js +1 -0
  128. package/lib/esm/components/addresses/SaveAddressesButton.d.ts +4 -3
  129. package/lib/esm/components/addresses/SaveAddressesButton.js +1 -1
  130. package/lib/esm/components/auth/CommerceLayer.d.ts +2 -9
  131. package/lib/esm/components/auth/CommerceLayer.js +1 -1
  132. package/lib/esm/components/customers/CustomerContainer.d.ts +2 -2
  133. package/lib/esm/components/customers/CustomerContainer.js +1 -1
  134. package/lib/esm/components/customers/SaveCustomerButton.d.ts +6 -7
  135. package/lib/esm/components/customers/SaveCustomerButton.js +1 -1
  136. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +8 -16
  137. package/lib/esm/components/gift_cards/GiftCardOrCouponCode.js +1 -1
  138. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.d.ts +4 -12
  139. package/lib/esm/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -1
  140. package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.d.ts +6 -12
  141. package/lib/esm/components/gift_cards/GiftCardOrCouponSubmit.js +1 -1
  142. package/lib/esm/components/line_items/LineItemOption.d.ts +2 -2
  143. package/lib/esm/components/line_items/LineItemQuantity.d.ts +4 -16
  144. package/lib/esm/components/line_items/LineItemQuantity.js +1 -1
  145. package/lib/esm/components/line_items/LineItemRemoveLink.d.ts +6 -16
  146. package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -1
  147. package/lib/esm/components/line_items/LineItemsCount.d.ts +4 -14
  148. package/lib/esm/components/line_items/LineItemsCount.js +1 -1
  149. package/lib/esm/components/line_items/LineItemsEmpty.d.ts +6 -17
  150. package/lib/esm/components/line_items/LineItemsEmpty.js +1 -1
  151. package/lib/esm/components/orders/AddToCartButton.d.ts +4 -5
  152. package/lib/esm/components/orders/AddToCartButton.js +1 -1
  153. package/lib/esm/components/orders/CartLink.d.ts +6 -6
  154. package/lib/esm/components/orders/CartLink.js +1 -1
  155. package/lib/esm/components/orders/CheckoutLink.d.ts +4 -4
  156. package/lib/esm/components/orders/CheckoutLink.js +1 -1
  157. package/lib/esm/components/orders/ItemContainer.d.ts +2 -13
  158. package/lib/esm/components/orders/ItemContainer.js +1 -1
  159. package/lib/esm/components/orders/OrderContainer.d.ts +4 -18
  160. package/lib/esm/components/orders/OrderContainer.js +1 -1
  161. package/lib/esm/components/orders/OrderList.d.ts +11 -12
  162. package/lib/esm/components/orders/OrderList.js +1 -1
  163. package/lib/esm/components/orders/OrderListEmpty.d.ts +14 -0
  164. package/lib/esm/components/orders/OrderListEmpty.js +1 -0
  165. package/lib/esm/components/orders/OrderListRow.d.ts +9 -5
  166. package/lib/esm/components/orders/OrderListRow.js +1 -1
  167. package/lib/esm/components/orders/PlaceOrderButton.d.ts +4 -14
  168. package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
  169. package/lib/esm/components/parcels/Parcel.d.ts +6 -0
  170. package/lib/esm/components/parcels/Parcel.js +1 -0
  171. package/lib/esm/components/payment_source/AdyenPayment.js +1 -1
  172. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +4 -14
  173. package/lib/esm/components/payment_source/PaymentSourceBrandIcon.js +1 -1
  174. package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +4 -11
  175. package/lib/esm/components/payment_source/PaymentSourceBrandName.js +1 -1
  176. package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +6 -12
  177. package/lib/esm/components/payment_source/PaymentSourceDetail.js +1 -1
  178. package/lib/esm/components/payment_source/PaymentSourceEditButton.d.ts +4 -10
  179. package/lib/esm/components/payment_source/PaymentSourceEditButton.js +1 -1
  180. package/lib/esm/components/prices/Price.d.ts +6 -18
  181. package/lib/esm/components/prices/Price.js +1 -1
  182. package/lib/esm/components/prices/PricesContainer.d.ts +4 -20
  183. package/lib/esm/components/prices/PricesContainer.js +1 -1
  184. package/lib/esm/components/shipments/Shipment.d.ts +2 -8
  185. package/lib/esm/components/shipments/Shipment.js +1 -1
  186. package/lib/esm/components/shipments/ShipmentField.d.ts +0 -7
  187. package/lib/esm/components/shipments/ShipmentField.js +1 -1
  188. package/lib/esm/components/shipments/ShipmentsContainer.d.ts +2 -8
  189. package/lib/esm/components/shipments/ShipmentsContainer.js +1 -1
  190. package/lib/esm/components/shipping_methods/ShippingMethod.d.ts +2 -9
  191. package/lib/esm/components/shipping_methods/ShippingMethod.js +1 -1
  192. package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +0 -6
  193. package/lib/esm/components/shipping_methods/ShippingMethodName.js +1 -1
  194. package/lib/esm/components/skus/AvailabilityTemplate.d.ts +4 -13
  195. package/lib/esm/components/skus/AvailabilityTemplate.js +1 -1
  196. package/lib/esm/components/skus/QuantitySelector.d.ts +4 -18
  197. package/lib/esm/components/skus/QuantitySelector.js +1 -1
  198. package/lib/esm/components/skus/VariantSelector.d.ts +4 -27
  199. package/lib/esm/components/skus/VariantSelector.js +1 -1
  200. package/lib/esm/components/utils/AddressCardsTemplate.d.ts +8 -8
  201. package/lib/esm/components/utils/AddressCardsTemplate.js +1 -1
  202. package/lib/esm/components/utils/BaseInput.d.ts +1 -1
  203. package/lib/esm/components/utils/ErrorBoundary.d.ts +14 -0
  204. package/lib/esm/components/utils/ErrorBoundary.js +1 -0
  205. package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +2 -2
  206. package/lib/esm/components/utils/PriceTemplate.d.ts +2 -2
  207. package/lib/esm/components/utils/PriceTemplate.js +1 -1
  208. package/lib/esm/context/BillingAddressFormContext.d.ts +2 -2
  209. package/lib/esm/context/OrderContext.d.ts +3 -3
  210. package/lib/esm/context/OrderListChildrenContext.d.ts +8 -0
  211. package/lib/esm/context/ParcelChildrenContext.d.ts +7 -0
  212. package/lib/esm/context/ParcelChildrenContext.js +1 -0
  213. package/lib/esm/context/ShipmentChildrenContext.d.ts +6 -5
  214. package/lib/esm/context/ShipmentChildrenContext.js +1 -1
  215. package/lib/esm/index.d.ts +36 -34
  216. package/lib/esm/index.js +1 -1
  217. package/lib/esm/reducers/AddressReducer.d.ts +17 -23
  218. package/lib/esm/reducers/AddressReducer.js +1 -1
  219. package/lib/esm/reducers/CustomerReducer.d.ts +18 -20
  220. package/lib/esm/reducers/CustomerReducer.js +1 -1
  221. package/lib/esm/reducers/OrderReducer.d.ts +16 -29
  222. package/lib/esm/reducers/OrderReducer.js +1 -1
  223. package/lib/esm/reducers/ShipmentReducer.d.ts +1 -3
  224. package/lib/esm/typings/errors.d.ts +2 -2
  225. package/lib/esm/typings/index.d.ts +8 -16
  226. package/lib/esm/utils/addressesManager.d.ts +5 -4
  227. package/lib/esm/utils/getPrices.d.ts +4 -15
  228. package/lib/esm/utils/getPrices.js +1 -1
  229. package/lib/esm/utils/getSdk.d.ts +1 -1
  230. package/lib/esm/utils/organization.d.ts +2 -2
  231. package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
  232. package/lib/tsconfig.prod.tsbuildinfo +1 -1
  233. package/package.json +46 -35
@@ -2,7 +2,7 @@
2
2
  import { Order } from '@commercelayer/sdk';
3
3
  import { AddToCart, OrderState, CreateOrder, SetGiftCardOrCouponCode, RemoveGiftCardOrCouponCode, SaveAddressToCustomerAddressBook, addResourceToInclude, updateOrder, getOrderContext } from '../reducers/OrderReducer';
4
4
  import { BaseError } from '../typings/errors';
5
- declare type DefaultContext = {
5
+ interface DefaultContext extends OrderState {
6
6
  createOrder: CreateOrder;
7
7
  addToCart: AddToCart;
8
8
  setOrderErrors: (errors: BaseError[]) => void;
@@ -13,7 +13,7 @@ declare type DefaultContext = {
13
13
  getOrder: getOrderContext;
14
14
  updateOrder: typeof updateOrder;
15
15
  setOrder: (order: Order) => void;
16
- } & OrderState;
16
+ }
17
17
  export declare const defaultOrderContext: {
18
18
  addToCart: AddToCart;
19
19
  createOrder: CreateOrder;
@@ -23,7 +23,7 @@ export declare const defaultOrderContext: {
23
23
  removeGiftCardOrCouponCode: RemoveGiftCardOrCouponCode;
24
24
  saveAddressToCustomerAddressBook: SaveAddressToCustomerAddressBook;
25
25
  addResourceToInclude: typeof addResourceToInclude;
26
- getOrder: () => Promise<void>;
26
+ getOrder: () => Promise<undefined>;
27
27
  updateOrder: typeof updateOrder;
28
28
  };
29
29
  declare const OrderContext: import("react").Context<DefaultContext>;
@@ -6,6 +6,10 @@ export declare type InitialOrderListContext = Partial<{
6
6
  * The current order
7
7
  */
8
8
  order: Order | null;
9
+ /**
10
+ * The list of orders
11
+ */
12
+ orders: Order[] | null;
9
13
  /**
10
14
  * The current row
11
15
  */
@@ -34,6 +38,10 @@ declare const OrderListChildrenContext: import("react").Context<Partial<{
34
38
  * The current order
35
39
  */
36
40
  order: Order | null;
41
+ /**
42
+ * The list of orders
43
+ */
44
+ orders: Order[] | null;
37
45
  /**
38
46
  * The current row
39
47
  */
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { Parcel } from '@commercelayer/sdk';
3
+ export interface InitialParcelContext {
4
+ parcel?: Parcel;
5
+ }
6
+ declare const _default: import("react").Context<InitialParcelContext>;
7
+ export default _default;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const react_1=require("react"),initial={};exports.default=(0,react_1.createContext)(initial);
@@ -1,13 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { DeliveryLeadTime, LineItem, Shipment, ShippingMethod, StockTransfer } from '@commercelayer/sdk';
2
+ import type { DeliveryLeadTime, LineItem, Parcel, Shipment, ShippingMethod, StockTransfer } from '@commercelayer/sdk';
3
3
  export interface InitialShipmentContext {
4
- lineItems?: LineItem[];
5
- shippingMethods?: ShippingMethod[];
6
4
  currentShippingMethodId?: string;
7
- stockTransfers?: StockTransfer[];
8
5
  deliveryLeadTimes?: DeliveryLeadTime[];
9
- shipment?: Shipment;
10
6
  keyNumber: number;
7
+ lineItems?: LineItem[];
8
+ parcels?: Parcel[];
9
+ shipment?: Shipment;
10
+ shippingMethods?: ShippingMethod[];
11
+ stockTransfers?: StockTransfer[];
11
12
  }
12
13
  declare const ShipmentChildrenContext: import("react").Context<InitialShipmentContext>;
13
14
  export default ShipmentChildrenContext;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const react_1=require("react"),initial={lineItems:[],shippingMethods:[],stockTransfers:[],keyNumber:0},ShipmentChildrenContext=(0,react_1.createContext)(initial);exports.default=ShipmentChildrenContext;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const react_1=require("react"),initial={keyNumber:0,lineItems:[],shippingMethods:[],stockTransfers:[]},ShipmentChildrenContext=(0,react_1.createContext)(initial);exports.default=ShipmentChildrenContext;
@@ -1,28 +1,26 @@
1
- export * from './components/orders/AddToCartButton';
2
- export * from './components/addresses/AddressCountrySelector';
1
+ export * from './components/Errors';
2
+ export * from './components/ExternalFunction';
3
+ export * from './components/MetadataInput';
4
+ export * from './components/SubmitButton';
3
5
  export * from './components/addresses/Address';
6
+ export * from './components/addresses/AddressCountrySelector';
4
7
  export * from './components/addresses/AddressField';
5
8
  export * from './components/addresses/AddressInput';
6
9
  export * from './components/addresses/AddressStateSelector';
7
10
  export * from './components/addresses/AddressesContainer';
11
+ export * from './components/addresses/AddressesEmpty';
8
12
  export * from './components/addresses/BillingAddressContainer';
9
13
  export * from './components/addresses/BillingAddressForm';
10
- export * from './components/orders/AdjustmentAmount';
11
- export * from './components/skus/AvailabilityContainer';
12
- export * from './components/skus/AvailabilityTemplate';
13
- export * from './components/orders/CartLink';
14
- export * from './components/orders/CheckoutLink';
14
+ export * from './components/addresses/SaveAddressesButton';
15
+ export * from './components/addresses/ShippingAddressContainer';
16
+ export * from './components/addresses/ShippingAddressForm';
15
17
  export * from './components/auth/CommerceLayer';
18
+ export * from './components/customers/CustomerAddressForm';
16
19
  export * from './components/customers/CustomerContainer';
17
20
  export * from './components/customers/CustomerField';
18
- export * from './components/customers/CustomerAddressForm';
19
21
  export * from './components/customers/CustomerInput';
20
- export * from './components/skus/DeliveryLeadTime';
21
- export * from './components/orders/DiscountAmount';
22
- export * from './components/Errors';
23
- export * from './components/ExternalFunction';
22
+ export * from './components/customers/SaveCustomerButton';
24
23
  export * from './components/gift_cards/GiftCard';
25
- export * from './components/orders/GiftCardAmount';
26
24
  export * from './components/gift_cards/GiftCardContainer';
27
25
  export * from './components/gift_cards/GiftCardCurrencySelector';
28
26
  export * from './components/gift_cards/GiftCardInput';
@@ -31,7 +29,6 @@ export * from './components/gift_cards/GiftCardOrCouponForm';
31
29
  export * from './components/gift_cards/GiftCardOrCouponInput';
32
30
  export * from './components/gift_cards/GiftCardOrCouponRemoveButton';
33
31
  export * from './components/gift_cards/GiftCardOrCouponSubmit';
34
- export * from './components/orders/ItemContainer';
35
32
  export * from './components/line_items/LineItem';
36
33
  export * from './components/line_items/LineItemAmount';
37
34
  export * from './components/line_items/LineItemCode';
@@ -44,12 +41,26 @@ export * from './components/line_items/LineItemRemoveLink';
44
41
  export * from './components/line_items/LineItemsContainer';
45
42
  export * from './components/line_items/LineItemsCount';
46
43
  export * from './components/line_items/LineItemsEmpty';
47
- export * from './components/MetadataInput';
44
+ export * from './components/orders/AddToCartButton';
45
+ export * from './components/orders/AdjustmentAmount';
46
+ export * from './components/orders/CartLink';
47
+ export * from './components/orders/CheckoutLink';
48
+ export * from './components/orders/DiscountAmount';
49
+ export * from './components/orders/GiftCardAmount';
50
+ export * from './components/orders/ItemContainer';
48
51
  export * from './components/orders/OrderContainer';
49
- export * from './components/orders/OrderNumber';
50
- export * from './components/orders/OrderStorage';
51
52
  export * from './components/orders/OrderList';
53
+ export * from './components/orders/OrderListEmpty';
52
54
  export * from './components/orders/OrderListRow';
55
+ export * from './components/orders/OrderNumber';
56
+ export * from './components/orders/OrderStorage';
57
+ export * from './components/orders/PlaceOrderButton';
58
+ export * from './components/orders/PlaceOrderContainer';
59
+ export * from './components/orders/PrivacyAndTermsCheckbox';
60
+ export * from './components/orders/ShippingAmount';
61
+ export * from './components/orders/SubTotalAmount';
62
+ export * from './components/orders/TaxesAmount';
63
+ export * from './components/orders/TotalAmount';
53
64
  export * from './components/payment_methods/PaymentMethod';
54
65
  export * from './components/payment_methods/PaymentMethodAmount';
55
66
  export * from './components/payment_methods/PaymentMethodName';
@@ -61,24 +72,19 @@ export * from './components/payment_source/PaymentSourceBrandIcon';
61
72
  export * from './components/payment_source/PaymentSourceBrandName';
62
73
  export * from './components/payment_source/PaymentSourceDetail';
63
74
  export * from './components/payment_source/PaymentSourceEditButton';
64
- export * from './components/orders/PlaceOrderButton';
65
- export * from './components/orders/PlaceOrderContainer';
66
75
  export * from './components/prices/Price';
67
76
  export * from './components/prices/PricesContainer';
68
- export * from './components/orders/PrivacyAndTermsCheckbox';
69
- export * from './components/skus/QuantitySelector';
70
- export * from './components/addresses/SaveAddressesButton';
71
- export * from './components/customers/SaveCustomerButton';
72
77
  export * from './components/shipments/Shipment';
73
78
  export * from './components/shipments/ShipmentField';
74
79
  export * from './components/shipments/ShipmentsContainer';
75
- export * from './components/addresses/ShippingAddressContainer';
76
- export * from './components/addresses/ShippingAddressForm';
77
- export * from './components/orders/ShippingAmount';
78
80
  export * from './components/shipping_methods/ShippingMethod';
79
81
  export * from './components/shipping_methods/ShippingMethodName';
80
82
  export * from './components/shipping_methods/ShippingMethodPrice';
81
83
  export * from './components/shipping_methods/ShippingMethodRadioButton';
84
+ export * from './components/skus/AvailabilityContainer';
85
+ export * from './components/skus/AvailabilityTemplate';
86
+ export * from './components/skus/DeliveryLeadTime';
87
+ export * from './components/skus/QuantitySelector';
82
88
  export * from './components/skus/SkuField';
83
89
  export * from './components/skus/SkuList';
84
90
  export * from './components/skus/SkuListsContainer';
@@ -87,21 +93,17 @@ export * from './components/skus/SkuOptionInput';
87
93
  export * from './components/skus/SkuOptionsContainer';
88
94
  export * from './components/skus/Skus';
89
95
  export * from './components/skus/SkusContainer';
90
- export * from './components/stock_transfers/StockTransfer';
91
- export * from './components/stock_transfers/StockTransferField';
92
- export * from './components/orders/SubTotalAmount';
93
- export * from './components/SubmitButton';
94
- export * from './components/orders/TaxesAmount';
95
- export * from './components/orders/TotalAmount';
96
96
  export * from './components/skus/VariantSelector';
97
97
  export * from './components/skus/VariantsContainer';
98
+ export * from './components/stock_transfers/StockTransfer';
99
+ export * from './components/stock_transfers/StockTransferField';
98
100
  export type { CustomerCardsType } from './components/utils/PaymentCardsTemplate';
99
101
  export type { AddressCardsType } from './components/utils/AddressCardsTemplate';
100
102
  export type { AddToCartButtonType } from './components/orders/AddToCartButton';
101
- export type { ShippingMethodRadioButtonType, ShippingMethodRadioButtonOnChangeType, } from './components/shipping_methods/ShippingMethodRadioButton';
103
+ export type { ShippingMethodRadioButtonType, ShippingMethodRadioButtonOnChangeType } from './components/shipping_methods/ShippingMethodRadioButton';
102
104
  export type { LineItemCodeType } from './components/line_items/LineItemCode';
103
105
  export type { LineItemNameType } from './components/line_items/LineItemName';
104
106
  export type { LineItemImageType } from './components/line_items/LineItemImage';
105
107
  export type { LineItemType } from './typings/index';
106
108
  export type { ErrorComponentProps, ResourceErrorType } from './typings/errors';
107
- export type { AddressCountrySelectName, AddressInputName, AddressStateSelectName, BaseInputType, } from './typings/index';
109
+ export type { AddressCountrySelectName, AddressInputName, AddressStateSelectName, BaseInputType } from './typings/index';
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/orders/AddToCartButton"),exports),tslib_1.__exportStar(require("./components/addresses/AddressCountrySelector"),exports),tslib_1.__exportStar(require("./components/addresses/Address"),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/BillingAddressContainer"),exports),tslib_1.__exportStar(require("./components/addresses/BillingAddressForm"),exports),tslib_1.__exportStar(require("./components/orders/AdjustmentAmount"),exports),tslib_1.__exportStar(require("./components/skus/AvailabilityContainer"),exports),tslib_1.__exportStar(require("./components/skus/AvailabilityTemplate"),exports),tslib_1.__exportStar(require("./components/orders/CartLink"),exports),tslib_1.__exportStar(require("./components/orders/CheckoutLink"),exports),tslib_1.__exportStar(require("./components/auth/CommerceLayer"),exports),tslib_1.__exportStar(require("./components/customers/CustomerContainer"),exports),tslib_1.__exportStar(require("./components/customers/CustomerField"),exports),tslib_1.__exportStar(require("./components/customers/CustomerAddressForm"),exports),tslib_1.__exportStar(require("./components/customers/CustomerInput"),exports),tslib_1.__exportStar(require("./components/skus/DeliveryLeadTime"),exports),tslib_1.__exportStar(require("./components/orders/DiscountAmount"),exports),tslib_1.__exportStar(require("./components/Errors"),exports),tslib_1.__exportStar(require("./components/ExternalFunction"),exports),tslib_1.__exportStar(require("./components/gift_cards/GiftCard"),exports),tslib_1.__exportStar(require("./components/orders/GiftCardAmount"),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/orders/ItemContainer"),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/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/LineItemsContainer"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemsCount"),exports),tslib_1.__exportStar(require("./components/line_items/LineItemsEmpty"),exports),tslib_1.__exportStar(require("./components/MetadataInput"),exports),tslib_1.__exportStar(require("./components/orders/OrderContainer"),exports),tslib_1.__exportStar(require("./components/orders/OrderNumber"),exports),tslib_1.__exportStar(require("./components/orders/OrderStorage"),exports),tslib_1.__exportStar(require("./components/orders/OrderList"),exports),tslib_1.__exportStar(require("./components/orders/OrderListRow"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethod"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodAmount"),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/orders/PlaceOrderButton"),exports),tslib_1.__exportStar(require("./components/orders/PlaceOrderContainer"),exports),tslib_1.__exportStar(require("./components/prices/Price"),exports),tslib_1.__exportStar(require("./components/prices/PricesContainer"),exports),tslib_1.__exportStar(require("./components/orders/PrivacyAndTermsCheckbox"),exports),tslib_1.__exportStar(require("./components/skus/QuantitySelector"),exports),tslib_1.__exportStar(require("./components/addresses/SaveAddressesButton"),exports),tslib_1.__exportStar(require("./components/customers/SaveCustomerButton"),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/addresses/ShippingAddressContainer"),exports),tslib_1.__exportStar(require("./components/addresses/ShippingAddressForm"),exports),tslib_1.__exportStar(require("./components/orders/ShippingAmount"),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/SkuField"),exports),tslib_1.__exportStar(require("./components/skus/SkuList"),exports),tslib_1.__exportStar(require("./components/skus/SkuListsContainer"),exports),tslib_1.__exportStar(require("./components/skus/SkuOption"),exports),tslib_1.__exportStar(require("./components/skus/SkuOptionInput"),exports),tslib_1.__exportStar(require("./components/skus/SkuOptionsContainer"),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),tslib_1.__exportStar(require("./components/orders/SubTotalAmount"),exports),tslib_1.__exportStar(require("./components/SubmitButton"),exports),tslib_1.__exportStar(require("./components/orders/TaxesAmount"),exports),tslib_1.__exportStar(require("./components/orders/TotalAmount"),exports),tslib_1.__exportStar(require("./components/skus/VariantSelector"),exports),tslib_1.__exportStar(require("./components/skus/VariantsContainer"),exports);
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/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/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/LineItemsContainer"),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/ItemContainer"),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/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/payment_methods/PaymentMethod"),exports),tslib_1.__exportStar(require("./components/payment_methods/PaymentMethodAmount"),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/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/QuantitySelector"),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/SkuOption"),exports),tslib_1.__exportStar(require("./components/skus/SkuOptionInput"),exports),tslib_1.__exportStar(require("./components/skus/SkuOptionsContainer"),exports),tslib_1.__exportStar(require("./components/skus/Skus"),exports),tslib_1.__exportStar(require("./components/skus/SkusContainer"),exports),tslib_1.__exportStar(require("./components/skus/VariantSelector"),exports),tslib_1.__exportStar(require("./components/skus/VariantsContainer"),exports),tslib_1.__exportStar(require("./components/stock_transfers/StockTransfer"),exports),tslib_1.__exportStar(require("./components/stock_transfers/StockTransferField"),exports);
@@ -25,33 +25,27 @@ export interface AddressAction {
25
25
  payload: Partial<AddressActionPayload>;
26
26
  }
27
27
  export declare const addressInitialState: AddressState;
28
- export interface SetAddressErrors {
29
- <V extends BaseError[]>(args: {
30
- errors: V;
31
- resource: Extract<ResourceErrorType, 'billing_address' | 'shipping_address'>;
32
- dispatch?: Dispatch<AddressAction>;
33
- currentErrors?: V;
34
- }): void;
35
- }
36
- export declare type SetAddressParams<V extends AddressSchema> = {
28
+ export declare type SetAddressErrors = <V extends BaseError[]>(args: {
29
+ errors: V;
30
+ resource: Extract<ResourceErrorType, 'billing_address' | 'shipping_address'>;
31
+ dispatch?: Dispatch<AddressAction>;
32
+ currentErrors?: V;
33
+ }) => void;
34
+ export interface SetAddressParams<V extends AddressSchema> {
37
35
  values: V;
38
36
  resource: AddressResource;
39
37
  dispatch?: Dispatch<AddressAction>;
40
- };
41
- export interface SetAddress {
42
- <V extends AddressSchema>(params: SetAddressParams<V>): void;
43
- }
44
- export interface SaveAddresses {
45
- (params: {
46
- orderId?: string;
47
- order?: Order | null;
48
- updateOrder?: typeof updateOrder;
49
- config: CommerceLayerConfig;
50
- state: AddressState;
51
- dispatch: Dispatch<AddressAction>;
52
- getCustomerAddresses?: () => Promise<void>;
53
- }): Promise<void>;
54
38
  }
39
+ export declare type SetAddress = <V extends AddressSchema>(params: SetAddressParams<V>) => void;
40
+ export declare type SaveAddresses = (params: {
41
+ orderId?: string;
42
+ order?: Order | null;
43
+ updateOrder?: typeof updateOrder;
44
+ config: CommerceLayerConfig;
45
+ state: AddressState;
46
+ dispatch: Dispatch<AddressAction>;
47
+ getCustomerAddresses?: () => Promise<void>;
48
+ }) => Promise<void>;
55
49
  export declare const setAddressErrors: SetAddressErrors;
56
50
  export declare const setAddress: SetAddress;
57
51
  declare type SetCloneAddress = (id: string, resource: AddressResource, dispatch: Dispatch<AddressAction>) => void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.saveAddresses=exports.setCloneAddress=exports.setAddress=exports.setAddressErrors=exports.addressInitialState=exports.addressFields=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),camelCase_1=tslib_1.__importDefault(require("lodash/camelCase"));exports.addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],exports.addressInitialState={errors:[]};const 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}})};exports.setAddressErrors=setAddressErrors;const setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})};exports.setAddress=setAddress;const setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${(0,camelCase_1.default)(resource)}Id`]:id}})};exports.setCloneAddress=setCloneAddress;const saveAddresses=async({config,updateOrder,order,state})=>{const{shipToDifferentAddress,billing_address,shipping_address,billingAddressId,shippingAddressId}=state;try{const sdk=(0,getSdk_1.default)(config);if(order){const currentBillingAddressRef=order?.billing_address?.reference,orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId};if(currentBillingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),!(0,isEmpty_1.default)(billing_address)&&billing_address){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(billing_address);orderAttributes.billing_address=sdk.addresses.relationship(address.id)}if(shipToDifferentAddress&&(delete orderAttributes._shipping_address_same_as_billing,shippingAddressId&&(orderAttributes._shipping_address_clone_id=shippingAddressId),!(0,isEmpty_1.default)(shipping_address)&&shipping_address)){delete orderAttributes._shipping_address_clone_id;const address=await sdk.addresses.create(shipping_address);orderAttributes.shipping_address=sdk.addresses.relationship(address.id)}!(0,isEmpty_1.default)(orderAttributes)&&updateOrder&&await updateOrder({id:order.id,attributes:orderAttributes})}}catch(error){console.error(error)}};exports.saveAddresses=saveAddresses;const type=["setErrors","setAddress","setShipToDifferentAddress","setCloneAddress","cleanup"],addressReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=addressReducer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.saveAddresses=exports.setCloneAddress=exports.setAddress=exports.setAddressErrors=exports.addressInitialState=exports.addressFields=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),camelCase_1=tslib_1.__importDefault(require("lodash/camelCase"));exports.addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],exports.addressInitialState={errors:[]};const 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}})};exports.setAddressErrors=setAddressErrors;const setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})};exports.setAddress=setAddress;const setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${(0,camelCase_1.default)(resource)}Id`]:id}})};exports.setCloneAddress=setCloneAddress;const saveAddresses=async({config,updateOrder,order,state})=>{const{shipToDifferentAddress,billing_address:billingAddress,shipping_address:shippingAddress,billingAddressId,shippingAddressId}=state;try{const sdk=(0,getSdk_1.default)(config);if(order){const currentBillingAddressRef=order?.billing_address?.reference,orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId};if(currentBillingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),!(0,isEmpty_1.default)(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),!(0,isEmpty_1.default)(shippingAddress)&&shippingAddress)){delete orderAttributes._shipping_address_clone_id;const address=await sdk.addresses.create(shippingAddress);orderAttributes.shipping_address=sdk.addresses.relationship(address.id)}!(0,isEmpty_1.default)(orderAttributes)&&updateOrder&&await updateOrder({id:order.id,attributes:orderAttributes})}}catch(error){console.error(error)}};exports.saveAddresses=saveAddresses;const type=["setErrors","setAddress","setShipToDifferentAddress","setCloneAddress","cleanup"],addressReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=addressReducer;
@@ -4,15 +4,15 @@ import type { Address, AddressCreate, AddressUpdate, Customer, CustomerPaymentSo
4
4
  import { CommerceLayerConfig } from '../context/CommerceLayerContext';
5
5
  import { updateOrder } from './OrderReducer';
6
6
  export declare type CustomerActionType = 'setErrors' | 'setCustomerEmail' | 'setAddresses' | 'setPayments' | 'setOrders';
7
- export declare type CustomerActionPayload = {
8
- addresses: Address[];
7
+ export interface CustomerActionPayload {
8
+ addresses: Address[] | null;
9
9
  payments: CustomerPaymentSource[];
10
10
  customerEmail: string;
11
11
  errors: BaseError[];
12
12
  orders: Order[];
13
13
  isGuest: boolean;
14
14
  customers: Customer;
15
- };
15
+ }
16
16
  export declare type CustomerState = Partial<CustomerActionPayload>;
17
17
  export interface CustomerAction {
18
18
  type: CustomerActionType;
@@ -22,7 +22,7 @@ export declare type SetSaveOnBlur = (args: {
22
22
  saveOnBlur: boolean;
23
23
  dispatch: Dispatch<CustomerAction>;
24
24
  }) => void;
25
- export declare type SaveCustomerUser = {
25
+ export interface SaveCustomerUser {
26
26
  /**
27
27
  * The Commerce Layer Config
28
28
  */
@@ -43,11 +43,9 @@ export declare type SaveCustomerUser = {
43
43
  * The function to update the order resource
44
44
  */
45
45
  updateOrder: typeof updateOrder;
46
- };
47
- export declare function saveCustomerUser({ customerEmail, order, updateOrder, }: SaveCustomerUser): Promise<void>;
48
- export interface SetCustomerErrors {
49
- <V extends BaseError[]>(errors: V, dispatch?: Dispatch<CustomerAction>): void;
50
46
  }
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;
51
49
  export declare function setCustomerErrors(
52
50
  /**
53
51
  * @param errors - An array of errors
@@ -66,7 +64,7 @@ customerEmail: string,
66
64
  * @param dispatch The dispatch function
67
65
  */
68
66
  dispatch?: Dispatch<CustomerAction>): void;
69
- export declare type GetCustomerAddresses = {
67
+ export interface GetCustomerAddresses {
70
68
  /**
71
69
  * The Commerce Layer config
72
70
  */
@@ -75,16 +73,16 @@ export declare type GetCustomerAddresses = {
75
73
  * The Customer dispatch function
76
74
  */
77
75
  dispatch: Dispatch<CustomerAction>;
78
- };
79
- export declare function getCustomerAddresses({ config, dispatch, }: GetCustomerAddresses): Promise<void>;
80
- export declare type DeleteCustomerAddress = {
76
+ }
77
+ export declare function getCustomerAddresses({ config, dispatch }: GetCustomerAddresses): Promise<void>;
78
+ export interface DeleteCustomerAddress {
81
79
  config?: CommerceLayerConfig;
82
80
  dispatch?: Dispatch<CustomerAction>;
83
81
  customerAddressId: string;
84
- addresses?: Address[];
85
- };
86
- export declare function deleteCustomerAddress({ config, dispatch, customerAddressId, addresses, }: DeleteCustomerAddress): Promise<void>;
87
- export declare type GetCustomerPaymentSources = {
82
+ addresses?: Address[] | null;
83
+ }
84
+ export declare function deleteCustomerAddress({ config, dispatch, customerAddressId, addresses }: DeleteCustomerAddress): Promise<void>;
85
+ export interface GetCustomerPaymentSources {
88
86
  /**
89
87
  * The Customer dispatch function
90
88
  */
@@ -93,7 +91,7 @@ export declare type GetCustomerPaymentSources = {
93
91
  * The Commerce Layer Order resource
94
92
  */
95
93
  order?: Order;
96
- };
94
+ }
97
95
  export declare function getCustomerPaymentSources(params?: GetCustomerPaymentSources): void;
98
96
  export declare type GetCustomerOrders = (params: {
99
97
  /**
@@ -107,7 +105,7 @@ export declare type GetCustomerOrders = (params: {
107
105
  }) => Promise<void>;
108
106
  export declare const getCustomerOrders: GetCustomerOrders;
109
107
  export declare type TCustomerAddress = AddressCreate & AddressUpdate;
110
- declare type TCreateCustomerAddress = {
108
+ interface TCreateCustomerAddress {
111
109
  /**
112
110
  * Customer address dispatch function
113
111
  */
@@ -124,8 +122,8 @@ declare type TCreateCustomerAddress = {
124
122
  * Current state of the customer
125
123
  */
126
124
  state?: CustomerState;
127
- };
128
- export declare function createCustomerAddress({ address, config, dispatch, state, }: TCreateCustomerAddress): Promise<void>;
125
+ }
126
+ export declare function createCustomerAddress({ address, config, dispatch, state }: TCreateCustomerAddress): Promise<void>;
129
127
  export declare const customerInitialState: CustomerState;
130
128
  declare const customerReducer: (state: CustomerState, reducer: CustomerAction) => CustomerState;
131
129
  export default customerReducer;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.customerInitialState=exports.createCustomerAddress=exports.getCustomerOrders=exports.getCustomerPaymentSources=exports.deleteCustomerAddress=exports.getCustomerAddresses=exports.setCustomerEmail=exports.setCustomerErrors=exports.saveCustomerUser=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),jwt_1=tslib_1.__importDefault(require("../utils/jwt"));async function saveCustomerUser({customerEmail,order,updateOrder}){if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}}exports.saveCustomerUser=saveCustomerUser;function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}exports.setCustomerErrors=setCustomerErrors;function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}exports.setCustomerEmail=setCustomerEmail;async function getCustomerAddresses({config,dispatch}){try{const addresses=[];(await(0,getSdk_1.default)(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&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=(0,getErrors_1.default)(error,"addresses");dispatch({type:"setErrors",payload:{errors}})}}exports.getCustomerAddresses=getCustomerAddresses;async function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){if(config&&addresses&&dispatch&&config)try{await(0,getSdk_1.default)(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")}}exports.deleteCustomerAddress=deleteCustomerAddress;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}})}}exports.getCustomerPaymentSources=getCustomerPaymentSources;const getCustomerOrders=async({config,dispatch})=>{if(config.accessToken){const{owner}=(0,jwt_1.default)(config.accessToken);if(owner?.id){const customers=await(0,getSdk_1.default)(config).customers.retrieve(owner.id,{include:["orders"]}),orders=customers.orders?.filter(order=>order.status!=="pending"&&order.status!=="draft");dispatch({type:"setOrders",payload:{orders,customers}})}}};exports.getCustomerOrders=getCustomerOrders;async function createCustomerAddress({address,config,dispatch,state}){if(config&&address){const sdk=(0,getSdk_1.default)(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")}}}exports.createCustomerAddress=createCustomerAddress,exports.customerInitialState={errors:[],addresses:[],payments:[],orders:[]};const type=["setErrors","setCustomerEmail","setAddresses","setPayments","setOrders"],customerReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=customerReducer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.customerInitialState=exports.createCustomerAddress=exports.getCustomerOrders=exports.getCustomerPaymentSources=exports.deleteCustomerAddress=exports.getCustomerAddresses=exports.setCustomerEmail=exports.setCustomerErrors=exports.saveCustomerUser=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors")),jwt_1=tslib_1.__importDefault(require("../utils/jwt"));async function saveCustomerUser({customerEmail,order,updateOrder}){if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}}exports.saveCustomerUser=saveCustomerUser;function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}exports.setCustomerErrors=setCustomerErrors;function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}exports.setCustomerEmail=setCustomerEmail;async function getCustomerAddresses({config,dispatch}){try{const addresses=[];(await(0,getSdk_1.default)(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&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=(0,getErrors_1.default)(error,"addresses");dispatch({type:"setErrors",payload:{errors}})}}exports.getCustomerAddresses=getCustomerAddresses;async function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){if(config&&addresses&&dispatch&&config)try{await(0,getSdk_1.default)(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")}}exports.deleteCustomerAddress=deleteCustomerAddress;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}})}}exports.getCustomerPaymentSources=getCustomerPaymentSources;const getCustomerOrders=async({config,dispatch})=>{if(config.accessToken){const{owner}=(0,jwt_1.default)(config.accessToken);if(owner?.id){const customers=await(0,getSdk_1.default)(config).customers.retrieve(owner.id,{include:["orders"]}),orders=customers.orders?.filter(order=>order.status!=="pending"&&order.status!=="draft");dispatch({type:"setOrders",payload:{orders,customers}})}}};exports.getCustomerOrders=getCustomerOrders;async function createCustomerAddress({address,config,dispatch,state}){if(config&&address){const sdk=(0,getSdk_1.default)(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")}}}exports.createCustomerAddress=createCustomerAddress,exports.customerInitialState={errors:[],addresses:null,payments:[]};const type=["setErrors","setCustomerEmail","setAddresses","setPayments","setOrders"],customerReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=customerReducer;
@@ -15,13 +15,9 @@ export declare type GetOrderParams = Partial<{
15
15
  persistKey: string;
16
16
  state: OrderState;
17
17
  }>;
18
- export interface GetOrder {
19
- (params: GetOrderParams): Promise<void | Order>;
20
- }
18
+ export declare type GetOrder = (params: GetOrderParams) => Promise<undefined | Order>;
21
19
  declare type CreateOrderParams = Pick<AddToCartParams, 'config' | 'dispatch' | 'persistKey' | 'state' | 'orderMetadata' | 'orderAttributes' | 'setLocalOrder'>;
22
- export interface CreateOrder {
23
- (params?: CreateOrderParams): Promise<string>;
24
- }
20
+ export declare type CreateOrder = (params?: CreateOrderParams) => Promise<string>;
25
21
  export declare type AddToCartParams = Partial<{
26
22
  bundleCode: string;
27
23
  skuCode: string;
@@ -47,16 +43,10 @@ export declare type AddToCartReturn = Promise<{
47
43
  success: boolean;
48
44
  orderId: string | undefined;
49
45
  }>;
50
- export interface AddToCart {
51
- (params: AddToCartParams): AddToCartReturn;
52
- }
53
- export interface AddToCartImport {
54
- (params: AddToCartImportParams): AddToCartReturn;
55
- }
56
- export interface UnsetOrderState {
57
- (dispatch: Dispatch<OrderActions>): void;
58
- }
59
- 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' | 'payment_source' | 'available_payment_methods' | 'payment_method';
46
+ export declare type AddToCart = (params: AddToCartParams) => AddToCartReturn;
47
+ export declare type AddToCartImport = (params: AddToCartImportParams) => AddToCartReturn;
48
+ export declare type UnsetOrderState = (dispatch: Dispatch<OrderActions>) => void;
49
+ 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' | 'payment_source' | 'available_payment_methods' | 'payment_method';
60
50
  declare type ResourceIncludedLoaded = Partial<Record<ResourceIncluded, boolean>>;
61
51
  export interface OrderPayload {
62
52
  loading?: boolean;
@@ -69,7 +59,7 @@ export interface OrderPayload {
69
59
  }
70
60
  export declare type AddToCartValues = Pick<AddToCartParams, 'bundleCode' | 'lineItem' | 'quantity' | 'skuCode' | 'skuId' | 'option' | 'buyNowMode' | 'checkoutUrl'>;
71
61
  export declare type AddToCartImportValues = Pick<AddToCartImportParams, 'lineItems'>;
72
- export declare type getOrderContext = (id: string) => Promise<void | Order>;
62
+ export declare type getOrderContext = (id: string) => Promise<undefined | Order>;
73
63
  export declare type OrderState = Partial<OrderPayload>;
74
64
  export interface OrderActions {
75
65
  type: OrderActionType;
@@ -78,36 +68,33 @@ export interface OrderActions {
78
68
  export declare type OrderActionType = 'setLoading' | 'setOrderId' | 'setOrder' | 'setSingleQuantity' | 'setCurrentSkuCodes' | 'setCurrentSkuPrices' | 'setCurrentItem' | 'setErrors' | 'setSaveAddressToCustomerAddressBook' | 'setGiftCardOrCouponCode' | 'setIncludesResource';
79
69
  export declare const createOrder: CreateOrder;
80
70
  export declare const getApiOrder: GetOrder;
81
- export declare type UpdateOrderArgs = {
71
+ export interface UpdateOrderArgs {
82
72
  id: string;
83
73
  attributes: Omit<OrderUpdate, 'id'>;
84
74
  dispatch?: Dispatch<OrderActions>;
85
75
  include?: string[];
86
76
  config?: CommerceLayerConfig;
87
77
  state?: OrderState;
88
- };
89
- export declare function updateOrder({ id, attributes, dispatch, config, include, state, }: UpdateOrderArgs): Promise<{
90
- success: boolean;
91
- error?: undefined;
92
- } | {
78
+ }
79
+ export declare function updateOrder({ id, attributes, dispatch, config, include, state }: UpdateOrderArgs): Promise<{
93
80
  success: boolean;
94
- error: unknown;
81
+ error?: unknown;
95
82
  }>;
96
83
  export declare const setOrder: (order: Order, dispatch?: Dispatch<OrderActions>) => void;
97
- export declare type AddResourceToInclude = {
84
+ export interface AddResourceToInclude {
98
85
  resourcesIncluded?: ResourceIncluded[];
99
86
  dispatch?: Dispatch<OrderActions>;
100
87
  newResource?: ResourceIncluded | ResourceIncluded[];
101
88
  resourceIncludedLoaded?: ResourceIncludedLoaded;
102
89
  newResourceLoaded?: ResourceIncludedLoaded;
103
- };
104
- export declare function addResourceToInclude({ resourcesIncluded, dispatch, newResource, newResourceLoaded, resourceIncludedLoaded, }: AddResourceToInclude): void;
90
+ }
91
+ export declare function addResourceToInclude({ resourcesIncluded, dispatch, newResource, newResourceLoaded, resourceIncludedLoaded }: AddResourceToInclude): void;
105
92
  export declare const addToCart: AddToCart;
106
93
  export declare const unsetOrderState: UnsetOrderState;
107
- declare type OrderErrors = {
94
+ interface OrderErrors {
108
95
  dispatch?: Dispatch<OrderActions>;
109
96
  errors: BaseError[];
110
- };
97
+ }
111
98
  export declare function setOrderErrors({ dispatch, errors }: OrderErrors): {
112
99
  success: boolean;
113
100
  };
@@ -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")),size_1=tslib_1.__importDefault(require("lodash/size")),map_1=tslib_1.__importDefault(require("lodash/map")),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"||order.status==="approved"||order.status==="cancelled"?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(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=>{payload.includeLoaded={...payload.includeLoaded,[resource]:!0}})}else delete payload.include;payload.includeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded},dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}exports.addResourceToInclude=addResourceToInclude;const addToCart=async params=>{const{skuCode,bundleCode,skuId,quantity,option,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl}=params;try{if(!config)throw{errors:[{code:"INVALID_RESOURCE",resource:"orders",title:"Markup error",message:"You are trying to place an order outside the OrderContainer component"}]};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}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});line_items&&line_items?.length>0&&await Promise.all(line_items.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};skuId&&(attrs.item=sdk.skus.relationship(skuId));const newLineItem=await sdk.line_items.create(attrs);if((0,isEmpty_1.default)(option))await(0,exports.getApiOrder)({id,...params,state});else{let c=0;(0,map_1.default)(option,async opt=>{const{options,skuOptionId}=opt,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),c+=1,c===(0,size_1.default)(option)&&await(0,exports.getApiOrder)({id,...params})})}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,orderId:void 0}}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,orderId:void 0}}};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}`;(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")),size_1=tslib_1.__importDefault(require("lodash/size")),map_1=tslib_1.__importDefault(require("lodash/map")),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"||order.status==="approved"||order.status==="cancelled"?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(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;const addToCart=async params=>{const{skuCode,bundleCode,skuId,quantity,option,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl}=params;try{if(!config)throw{errors:[{code:"INVALID_RESOURCE",resource:"orders",title:"Markup error",message:"You are trying to place an order outside the OrderContainer component"}]};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};skuId&&(attrs.item=sdk.skus.relationship(skuId));const newLineItem=await sdk.line_items.create(attrs);if((0,isEmpty_1.default)(option))await(0,exports.getApiOrder)({id,...params,state});else{let c=0;(0,map_1.default)(option,async opt=>{const{options,skuOptionId}=opt,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),c+=1,c===(0,size_1.default)(option)&&await(0,exports.getApiOrder)({id,...params})})}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,orderId:void 0}}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,orderId:void 0}}};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;
@@ -18,9 +18,7 @@ export interface ShipmentAction {
18
18
  payload: Partial<ShipmentActionPayload>;
19
19
  }
20
20
  export declare const shipmentInitialState: ShipmentState;
21
- export interface SetShipmentErrors {
22
- <V extends BaseError[]>(errors: V, dispatch?: Dispatch<ShipmentAction>): void;
23
- }
21
+ export declare type SetShipmentErrors = <V extends BaseError[]>(errors: V, dispatch?: Dispatch<ShipmentAction>) => void;
24
22
  export declare const setShipmentErrors: SetShipmentErrors;
25
23
  declare type GetShipments = (args: {
26
24
  order: Order;