@commercelayer/react-components 3.13.0-beta.1 → 3.13.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/lib/components/AddToCartButton.d.ts +27 -1
  2. package/lib/components/Address.d.ts +13 -1
  3. package/lib/components/AddressCountrySelector.d.ts +9 -1
  4. package/lib/components/AddressField.d.ts +15 -1
  5. package/lib/components/AddressInput.d.ts +7 -1
  6. package/lib/components/AddressStateSelector.d.ts +11 -1
  7. package/lib/components/AddressesContainer.d.ts +8 -1
  8. package/lib/components/AdjustmentAmount.d.ts +4 -1
  9. package/lib/components/AdyenPayment.d.ts +25 -1
  10. package/lib/components/AvailabilityContainer.d.ts +7 -1
  11. package/lib/components/AvailabilityTemplate.d.ts +15 -1
  12. package/lib/components/BillingAddressContainer.d.ts +6 -1
  13. package/lib/components/BillingAddressForm.d.ts +8 -1
  14. package/lib/components/BraintreePayment.d.ts +30 -1
  15. package/lib/components/CheckoutComPayment.d.ts +23 -1
  16. package/lib/components/CheckoutLink.d.ts +13 -1
  17. package/lib/components/CommerceLayer.d.ts +8 -1
  18. package/lib/components/CustomerContainer.d.ts +7 -1
  19. package/lib/components/CustomerInput.d.ts +11 -1
  20. package/lib/components/DeliveryLeadTime.d.ts +10 -1
  21. package/lib/components/DiscountAmount.d.ts +4 -1
  22. package/lib/components/Errors.d.ts +5 -1
  23. package/lib/components/ExternalFunction.d.ts +7 -1
  24. package/lib/components/GiftCard.d.ts +8 -1
  25. package/lib/components/GiftCardAmount.d.ts +4 -1
  26. package/lib/components/GiftCardContainer.d.ts +6 -1
  27. package/lib/components/GiftCardCurrencySelector.d.ts +7 -1
  28. package/lib/components/GiftCardInput.d.ts +7 -1
  29. package/lib/components/GiftCardOrCouponCode.d.ts +17 -1
  30. package/lib/components/GiftCardOrCouponCode.js +1 -1
  31. package/lib/components/GiftCardOrCouponForm.d.ts +10 -1
  32. package/lib/components/GiftCardOrCouponInput.d.ts +10 -1
  33. package/lib/components/GiftCardOrCouponRemoveButton.d.ts +18 -1
  34. package/lib/components/GiftCardOrCouponSubmit.d.ts +9 -1
  35. package/lib/components/ItemContainer.d.ts +11 -1
  36. package/lib/components/KlarnaPayment.d.ts +9 -1
  37. package/lib/components/LineItem.d.ts +8 -1
  38. package/lib/components/LineItem.js +1 -1
  39. package/lib/components/LineItemAmount.d.ts +7 -1
  40. package/lib/components/LineItemCode.d.ts +12 -1
  41. package/lib/components/LineItemImage.d.ts +16 -1
  42. package/lib/components/LineItemImage.js +1 -1
  43. package/lib/components/LineItemName.d.ts +11 -1
  44. package/lib/components/LineItemOption.d.ts +19 -1
  45. package/lib/components/LineItemOptions.d.ts +16 -1
  46. package/lib/components/LineItemQuantity.d.ts +14 -1
  47. package/lib/components/LineItemRemoveLink.d.ts +12 -1
  48. package/lib/components/LineItemsContainer.d.ts +8 -1
  49. package/lib/components/LineItemsCount.d.ts +12 -1
  50. package/lib/components/LineItemsEmpty.d.ts +12 -1
  51. package/lib/components/MetadataInput.d.ts +5 -1
  52. package/lib/components/OrderContainer.d.ts +12 -1
  53. package/lib/components/OrderNumber.d.ts +5 -1
  54. package/lib/components/OrderStorage.d.ts +8 -1
  55. package/lib/components/PaymentGateway.d.ts +16 -1
  56. package/lib/components/PaymentMethod.d.ts +16 -1
  57. package/lib/components/PaymentMethodAmount.d.ts +4 -1
  58. package/lib/components/PaymentMethodName.d.ts +9 -1
  59. package/lib/components/PaymentMethodPrice.d.ts +9 -1
  60. package/lib/components/PaymentMethodRadioButton.d.ts +12 -1
  61. package/lib/components/PaymentMethodsContainer.d.ts +8 -1
  62. package/lib/components/PaymentSource.d.ts +19 -1
  63. package/lib/components/PaymentSourceBrandIcon.d.ts +15 -1
  64. package/lib/components/PaymentSourceBrandName.d.ts +12 -1
  65. package/lib/components/PaymentSourceDetail.d.ts +12 -1
  66. package/lib/components/PaymentSourceEditButton.d.ts +9 -1
  67. package/lib/components/PaypalPayment.d.ts +12 -1
  68. package/lib/components/PlaceOrderButton.d.ts +14 -1
  69. package/lib/components/PlaceOrderContainer.d.ts +8 -1
  70. package/lib/components/Price.d.ts +16 -1
  71. package/lib/components/PricesContainer.d.ts +11 -1
  72. package/lib/components/PrivacyAndTermsCheckbox.d.ts +4 -1
  73. package/lib/components/QuantitySelector.d.ts +17 -1
  74. package/lib/components/SaveAddressesButton.d.ts +10 -1
  75. package/lib/components/SaveCustomerButton.d.ts +13 -1
  76. package/lib/components/Shipment.d.ts +15 -1
  77. package/lib/components/Shipment.js +1 -1
  78. package/lib/components/ShipmentField.d.ts +12 -1
  79. package/lib/components/ShipmentsContainer.d.ts +6 -1
  80. package/lib/components/ShipmentsContainer.js +1 -1
  81. package/lib/components/ShippingAddressContainer.d.ts +6 -1
  82. package/lib/components/ShippingAddressForm.d.ts +8 -1
  83. package/lib/components/ShippingAmount.d.ts +4 -1
  84. package/lib/components/ShippingMethod.d.ts +8 -1
  85. package/lib/components/ShippingMethodName.d.ts +11 -1
  86. package/lib/components/ShippingMethodPrice.d.ts +13 -1
  87. package/lib/components/ShippingMethodRadioButton.d.ts +13 -1
  88. package/lib/components/ShippingMethodRadioButton.js +1 -1
  89. package/lib/components/SkuField.d.ts +9 -1
  90. package/lib/components/SkuList.d.ts +7 -1
  91. package/lib/components/SkuListsContainer.d.ts +6 -1
  92. package/lib/components/SkuOption.d.ts +7 -1
  93. package/lib/components/SkuOptionInput.d.ts +5 -1
  94. package/lib/components/SkuOptionsContainer.d.ts +7 -1
  95. package/lib/components/Skus.d.ts +11 -1
  96. package/lib/components/SkusContainer.d.ts +14 -1
  97. package/lib/components/StockTransfer.d.ts +6 -1
  98. package/lib/components/StockTransfer.js +1 -1
  99. package/lib/components/StockTransferField.d.ts +9 -1
  100. package/lib/components/StripePayment.d.ts +18 -1
  101. package/lib/components/SubTotalAmount.d.ts +4 -1
  102. package/lib/components/SubmitButton.d.ts +9 -1
  103. package/lib/components/TaxesAmount.d.ts +4 -1
  104. package/lib/components/TotalAmount.d.ts +4 -1
  105. package/lib/components/VariantSelector.d.ts +29 -1
  106. package/lib/components/VariantsContainer.d.ts +8 -1
  107. package/lib/components/WireTransferPayment.d.ts +10 -1
  108. package/lib/components/gateways/AdyenGateway.d.ts +4 -1
  109. package/lib/components/gateways/BraintreeGateway.d.ts +4 -1
  110. package/lib/components/gateways/CheckoutComGateway.d.ts +4 -1
  111. package/lib/components/gateways/KlarnaGateway.d.ts +4 -1
  112. package/lib/components/gateways/PaypalGateway.d.ts +4 -1
  113. package/lib/components/gateways/StripeGateway.d.ts +4 -1
  114. package/lib/components/gateways/WireTransferGateway.d.ts +4 -1
  115. package/lib/components/utils/AddressCardsTemplate.d.ts +26 -1
  116. package/lib/components/utils/BaseField.d.ts +8 -1
  117. package/lib/components/utils/BaseInput.d.ts +5 -1
  118. package/lib/components/utils/BaseInput.js +1 -1
  119. package/lib/components/utils/BaseOrderPrice.d.ts +6 -1
  120. package/lib/components/utils/BaseSelect.d.ts +5 -1
  121. package/lib/components/utils/GenericFieldComponent.d.ts +37 -1
  122. package/lib/components/utils/GenericFieldComponent.js +1 -1
  123. package/lib/components/utils/Parent.d.ts +6 -1
  124. package/lib/components/utils/Parent.js +1 -1
  125. package/lib/components/utils/PaymentCardsTemplate.d.ts +22 -1
  126. package/lib/components/utils/PriceTemplate.d.ts +8 -1
  127. package/lib/components/utils/VariantTemplate.d.ts +36 -1
  128. package/lib/components/utils/getAllErrors.d.ts +17 -1
  129. package/lib/config/components.d.ts +913 -1
  130. package/lib/config/currency.d.ts +5 -1
  131. package/lib/context/AddressChildrenContext.d.ts +6 -1
  132. package/lib/context/AddressContext.d.ts +16 -1
  133. package/lib/context/AvailabilityContext.d.ts +2 -1
  134. package/lib/context/BillingAddressContext.d.ts +11 -1
  135. package/lib/context/BillingAddressFormContext.d.ts +19 -1
  136. package/lib/context/CommerceLayerContext.d.ts +6 -1
  137. package/lib/context/CouponAndGiftCardFormContext.d.ts +9 -1
  138. package/lib/context/CustomerContext.d.ts +15 -1
  139. package/lib/context/ExternalFunctionContext.d.ts +11 -1
  140. package/lib/context/GiftCardContext.d.ts +10 -1
  141. package/lib/context/ItemContext.d.ts +12 -1
  142. package/lib/context/LineItemChildrenContext.d.ts +8 -1
  143. package/lib/context/LineItemContext.d.ts +7 -1
  144. package/lib/context/LineItemOptionChildrenContext.d.ts +7 -1
  145. package/lib/context/OrderContext.d.ts +29 -1
  146. package/lib/context/OrderStorageContext.d.ts +10 -1
  147. package/lib/context/PaymentMethodChildrenContext.d.ts +9 -1
  148. package/lib/context/PaymentMethodContext.d.ts +22 -1
  149. package/lib/context/PaymentSourceContext.d.ts +13 -1
  150. package/lib/context/PlaceOrderContext.d.ts +17 -1
  151. package/lib/context/PricesContext.d.ts +6 -1
  152. package/lib/context/ShipmentChildrenContext.d.ts +12 -1
  153. package/lib/context/ShipmentContext.d.ts +11 -1
  154. package/lib/context/ShippingAddressContext.d.ts +9 -1
  155. package/lib/context/ShippingAddressFormContext.d.ts +3 -1
  156. package/lib/context/ShippingMethodChildrenContext.d.ts +9 -1
  157. package/lib/context/SkuChildrenContext.d.ts +8 -1
  158. package/lib/context/SkuContext.d.ts +8 -1
  159. package/lib/context/SkuListsContext.d.ts +5 -1
  160. package/lib/context/SkuOptionChildrenContext.d.ts +7 -1
  161. package/lib/context/SkuOptionsContext.d.ts +2 -1
  162. package/lib/context/StockTransferChildrenContext.d.ts +6 -1
  163. package/lib/context/VariantsContext.d.ts +2 -1
  164. package/lib/index.d.ts +102 -1
  165. package/lib/reducers/AddressReducer.d.ts +59 -1
  166. package/lib/reducers/AvailabilityReducer.d.ts +61 -1
  167. package/lib/reducers/BillingAddressReducer.d.ts +31 -1
  168. package/lib/reducers/CustomerReducer.d.ts +50 -1
  169. package/lib/reducers/GiftCardReducer.d.ts +76 -1
  170. package/lib/reducers/ItemReducer.d.ts +69 -1
  171. package/lib/reducers/LineItemReducer.d.ts +52 -1
  172. package/lib/reducers/OrderReducer.d.ts +132 -2
  173. package/lib/reducers/PaymentMethodReducer.d.ts +151 -1
  174. package/lib/reducers/PlaceOrderReducer.d.ts +59 -1
  175. package/lib/reducers/PriceReducer.d.ts +44 -1
  176. package/lib/reducers/ShipmentReducer.d.ts +40 -1
  177. package/lib/reducers/ShippingAddressReducer.d.ts +32 -1
  178. package/lib/reducers/SkuListsReducer.d.ts +21 -1
  179. package/lib/reducers/SkuOptionsReducer.d.ts +26 -1
  180. package/lib/reducers/SkuReducer.d.ts +21 -1
  181. package/lib/reducers/VariantReducer.d.ts +71 -1
  182. package/lib/typings/errors.d.ts +42 -1
  183. package/lib/typings/index.d.ts +137 -1
  184. package/lib/utils/PropsType.d.ts +33 -1
  185. package/lib/utils/addressesManager.d.ts +28 -1
  186. package/lib/utils/baseReducer.d.ts +3 -1
  187. package/lib/utils/browserInfo.d.ts +9 -1
  188. package/lib/utils/checkIncludeResource.d.ts +8 -1
  189. package/lib/utils/childrenTypes.d.ts +9 -1
  190. package/lib/utils/compareObjAttribute.d.ts +7 -1
  191. package/lib/utils/countryStateCity.d.ts +9 -1
  192. package/lib/utils/customMessages.d.ts +8 -1
  193. package/lib/utils/customerOrderOptions.d.ts +3 -1
  194. package/lib/utils/getAmount.d.ts +9 -1
  195. package/lib/utils/getCardDetails.d.ts +15 -1
  196. package/lib/utils/getCurrentItemKey.d.ts +6 -1
  197. package/lib/utils/getErrors.d.ts +11 -1
  198. package/lib/utils/getLineItemsCount.d.ts +12 -1
  199. package/lib/utils/getLoaderComponent.d.ts +2 -1
  200. package/lib/utils/getPrices.d.ts +17 -1
  201. package/lib/utils/getSdk.d.ts +3 -1
  202. package/lib/utils/getSkus.d.ts +3 -1
  203. package/lib/utils/hooks/useExternalScript.d.ts +1 -1
  204. package/lib/utils/isEmptyStates.d.ts +1 -1
  205. package/lib/utils/isJSON.d.ts +1 -1
  206. package/lib/utils/jwt.d.ts +27 -1
  207. package/lib/utils/localStorage.d.ts +17 -1
  208. package/lib/utils/organization.d.ts +6 -1
  209. package/lib/utils/paypalPayment.d.ts +3 -1
  210. package/lib/utils/placeholderImages.d.ts +2 -0
  211. package/lib/utils/placeholderImages.js +1 -0
  212. package/lib/utils/promisify.d.ts +1 -1
  213. package/lib/utils/shipments.d.ts +3 -1
  214. package/lib/utils/validateFormFields.d.ts +22 -1
  215. package/package.json +2 -2
@@ -1 +1,151 @@
1
- import{AdyenPaymentConfig}from'../components/AdyenPayment';import{BraintreeConfig}from'../components/BraintreePayment';import{PaypalConfig}from'../components/PaypalPayment';import{StripeConfig}from'../components/StripePayment';import{WireTransferConfig}from'../components/WireTransferPayment';import{CommerceLayerConfig}from'../context/CommerceLayerContext';import{getOrderContext,updateOrder}from'./OrderReducer';import{BaseError}from'../typings/errors';import{Order,PaymentMethod,StripePayment,WireTransfer,AdyenPayment,BraintreePayment,CheckoutComPayment,ExternalPayment,PaypalPayment,KlarnaPayment}from'@commercelayer/sdk';import{Dispatch,MutableRefObject}from'react';import{CheckoutComConfig}from'../components/CheckoutComPayment';export declare type PaymentSourceType=AdyenPayment|BraintreePayment|CheckoutComPayment|ExternalPayment|PaypalPayment|StripePayment|WireTransfer;declare type Card={brand:string;last4:string;exp_year:number;exp_month:number;};export declare type PaymentSourceObject={adyen_payments:AdyenPayment&{payment_request_data?:{payment_method?:Card;};payment_response?:{resultCode?:'Authorised';};};braintree_payments:BraintreePayment&{options?:{card:Card;};};external_payments:ExternalPayment&{payment_source_token?:string;};paypal_payments:PaypalPayment;stripe_payments:StripePayment&{options?:{card:Card;};};wire_transfers:WireTransfer;checkout_com_payments:CheckoutComPayment&{payment_response:{source?:Pick<Card,'last4'>&{scheme:string;expiry_year:number;expiry_month:number;};};};klarna_payments:KlarnaPayment;};export declare type PaymentMethodActionType='setErrors'|'setPaymentMethods'|'setPaymentMethodConfig'|'setPaymentSource'|'setPaymentRef'|'setLoading';export declare type PaymentRef=MutableRefObject<null|HTMLFormElement>;export interface PaymentMethodActionPayload{errors:BaseError[];paymentMethods:PaymentMethod[];currentPaymentMethodType:PaymentResource;currentPaymentMethodId:string;currentPaymentMethodRef:PaymentRef;config:PaymentMethodConfig;paymentSource:PaymentSourceTypes;loading:boolean;}export declare function setLoading({loading,dispatch,}:{loading:boolean;dispatch?:Dispatch<PaymentMethodAction>;}):void;export declare type SetPaymentRef=(args:{ref:PaymentRef;dispatch?:Dispatch<PaymentMethodAction>;})=>void;export declare const setPaymentRef:SetPaymentRef;export declare type PaymentMethodState=Partial<PaymentMethodActionPayload>;export interface PaymentMethodAction{type:PaymentMethodActionType;payload:Partial<PaymentMethodActionPayload>;}export declare const paymentMethodInitialState:PaymentMethodState;export interface SetPaymentMethodErrors{<V extends BaseError[]>(errors:V,dispatch?:Dispatch<PaymentMethodAction>):void;}export declare const setPaymentMethodErrors:SetPaymentMethodErrors;declare type GetPaymentMethods=(args:{order:Order;dispatch:Dispatch<PaymentMethodAction>;})=>Promise<void>;export declare const getPaymentMethods:GetPaymentMethods;export declare type PaymentResource=keyof PaymentSourceObject;export declare type PaymentResourceKey='braintreePayment'|'stripePayment'|'klarnaPayment'|'wireTransfer'|'paypalPayment'|'adyenPayment'|'checkoutComPayment';export declare type SDKPaymentResource='AdyenPayment'|'BraintreePayment'|'ExternalPayment'|'PaypalPayment'|'StripePayment'|'WireTransfer'|'CheckoutComPayment';export declare type SetPaymentMethod=(args:{config?:CommerceLayerConfig;dispatch?:Dispatch<PaymentMethodAction>;updateOrder?:typeof updateOrder;setOrderErrors?:(collection:any)=>{success:boolean;};order?:Order;paymentMethodId:string;paymentResource?:PaymentResource;})=>Promise<void>;export declare const setPaymentMethod:SetPaymentMethod;declare type PaymentSourceTypes=(StripePayment&WireTransfer)|(StripePayment|WireTransfer);export declare type SetPaymentSourceResponse={order:Order;paymentSource:PaymentSourceTypes;}|null;export declare type SetPaymentSource=(args:{config?:CommerceLayerConfig;dispatch?:Dispatch<PaymentMethodAction>;getOrder?:getOrderContext;attributes?:Record<string,unknown>;order?:Order;paymentResource:PaymentResource;paymentSourceId?:string;customerPaymentSourceId?:string;updateOrder?:typeof updateOrder;}&PaymentMethodState)=>Promise<PaymentSourceType|void>;export declare const setPaymentSource:SetPaymentSource;export declare type UpdatePaymentSource=(args:{id:string;attributes:Record<string,any>;paymentResource:PaymentResource;config?:CommerceLayerConfig;dispatch?:Dispatch<PaymentMethodAction>;})=>Promise<void>;export declare const updatePaymentSource:UpdatePaymentSource;export declare type DestroyPaymentSource=(args:{paymentSourceId:string;paymentResource:PaymentResource;dispatch?:Dispatch<PaymentMethodAction>;updateOrder?:typeof updateOrder;orderId?:string;})=>Promise<void>;export declare const destroyPaymentSource:DestroyPaymentSource;export declare type PaymentMethodConfig={stripePayment?:StripeConfig;braintreePayment?:BraintreeConfig;wireTransfer?:Partial<WireTransferConfig>;paypalPayment?:PaypalConfig;adyenPayment?:AdyenPaymentConfig;checkoutComPayment?:CheckoutComConfig;klarnaPayment?:Pick<AdyenPaymentConfig,'placeOrderCallback'>&Pick<StripeConfig,'containerClassName'>;};declare type SetPaymentMethodConfig=(config:PaymentMethodConfig,dispatch:Dispatch<PaymentMethodAction>)=>void;export declare const setPaymentMethodConfig:SetPaymentMethodConfig;export declare function getPaymentConfig<K extends PaymentResourceKey>(paymentResource:PaymentResource,config:PaymentMethodConfig):PaymentMethodConfig[K];declare const paymentMethodReducer:(state:PaymentMethodState,reducer:PaymentMethodAction)=>PaymentMethodState;export default paymentMethodReducer;
1
+ import { AdyenPaymentConfig } from '../components/AdyenPayment';
2
+ import { BraintreeConfig } from '../components/BraintreePayment';
3
+ import { PaypalConfig } from '../components/PaypalPayment';
4
+ import { StripeConfig } from '../components/StripePayment';
5
+ import { WireTransferConfig } from '../components/WireTransferPayment';
6
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
7
+ import { getOrderContext, updateOrder } from './OrderReducer';
8
+ import { BaseError } from '../typings/errors';
9
+ import { Order, PaymentMethod, StripePayment, WireTransfer, AdyenPayment, BraintreePayment, CheckoutComPayment, ExternalPayment, PaypalPayment, KlarnaPayment } from '@commercelayer/sdk';
10
+ import { Dispatch, MutableRefObject } from 'react';
11
+ import { CheckoutComConfig } from '../components/CheckoutComPayment';
12
+ export declare type PaymentSourceType = AdyenPayment | BraintreePayment | CheckoutComPayment | ExternalPayment | PaypalPayment | StripePayment | WireTransfer;
13
+ declare type Card = {
14
+ brand: string;
15
+ last4: string;
16
+ exp_year: number;
17
+ exp_month: number;
18
+ };
19
+ export declare type PaymentSourceObject = {
20
+ adyen_payments: AdyenPayment & {
21
+ payment_request_data?: {
22
+ payment_method?: Card;
23
+ };
24
+ payment_response?: {
25
+ resultCode?: 'Authorised';
26
+ };
27
+ };
28
+ braintree_payments: BraintreePayment & {
29
+ options?: {
30
+ card: Card;
31
+ };
32
+ };
33
+ external_payments: ExternalPayment & {
34
+ payment_source_token?: string;
35
+ };
36
+ paypal_payments: PaypalPayment;
37
+ stripe_payments: StripePayment & {
38
+ options?: {
39
+ card: Card;
40
+ };
41
+ };
42
+ wire_transfers: WireTransfer;
43
+ checkout_com_payments: CheckoutComPayment & {
44
+ payment_response: {
45
+ source?: Pick<Card, 'last4'> & {
46
+ scheme: string;
47
+ expiry_year: number;
48
+ expiry_month: number;
49
+ };
50
+ };
51
+ };
52
+ klarna_payments: KlarnaPayment;
53
+ };
54
+ export declare type PaymentMethodActionType = 'setErrors' | 'setPaymentMethods' | 'setPaymentMethodConfig' | 'setPaymentSource' | 'setPaymentRef' | 'setLoading';
55
+ export declare type PaymentRef = MutableRefObject<null | HTMLFormElement>;
56
+ export interface PaymentMethodActionPayload {
57
+ errors: BaseError[];
58
+ paymentMethods: PaymentMethod[];
59
+ currentPaymentMethodType: PaymentResource;
60
+ currentPaymentMethodId: string;
61
+ currentPaymentMethodRef: PaymentRef;
62
+ config: PaymentMethodConfig;
63
+ paymentSource: PaymentSourceTypes;
64
+ loading: boolean;
65
+ }
66
+ export declare function setLoading({ loading, dispatch, }: {
67
+ loading: boolean;
68
+ dispatch?: Dispatch<PaymentMethodAction>;
69
+ }): void;
70
+ export declare type SetPaymentRef = (args: {
71
+ ref: PaymentRef;
72
+ dispatch?: Dispatch<PaymentMethodAction>;
73
+ }) => void;
74
+ export declare const setPaymentRef: SetPaymentRef;
75
+ export declare type PaymentMethodState = Partial<PaymentMethodActionPayload>;
76
+ export interface PaymentMethodAction {
77
+ type: PaymentMethodActionType;
78
+ payload: Partial<PaymentMethodActionPayload>;
79
+ }
80
+ export declare const paymentMethodInitialState: PaymentMethodState;
81
+ export interface SetPaymentMethodErrors {
82
+ <V extends BaseError[]>(errors: V, dispatch?: Dispatch<PaymentMethodAction>): void;
83
+ }
84
+ export declare const setPaymentMethodErrors: SetPaymentMethodErrors;
85
+ declare type GetPaymentMethods = (args: {
86
+ order: Order;
87
+ dispatch: Dispatch<PaymentMethodAction>;
88
+ }) => Promise<void>;
89
+ export declare const getPaymentMethods: GetPaymentMethods;
90
+ export declare type PaymentResource = keyof PaymentSourceObject;
91
+ export declare type PaymentResourceKey = 'braintreePayment' | 'stripePayment' | 'klarnaPayment' | 'wireTransfer' | 'paypalPayment' | 'adyenPayment' | 'checkoutComPayment';
92
+ export declare type SDKPaymentResource = 'AdyenPayment' | 'BraintreePayment' | 'ExternalPayment' | 'PaypalPayment' | 'StripePayment' | 'WireTransfer' | 'CheckoutComPayment';
93
+ export declare type SetPaymentMethod = (args: {
94
+ config?: CommerceLayerConfig;
95
+ dispatch?: Dispatch<PaymentMethodAction>;
96
+ updateOrder?: typeof updateOrder;
97
+ setOrderErrors?: (collection: any) => {
98
+ success: boolean;
99
+ };
100
+ order?: Order;
101
+ paymentMethodId: string;
102
+ paymentResource?: PaymentResource;
103
+ }) => Promise<void>;
104
+ export declare const setPaymentMethod: SetPaymentMethod;
105
+ declare type PaymentSourceTypes = (StripePayment & WireTransfer) | (StripePayment | WireTransfer);
106
+ export declare type SetPaymentSourceResponse = {
107
+ order: Order;
108
+ paymentSource: PaymentSourceTypes;
109
+ } | null;
110
+ export declare type SetPaymentSource = (args: {
111
+ config?: CommerceLayerConfig;
112
+ dispatch?: Dispatch<PaymentMethodAction>;
113
+ getOrder?: getOrderContext;
114
+ attributes?: Record<string, unknown>;
115
+ order?: Order;
116
+ paymentResource: PaymentResource;
117
+ paymentSourceId?: string;
118
+ customerPaymentSourceId?: string;
119
+ updateOrder?: typeof updateOrder;
120
+ } & PaymentMethodState) => Promise<PaymentSourceType | void>;
121
+ export declare const setPaymentSource: SetPaymentSource;
122
+ export declare type UpdatePaymentSource = (args: {
123
+ id: string;
124
+ attributes: Record<string, any>;
125
+ paymentResource: PaymentResource;
126
+ config?: CommerceLayerConfig;
127
+ dispatch?: Dispatch<PaymentMethodAction>;
128
+ }) => Promise<void>;
129
+ export declare const updatePaymentSource: UpdatePaymentSource;
130
+ export declare type DestroyPaymentSource = (args: {
131
+ paymentSourceId: string;
132
+ paymentResource: PaymentResource;
133
+ dispatch?: Dispatch<PaymentMethodAction>;
134
+ updateOrder?: typeof updateOrder;
135
+ orderId?: string;
136
+ }) => Promise<void>;
137
+ export declare const destroyPaymentSource: DestroyPaymentSource;
138
+ export declare type PaymentMethodConfig = {
139
+ stripePayment?: StripeConfig;
140
+ braintreePayment?: BraintreeConfig;
141
+ wireTransfer?: Partial<WireTransferConfig>;
142
+ paypalPayment?: PaypalConfig;
143
+ adyenPayment?: AdyenPaymentConfig;
144
+ checkoutComPayment?: CheckoutComConfig;
145
+ klarnaPayment?: Pick<AdyenPaymentConfig, 'placeOrderCallback'> & Pick<StripeConfig, 'containerClassName'>;
146
+ };
147
+ declare type SetPaymentMethodConfig = (config: PaymentMethodConfig, dispatch: Dispatch<PaymentMethodAction>) => void;
148
+ export declare const setPaymentMethodConfig: SetPaymentMethodConfig;
149
+ export declare function getPaymentConfig<K extends PaymentResourceKey>(paymentResource: PaymentResource, config: PaymentMethodConfig): PaymentMethodConfig[K];
150
+ declare const paymentMethodReducer: (state: PaymentMethodState, reducer: PaymentMethodAction) => PaymentMethodState;
151
+ export default paymentMethodReducer;
@@ -1 +1,59 @@
1
- import{Dispatch}from'react';import{BaseError}from'../typings/errors';import{CommerceLayerConfig}from'../context/CommerceLayerContext';import{Order}from'@commercelayer/sdk';import{PaymentResource}from'./PaymentMethodReducer';import{PaymentSourceType}from'./PaymentMethodReducer';export declare type PlaceOrderActionType='setErrors'|'setPlaceOrderPermitted';export declare type PlaceOrderOptions={paypalPayerId?:string;adyen?:{MD:string;PaRes:string;};checkoutCom?:{session_id:string;};};export interface PlaceOrderActionPayload{errors:BaseError[];isPermitted:boolean;paymentType:PaymentResource;paymentSecret:string;paymentId:string;paymentSource:PaymentSourceType;options?:PlaceOrderOptions;}export declare type PlaceOrderState=Partial<PlaceOrderActionPayload>;export interface PlaceOrderAction{type:PlaceOrderActionType;payload:Partial<PlaceOrderActionPayload>;}export declare const placeOrderInitialState:PlaceOrderState;export interface SetPlaceOrderErrors{<V extends BaseError[]>(errors:V,dispatch?:Dispatch<PlaceOrderAction>):void;}export declare const setPlaceOrderErrors:SetPlaceOrderErrors;declare type PlaceOrderPermitted=(args:{config?:CommerceLayerConfig;dispatch:Dispatch<PlaceOrderAction>;order?:Order;options?:PlaceOrderOptions;})=>void;export declare const placeOrderPermitted:PlaceOrderPermitted;export declare type SetPlaceOrder=(args:{config?:CommerceLayerConfig;order?:Order;state?:PlaceOrderState;setOrderErrors?:(errors:BaseError[])=>void;paymentSource?:PaymentSourceType&{approval_url?:string;};include?:string[];setOrder?:(order:Order)=>void;})=>Promise<{placed:boolean;}>;export declare const setPlaceOrder:SetPlaceOrder;declare const placeOrderReducer:(state:PlaceOrderState,reducer:PlaceOrderAction)=>PlaceOrderState;export default placeOrderReducer;
1
+ import { Dispatch } from 'react';
2
+ import { BaseError } from '../typings/errors';
3
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
4
+ import { Order } from '@commercelayer/sdk';
5
+ import { PaymentResource } from './PaymentMethodReducer';
6
+ import { PaymentSourceType } from './PaymentMethodReducer';
7
+ export declare type PlaceOrderActionType = 'setErrors' | 'setPlaceOrderPermitted';
8
+ export declare type PlaceOrderOptions = {
9
+ paypalPayerId?: string;
10
+ adyen?: {
11
+ MD: string;
12
+ PaRes: string;
13
+ };
14
+ checkoutCom?: {
15
+ session_id: string;
16
+ };
17
+ };
18
+ export interface PlaceOrderActionPayload {
19
+ errors: BaseError[];
20
+ isPermitted: boolean;
21
+ paymentType: PaymentResource;
22
+ paymentSecret: string;
23
+ paymentId: string;
24
+ paymentSource: PaymentSourceType;
25
+ options?: PlaceOrderOptions;
26
+ }
27
+ export declare type PlaceOrderState = Partial<PlaceOrderActionPayload>;
28
+ export interface PlaceOrderAction {
29
+ type: PlaceOrderActionType;
30
+ payload: Partial<PlaceOrderActionPayload>;
31
+ }
32
+ export declare const placeOrderInitialState: PlaceOrderState;
33
+ export interface SetPlaceOrderErrors {
34
+ <V extends BaseError[]>(errors: V, dispatch?: Dispatch<PlaceOrderAction>): void;
35
+ }
36
+ export declare const setPlaceOrderErrors: SetPlaceOrderErrors;
37
+ declare type PlaceOrderPermitted = (args: {
38
+ config?: CommerceLayerConfig;
39
+ dispatch: Dispatch<PlaceOrderAction>;
40
+ order?: Order;
41
+ options?: PlaceOrderOptions;
42
+ }) => void;
43
+ export declare const placeOrderPermitted: PlaceOrderPermitted;
44
+ export declare type SetPlaceOrder = (args: {
45
+ config?: CommerceLayerConfig;
46
+ order?: Order;
47
+ state?: PlaceOrderState;
48
+ setOrderErrors?: (errors: BaseError[]) => void;
49
+ paymentSource?: PaymentSourceType & {
50
+ approval_url?: string;
51
+ };
52
+ include?: string[];
53
+ setOrder?: (order: Order) => void;
54
+ }) => Promise<{
55
+ placed: boolean;
56
+ }>;
57
+ export declare const setPlaceOrder: SetPlaceOrder;
58
+ declare const placeOrderReducer: (state: PlaceOrderState, reducer: PlaceOrderAction) => PlaceOrderState;
59
+ export default placeOrderReducer;
@@ -1 +1,44 @@
1
- import{BaseAction,LoaderType}from'../typings/index';import{Price}from'@commercelayer/sdk';import{CommerceLayerConfig}from'../context/CommerceLayerContext';import{Dispatch}from'react';import{ItemPrices}from'./ItemReducer';import{BaseError}from'../typings/errors';export interface Prices{[key:string]:Price|Price[];}declare type SkuCodesPrice=string[];export interface SetSkuCodesPrice{(skuCodes:SkuCodesPrice):void;}export interface PriceState{loading:boolean;prices:Prices;skuCodes:SkuCodesPrice;errors?:BaseError[];skuCode?:string;setSkuCodes?:SetSkuCodesPrice;loader?:LoaderType;}export interface PriceAction extends BaseAction{type:PriceActionType;}export declare const priceInitialState:PriceState;export interface GetSkusPrice{(skuCodes:SkuCodesPrice,options:{config:CommerceLayerConfig;dispatch:Dispatch<PriceAction>;setPrices:((item:ItemPrices)=>void)|undefined;prices:ItemPrices;perPage:number;filters:Record<string,any>;}):void;}export declare const getSkusPrice:GetSkusPrice;export interface UnsetPriceState{(dispatch:Dispatch<PriceAction>):void;}export declare const unsetPriceState:UnsetPriceState;export declare type PriceActionType='setLoading'|'setPrices'|'setSkuCodes'|'setErrors';declare const priceReducer:(state:PriceState,reducer:PriceAction)=>PriceState;export default priceReducer;
1
+ import { BaseAction, LoaderType } from '../typings/index';
2
+ import { Price } from '@commercelayer/sdk';
3
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
4
+ import { Dispatch } from 'react';
5
+ import { ItemPrices } from './ItemReducer';
6
+ import { BaseError } from '../typings/errors';
7
+ export interface Prices {
8
+ [key: string]: Price | Price[];
9
+ }
10
+ declare type SkuCodesPrice = string[];
11
+ export interface SetSkuCodesPrice {
12
+ (skuCodes: SkuCodesPrice): void;
13
+ }
14
+ export interface PriceState {
15
+ loading: boolean;
16
+ prices: Prices;
17
+ skuCodes: SkuCodesPrice;
18
+ errors?: BaseError[];
19
+ skuCode?: string;
20
+ setSkuCodes?: SetSkuCodesPrice;
21
+ loader?: LoaderType;
22
+ }
23
+ export interface PriceAction extends BaseAction {
24
+ type: PriceActionType;
25
+ }
26
+ export declare const priceInitialState: PriceState;
27
+ export interface GetSkusPrice {
28
+ (skuCodes: SkuCodesPrice, options: {
29
+ config: CommerceLayerConfig;
30
+ dispatch: Dispatch<PriceAction>;
31
+ setPrices: ((item: ItemPrices) => void) | undefined;
32
+ prices: ItemPrices;
33
+ perPage: number;
34
+ filters: Record<string, any>;
35
+ }): void;
36
+ }
37
+ export declare const getSkusPrice: GetSkusPrice;
38
+ export interface UnsetPriceState {
39
+ (dispatch: Dispatch<PriceAction>): void;
40
+ }
41
+ export declare const unsetPriceState: UnsetPriceState;
42
+ export declare type PriceActionType = 'setLoading' | 'setPrices' | 'setSkuCodes' | 'setErrors';
43
+ declare const priceReducer: (state: PriceState, reducer: PriceAction) => PriceState;
44
+ export default priceReducer;
@@ -1 +1,40 @@
1
- import{Dispatch}from'react';import{BaseError}from'../typings/errors';import{DeliveryLeadTime,LineItem,Order,Shipment}from'@commercelayer/sdk';import{CommerceLayerConfig}from'../context/CommerceLayerContext';import{getOrderContext}from'./OrderReducer';export declare type ShipmentActionType='setErrors'|'setShipments'|'setShippingMethod';export declare type ShipmentLineItem=LineItem&{line_item:LineItem;};export interface ShipmentActionPayload{errors:BaseError[];shipments:Shipment[];deliveryLeadTimes:DeliveryLeadTime[];}export declare type ShipmentState=Partial<ShipmentActionPayload>;export interface ShipmentAction{type:ShipmentActionType;payload:Partial<ShipmentActionPayload>;}export declare const shipmentInitialState:ShipmentState;export interface SetShipmentErrors{<V extends BaseError[]>(errors:V,dispatch?:Dispatch<ShipmentAction>):void;}export declare const setShipmentErrors:SetShipmentErrors;declare type GetShipments=(args:{order:Order;dispatch:Dispatch<ShipmentAction>;config:CommerceLayerConfig;})=>Promise<void>;export declare const getShipments:GetShipments;declare type SetShippingMethod=(args:{config:CommerceLayerConfig;shipmentId:string;shippingMethodId:string;order?:Order;getOrder?:getOrderContext;})=>Promise<void>;export declare const setShippingMethod:SetShippingMethod;declare const shipmentReducer:(state:ShipmentState,reducer:ShipmentAction)=>ShipmentState;export default shipmentReducer;
1
+ import { Dispatch } from 'react';
2
+ import { BaseError } from '../typings/errors';
3
+ import { DeliveryLeadTime, LineItem, Order, Shipment } from '@commercelayer/sdk';
4
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
5
+ import { getOrderContext } from './OrderReducer';
6
+ export declare type ShipmentActionType = 'setErrors' | 'setShipments' | 'setShippingMethod';
7
+ export declare type ShipmentLineItem = LineItem & {
8
+ line_item: LineItem;
9
+ };
10
+ export interface ShipmentActionPayload {
11
+ errors: BaseError[];
12
+ shipments: Shipment[];
13
+ deliveryLeadTimes: DeliveryLeadTime[];
14
+ }
15
+ export declare type ShipmentState = Partial<ShipmentActionPayload>;
16
+ export interface ShipmentAction {
17
+ type: ShipmentActionType;
18
+ payload: Partial<ShipmentActionPayload>;
19
+ }
20
+ export declare const shipmentInitialState: ShipmentState;
21
+ export interface SetShipmentErrors {
22
+ <V extends BaseError[]>(errors: V, dispatch?: Dispatch<ShipmentAction>): void;
23
+ }
24
+ export declare const setShipmentErrors: SetShipmentErrors;
25
+ declare type GetShipments = (args: {
26
+ order: Order;
27
+ dispatch: Dispatch<ShipmentAction>;
28
+ config: CommerceLayerConfig;
29
+ }) => Promise<void>;
30
+ export declare const getShipments: GetShipments;
31
+ declare type SetShippingMethod = (args: {
32
+ config: CommerceLayerConfig;
33
+ shipmentId: string;
34
+ shippingMethodId: string;
35
+ order?: Order;
36
+ getOrder?: getOrderContext;
37
+ }) => Promise<void>;
38
+ export declare const setShippingMethod: SetShippingMethod;
39
+ declare const shipmentReducer: (state: ShipmentState, reducer: ShipmentAction) => ShipmentState;
40
+ export default shipmentReducer;
@@ -1 +1,32 @@
1
- import{Dispatch}from'react';import{CommerceLayerConfig}from'../context/CommerceLayerContext';import{Order}from'@commercelayer/sdk';import{getOrderContext}from'./OrderReducer';import{AddressResource}from'./AddressReducer';export declare type ShippingAddressActionType='setShippingAddress'|'setShippingCustomerAddressId'|'cleanup';export interface ShippingAddressActionPayload{_shipping_address_clone_id:string;shippingCustomerAddressId:string;}export declare type ShippingAddressState=Partial<ShippingAddressActionPayload>;export interface ShippingAddressAction{type:ShippingAddressActionType;payload:Partial<ShippingAddressActionPayload>;}export declare const shippingAddressInitialState:ShippingAddressState;export declare type SetShippingAddress=(id:string,options?:{config:CommerceLayerConfig;dispatch:Dispatch<ShippingAddressAction>;order?:Order|null;getOrder?:getOrderContext;customerAddressId?:string;})=>Promise<void>;export declare const setShippingAddress:SetShippingAddress;declare type SetShippingCustomerAddressId=(args:{dispatch:Dispatch<ShippingAddressAction>;order:Order;setCloneAddress:(id:string,resource:AddressResource)=>void;})=>void;export declare const setShippingCustomerAddressId:SetShippingCustomerAddressId;declare const shippingAddressReducer:(state:ShippingAddressState,reducer:ShippingAddressAction)=>ShippingAddressState;export default shippingAddressReducer;
1
+ import { Dispatch } from 'react';
2
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
3
+ import { Order } from '@commercelayer/sdk';
4
+ import { getOrderContext } from './OrderReducer';
5
+ import { AddressResource } from './AddressReducer';
6
+ export declare type ShippingAddressActionType = 'setShippingAddress' | 'setShippingCustomerAddressId' | 'cleanup';
7
+ export interface ShippingAddressActionPayload {
8
+ _shipping_address_clone_id: string;
9
+ shippingCustomerAddressId: string;
10
+ }
11
+ export declare type ShippingAddressState = Partial<ShippingAddressActionPayload>;
12
+ export interface ShippingAddressAction {
13
+ type: ShippingAddressActionType;
14
+ payload: Partial<ShippingAddressActionPayload>;
15
+ }
16
+ export declare const shippingAddressInitialState: ShippingAddressState;
17
+ export declare type SetShippingAddress = (id: string, options?: {
18
+ config: CommerceLayerConfig;
19
+ dispatch: Dispatch<ShippingAddressAction>;
20
+ order?: Order | null;
21
+ getOrder?: getOrderContext;
22
+ customerAddressId?: string;
23
+ }) => Promise<void>;
24
+ export declare const setShippingAddress: SetShippingAddress;
25
+ declare type SetShippingCustomerAddressId = (args: {
26
+ dispatch: Dispatch<ShippingAddressAction>;
27
+ order: Order;
28
+ setCloneAddress: (id: string, resource: AddressResource) => void;
29
+ }) => void;
30
+ export declare const setShippingCustomerAddressId: SetShippingCustomerAddressId;
31
+ declare const shippingAddressReducer: (state: ShippingAddressState, reducer: ShippingAddressAction) => ShippingAddressState;
32
+ export default shippingAddressReducer;
@@ -1 +1,21 @@
1
- import{Dispatch}from'react';import{CommerceLayerConfig}from'../context/CommerceLayerContext';declare type SkuListsActionType='getSkuList'|'setSkuList';export declare type SkuListsState=Partial<{listIds:string[];skuLists:Record<string,any>;}>;export declare const skuListsInitialState:SkuListsState;export interface SkuListsAction{payload:Partial<SkuListsState>;type:SkuListsActionType;}export declare type GetSkuList=(params:{config:CommerceLayerConfig;dispatch:Dispatch<SkuListsAction>;listIds:string[];state:SkuListsState;})=>Promise<void>;export declare const getSkuList:GetSkuList;declare const skuListsReducer:(state:SkuListsState,reducer:SkuListsAction)=>SkuListsState;export default skuListsReducer;
1
+ import { Dispatch } from 'react';
2
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
3
+ declare type SkuListsActionType = 'getSkuList' | 'setSkuList';
4
+ export declare type SkuListsState = Partial<{
5
+ listIds: string[];
6
+ skuLists: Record<string, any>;
7
+ }>;
8
+ export declare const skuListsInitialState: SkuListsState;
9
+ export interface SkuListsAction {
10
+ payload: Partial<SkuListsState>;
11
+ type: SkuListsActionType;
12
+ }
13
+ export declare type GetSkuList = (params: {
14
+ config: CommerceLayerConfig;
15
+ dispatch: Dispatch<SkuListsAction>;
16
+ listIds: string[];
17
+ state: SkuListsState;
18
+ }) => Promise<void>;
19
+ export declare const getSkuList: GetSkuList;
20
+ declare const skuListsReducer: (state: SkuListsState, reducer: SkuListsAction) => SkuListsState;
21
+ export default skuListsReducer;
@@ -1 +1,26 @@
1
- import{Dispatch}from'react';import{SkuOption}from'@commercelayer/sdk';import{BaseUnsetState}from'../typings/index';import{BaseError}from'../typings/errors';export interface SkuOptionsState{skuCode?:string;skuOptions?:SkuOption[];errors?:BaseError[];}interface GetSkuOptionsParams{dispatch:Dispatch<SkuOptionsAction>;skuOptions?:SkuOption[];}export interface GetSkuOptions{(params:GetSkuOptionsParams):void;}export declare const getSkuOptions:GetSkuOptions;export declare const unsetSkuOptionsState:BaseUnsetState<SkuOptionsAction>;export declare type SkuOptionsActionType='setSkuOptions'|'setErrors';export interface SkuOptionsAction{type:SkuOptionsActionType;payload:SkuOptionsState;}export declare const skuOptionsInitialState:SkuOptionsState;declare const skuOptionsReducer:(state:SkuOptionsState,reducer:SkuOptionsAction)=>SkuOptionsState;export default skuOptionsReducer;
1
+ import { Dispatch } from 'react';
2
+ import { SkuOption } from '@commercelayer/sdk';
3
+ import { BaseUnsetState } from '../typings/index';
4
+ import { BaseError } from '../typings/errors';
5
+ export interface SkuOptionsState {
6
+ skuCode?: string;
7
+ skuOptions?: SkuOption[];
8
+ errors?: BaseError[];
9
+ }
10
+ interface GetSkuOptionsParams {
11
+ dispatch: Dispatch<SkuOptionsAction>;
12
+ skuOptions?: SkuOption[];
13
+ }
14
+ export interface GetSkuOptions {
15
+ (params: GetSkuOptionsParams): void;
16
+ }
17
+ export declare const getSkuOptions: GetSkuOptions;
18
+ export declare const unsetSkuOptionsState: BaseUnsetState<SkuOptionsAction>;
19
+ export declare type SkuOptionsActionType = 'setSkuOptions' | 'setErrors';
20
+ export interface SkuOptionsAction {
21
+ type: SkuOptionsActionType;
22
+ payload: SkuOptionsState;
23
+ }
24
+ export declare const skuOptionsInitialState: SkuOptionsState;
25
+ declare const skuOptionsReducer: (state: SkuOptionsState, reducer: SkuOptionsAction) => SkuOptionsState;
26
+ export default skuOptionsReducer;
@@ -1 +1,21 @@
1
- import{CommerceLayerConfig}from'../context/CommerceLayerContext';import{BaseAction}from'../typings/index';import{QueryParamsList,Sku}from'@commercelayer/sdk';import{Dispatch}from'react';declare type SkuActionType='getSkus'|'setLoading';declare type SkuAction=BaseAction<SkuActionType,SkuState>;export declare type SkuState=Partial<{skus:Sku[];loading:boolean;skuCodes:string[];}>;export declare const skuInitialState:SkuState;declare type GetSku={config:CommerceLayerConfig;skus:string[];dispatch:Dispatch<SkuAction>;queryParams?:QueryParamsList;};export declare function getSku<T extends GetSku>({config,skus,dispatch,queryParams,}:T):Promise<void>;export default function skuReducer(state:SkuState,reducer:SkuAction):SkuState;export{};
1
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
2
+ import { BaseAction } from '../typings/index';
3
+ import { QueryParamsList, Sku } from '@commercelayer/sdk';
4
+ import { Dispatch } from 'react';
5
+ declare type SkuActionType = 'getSkus' | 'setLoading';
6
+ declare type SkuAction = BaseAction<SkuActionType, SkuState>;
7
+ export declare type SkuState = Partial<{
8
+ skus: Sku[];
9
+ loading: boolean;
10
+ skuCodes: string[];
11
+ }>;
12
+ export declare const skuInitialState: SkuState;
13
+ declare type GetSku = {
14
+ config: CommerceLayerConfig;
15
+ skus: string[];
16
+ dispatch: Dispatch<SkuAction>;
17
+ queryParams?: QueryParamsList;
18
+ };
19
+ export declare function getSku<T extends GetSku>({ config, skus, dispatch, queryParams, }: T): Promise<void>;
20
+ export default function skuReducer(state: SkuState, reducer: SkuAction): SkuState;
21
+ export {};
@@ -1 +1,71 @@
1
- import{Sku}from'@commercelayer/sdk';import{VariantOption}from'../components/VariantSelector';import{Dispatch}from'react';import{CommerceLayerConfig}from'../context/CommerceLayerContext';import{Items,CustomLineItem,SetCustomLineItems}from'./ItemReducer';import{BaseError}from'../typings/errors';declare type SetSkuCodeVariantParams={code:string;id:string;config:CommerceLayerConfig;dispatch:Dispatch<VariantAction>;setItem:((item:Items)=>void)|undefined;};export interface SetSkuCodeVariant{(params:SetSkuCodeVariantParams):void;}declare type SetVariantSkuCodesParams={skuCodes:VariantOption[];dispatch:Dispatch<VariantAction>;setCustomLineItems?:SetCustomLineItems;};export interface SetVariantSkuCodes{(params:SetVariantSkuCodesParams):void;}export interface VariantsObject{[key:string]:Sku;}export declare type SetSkuCode=(code:string,id:string,lineItem?:CustomLineItem)=>void;export interface VariantPayload{loading?:boolean;variants?:VariantsObject|Record<string,any>;skuCodes?:string[];skuCode?:string;errors?:BaseError[];currentSkuId?:string;currentSkuInventory?:any;currentQuantity?:number;currentPrices?:Sku[];setSkuCode?:SetSkuCode;setSkuCodes?:(skuCodes:VariantOption[])=>void;}export interface VariantState extends VariantPayload{skuCodes:string[];variants:VariantsObject|Record<string,any>;}export interface VariantAction{type:VariantActionType;payload:VariantPayload;}export declare const setVariantSkuCodes:SetVariantSkuCodes;export interface UnsetVariantState{(dispatch:Dispatch<VariantAction>):void;}export declare const setSkuCode:SetSkuCodeVariant;declare type GetVariantsParams={config:CommerceLayerConfig;state:VariantState;skuCode:string;dispatch:Dispatch<VariantAction>;filters:Record<string,any>;setItem:((item:Items)=>void)|undefined;};export interface GetVariants{(params:GetVariantsParams):void;}export declare const getVariants:GetVariants;export declare const unsetVariantState:UnsetVariantState;export declare const variantInitialState:VariantState;export declare type VariantActionType='setLoading'|'setVariants'|'setSkuCodes'|'setSkuCode'|'setCurrentSkuId'|'setCurrentSkuInventory'|'setCurrentPrices'|'setErrors';declare const variantReducer:(state:VariantState,reducer:VariantAction)=>VariantState;export default variantReducer;
1
+ import { Sku } from '@commercelayer/sdk';
2
+ import { VariantOption } from '../components/VariantSelector';
3
+ import { Dispatch } from 'react';
4
+ import { CommerceLayerConfig } from '../context/CommerceLayerContext';
5
+ import { Items, CustomLineItem, SetCustomLineItems } from './ItemReducer';
6
+ import { BaseError } from '../typings/errors';
7
+ declare type SetSkuCodeVariantParams = {
8
+ code: string;
9
+ id: string;
10
+ config: CommerceLayerConfig;
11
+ dispatch: Dispatch<VariantAction>;
12
+ setItem: ((item: Items) => void) | undefined;
13
+ };
14
+ export interface SetSkuCodeVariant {
15
+ (params: SetSkuCodeVariantParams): void;
16
+ }
17
+ declare type SetVariantSkuCodesParams = {
18
+ skuCodes: VariantOption[];
19
+ dispatch: Dispatch<VariantAction>;
20
+ setCustomLineItems?: SetCustomLineItems;
21
+ };
22
+ export interface SetVariantSkuCodes {
23
+ (params: SetVariantSkuCodesParams): void;
24
+ }
25
+ export interface VariantsObject {
26
+ [key: string]: Sku;
27
+ }
28
+ export declare type SetSkuCode = (code: string, id: string, lineItem?: CustomLineItem) => void;
29
+ export interface VariantPayload {
30
+ loading?: boolean;
31
+ variants?: VariantsObject | Record<string, any>;
32
+ skuCodes?: string[];
33
+ skuCode?: string;
34
+ errors?: BaseError[];
35
+ currentSkuId?: string;
36
+ currentSkuInventory?: any;
37
+ currentQuantity?: number;
38
+ currentPrices?: Sku[];
39
+ setSkuCode?: SetSkuCode;
40
+ setSkuCodes?: (skuCodes: VariantOption[]) => void;
41
+ }
42
+ export interface VariantState extends VariantPayload {
43
+ skuCodes: string[];
44
+ variants: VariantsObject | Record<string, any>;
45
+ }
46
+ export interface VariantAction {
47
+ type: VariantActionType;
48
+ payload: VariantPayload;
49
+ }
50
+ export declare const setVariantSkuCodes: SetVariantSkuCodes;
51
+ export interface UnsetVariantState {
52
+ (dispatch: Dispatch<VariantAction>): void;
53
+ }
54
+ export declare const setSkuCode: SetSkuCodeVariant;
55
+ declare type GetVariantsParams = {
56
+ config: CommerceLayerConfig;
57
+ state: VariantState;
58
+ skuCode: string;
59
+ dispatch: Dispatch<VariantAction>;
60
+ filters: Record<string, any>;
61
+ setItem: ((item: Items) => void) | undefined;
62
+ };
63
+ export interface GetVariants {
64
+ (params: GetVariantsParams): void;
65
+ }
66
+ export declare const getVariants: GetVariants;
67
+ export declare const unsetVariantState: UnsetVariantState;
68
+ export declare const variantInitialState: VariantState;
69
+ export declare type VariantActionType = 'setLoading' | 'setVariants' | 'setSkuCodes' | 'setSkuCode' | 'setCurrentSkuId' | 'setCurrentSkuInventory' | 'setCurrentPrices' | 'setErrors';
70
+ declare const variantReducer: (state: VariantState, reducer: VariantAction) => VariantState;
71
+ export default variantReducer;
@@ -1 +1,42 @@
1
- import PropTypes from'prop-types';import{FunctionChildren}from'./index';export declare type CodeErrorType='EMPTY_ERROR'|'FILTER_NOT_ALLOWED'|'FORBIDDEN'|'INTERNAL_SERVER_ERROR'|'INVALID_DATA_FORMAT'|'INVALID_FIELD'|'INVALID_FIELD_FORMAT'|'INVALID_FIELD_VALUE'|'INVALID_FILTERS_SYNTAX'|'INVALID_FILTER_VALUE'|'INVALID_INCLUDE'|'INVALID_LINKS_OBJECT'|'INVALID_PAGE_OBJECT'|'INVALID_PAGE_VALUE'|'INVALID_RESOURCE'|'INVALID_RESOURCE_ID'|'INVALID_SORT_CRITERIA'|'INVALID_TOKEN'|'KEY_NOT_INCLUDED_IN_URL'|'KEY_ORDER_MISMATCH'|'LOCKED'|'NOT_ACCEPTABLE'|'OUT_OF_STOCK'|'PARAM_MISSING'|'PARAM_NOT_ALLOWED'|'PAYMENT_NOT_APPROVED_FOR_EXECUTION'|'PAYMENT_INTENT_AUTHENTICATION_FAILURE'|'RECORD_NOT_FOUND'|'RECORD_NOT_FOUND'|'RELATION_EXISTS'|'NO_SHIPPING_METHODS'|'SAVE_FAILED'|'TYPE_MISMATCH'|'UNAUTHORIZED'|'UNSUPPORTED_MEDIA_TYPE'|'VALIDATION_ERROR';export declare type ResourceErrorType='addresses'|'billing_address'|'gift_cards'|'gift_card_or_coupon_code'|'line_items'|'orders'|'payment_methods'|'prices'|'shipments'|'shipping_address'|'sku_options'|'variant';export interface BaseError{code:CodeErrorType;message:string;resource?:ResourceErrorType|null;field?:string;id?:string;title?:string;detail?:string;}export declare const REType:ResourceErrorType[];export declare const BaseErrorObject:PropTypes.Requireable<PropTypes.InferProps<{code:PropTypes.Validator<CodeErrorType>;message:PropTypes.Validator<string>;resource:PropTypes.Requireable<ResourceErrorType>;field:PropTypes.Requireable<string>;id:PropTypes.Requireable<string>;}>>;export declare const ErrorPropTypes:{resource:PropTypes.Validator<ResourceErrorType>;children:PropTypes.Requireable<(...args:any[])=>any>;field:PropTypes.Requireable<string>;};declare type ErrorChildrenComponentProps=FunctionChildren<Omit<ErrorComponentProps,'children'>&{errors:string[];}>;export interface ErrorComponentProps{resource:ResourceErrorType;children?:ErrorChildrenComponentProps;field?:string;messages?:{code:CodeErrorType;message:string;resource?:ResourceErrorType;field?:string;id?:string;}[];}export{};
1
+ import PropTypes from 'prop-types';
2
+ import { FunctionChildren } from './index';
3
+ export declare type CodeErrorType = 'EMPTY_ERROR' | 'FILTER_NOT_ALLOWED' | 'FORBIDDEN' | 'INTERNAL_SERVER_ERROR' | 'INVALID_DATA_FORMAT' | 'INVALID_FIELD' | 'INVALID_FIELD_FORMAT' | 'INVALID_FIELD_VALUE' | 'INVALID_FILTERS_SYNTAX' | 'INVALID_FILTER_VALUE' | 'INVALID_INCLUDE' | 'INVALID_LINKS_OBJECT' | 'INVALID_PAGE_OBJECT' | 'INVALID_PAGE_VALUE' | 'INVALID_RESOURCE' | 'INVALID_RESOURCE_ID' | 'INVALID_SORT_CRITERIA' | 'INVALID_TOKEN' | 'KEY_NOT_INCLUDED_IN_URL' | 'KEY_ORDER_MISMATCH' | 'LOCKED' | 'NOT_ACCEPTABLE' | 'OUT_OF_STOCK' | 'PARAM_MISSING' | 'PARAM_NOT_ALLOWED' | 'PAYMENT_NOT_APPROVED_FOR_EXECUTION' | 'PAYMENT_INTENT_AUTHENTICATION_FAILURE' | 'RECORD_NOT_FOUND' | 'RECORD_NOT_FOUND' | 'RELATION_EXISTS' | 'NO_SHIPPING_METHODS' | 'SAVE_FAILED' | 'TYPE_MISMATCH' | 'UNAUTHORIZED' | 'UNSUPPORTED_MEDIA_TYPE' | 'VALIDATION_ERROR';
4
+ export declare type ResourceErrorType = 'addresses' | 'billing_address' | 'gift_cards' | 'gift_card_or_coupon_code' | 'line_items' | 'orders' | 'payment_methods' | 'prices' | 'shipments' | 'shipping_address' | 'sku_options' | 'variant';
5
+ export interface BaseError {
6
+ code: CodeErrorType;
7
+ message: string;
8
+ resource?: ResourceErrorType | null;
9
+ field?: string;
10
+ id?: string;
11
+ title?: string;
12
+ detail?: string;
13
+ }
14
+ export declare const REType: ResourceErrorType[];
15
+ export declare const BaseErrorObject: PropTypes.Requireable<PropTypes.InferProps<{
16
+ code: PropTypes.Validator<CodeErrorType>;
17
+ message: PropTypes.Validator<string>;
18
+ resource: PropTypes.Requireable<ResourceErrorType>;
19
+ field: PropTypes.Requireable<string>;
20
+ id: PropTypes.Requireable<string>;
21
+ }>>;
22
+ export declare const ErrorPropTypes: {
23
+ resource: PropTypes.Validator<ResourceErrorType>;
24
+ children: PropTypes.Requireable<(...args: any[]) => any>;
25
+ field: PropTypes.Requireable<string>;
26
+ };
27
+ declare type ErrorChildrenComponentProps = FunctionChildren<Omit<ErrorComponentProps, 'children'> & {
28
+ errors: string[];
29
+ }>;
30
+ export interface ErrorComponentProps {
31
+ resource: ResourceErrorType;
32
+ children?: ErrorChildrenComponentProps;
33
+ field?: string;
34
+ messages?: {
35
+ code: CodeErrorType;
36
+ message: string;
37
+ resource?: ResourceErrorType;
38
+ field?: string;
39
+ id?: string;
40
+ }[];
41
+ }
42
+ export {};