@commercelayer/react-components 2.53.3 → 3.0.0-alpha.1
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.
- package/LICENSE +2 -2
- package/README.md +3 -3
- package/lib/components/AdyenPayment.d.ts +3 -3
- package/lib/components/AdyenPayment.js +1 -1
- package/lib/components/AvailabilityContainer.d.ts +10 -3
- package/lib/components/AvailabilityContainer.js +1 -1
- package/lib/components/AvailabilityTemplate.d.ts +13 -4
- package/lib/components/AvailabilityTemplate.js +1 -1
- package/lib/components/BillingAddressContainer.d.ts +7 -2
- package/lib/components/BillingAddressContainer.js +1 -1
- package/lib/components/BillingAddressForm.d.ts +8 -3
- package/lib/components/BillingAddressForm.js +1 -1
- package/lib/components/BraintreePayment.d.ts +3 -3
- package/lib/components/BraintreePayment.js +1 -1
- package/lib/components/CheckoutComPayment.d.ts +23 -0
- package/lib/components/CheckoutComPayment.js +1 -0
- package/lib/components/CheckoutLink.d.ts +16 -4
- package/lib/components/CheckoutLink.js +1 -1
- package/lib/components/DeliveryLeadTime.d.ts +11 -4
- package/lib/components/DeliveryLeadTime.js +1 -1
- package/lib/components/DiscountAmount.d.ts +16 -2
- package/lib/components/DiscountAmount.js +1 -1
- package/lib/components/Errors.d.ts +4 -4
- package/lib/components/Errors.js +1 -1
- package/lib/components/ExternalFunction.d.ts +9 -2
- package/lib/components/ExternalFunction.js +1 -1
- package/lib/components/GiftCard.d.ts +13 -3
- package/lib/components/GiftCard.js +1 -1
- package/lib/components/GiftCardContainer.d.ts +9 -3
- package/lib/components/GiftCardContainer.js +1 -1
- package/lib/components/GiftCardCurrencySelector.d.ts +18 -3
- package/lib/components/GiftCardCurrencySelector.js +1 -1
- package/lib/components/GiftCardInput.d.ts +12 -3
- package/lib/components/GiftCardInput.js +1 -1
- package/lib/components/GiftCardOrCouponCode.d.ts +17 -6
- package/lib/components/GiftCardOrCouponCode.js +1 -1
- package/lib/components/GiftCardOrCouponForm.d.ts +9 -4
- package/lib/components/GiftCardOrCouponForm.js +1 -1
- package/lib/components/GiftCardOrCouponInput.d.ts +14 -3
- package/lib/components/GiftCardOrCouponInput.js +1 -1
- package/lib/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
- package/lib/components/GiftCardOrCouponRemoveButton.js +1 -1
- package/lib/components/GiftCardOrCouponSubmit.d.ts +11 -4
- package/lib/components/GiftCardOrCouponSubmit.js +1 -1
- package/lib/components/ItemContainer.d.ts +14 -3
- package/lib/components/ItemContainer.js +1 -1
- package/lib/components/KlarnaPayment.d.ts +10 -0
- package/lib/components/KlarnaPayment.js +1 -0
- package/lib/components/LineItem.d.ts +10 -3
- package/lib/components/LineItem.js +1 -1
- package/lib/components/LineItemAmount.d.ts +16 -3
- package/lib/components/LineItemAmount.js +1 -1
- package/lib/components/LineItemCode.d.ts +10 -4
- package/lib/components/LineItemCode.js +1 -1
- package/lib/components/LineItemImage.d.ts +11 -4
- package/lib/components/LineItemImage.js +1 -1
- package/lib/components/LineItemName.d.ts +11 -5
- package/lib/components/LineItemName.js +1 -1
- package/lib/components/LineItemOption.d.ts +15 -4
- package/lib/components/LineItemOption.js +1 -1
- package/lib/components/LineItemOptions.d.ts +8 -3
- package/lib/components/LineItemOptions.js +1 -1
- package/lib/components/LineItemQuantity.d.ts +16 -4
- package/lib/components/LineItemQuantity.js +1 -1
- package/lib/components/LineItemRemoveLink.d.ts +15 -5
- package/lib/components/LineItemRemoveLink.js +1 -1
- package/lib/components/LineItemsContainer.d.ts +15 -3
- package/lib/components/LineItemsContainer.js +1 -1
- package/lib/components/LineItemsCount.d.ts +14 -4
- package/lib/components/LineItemsCount.js +1 -1
- package/lib/components/LineItemsEmpty.d.ts +13 -2
- package/lib/components/LineItemsEmpty.js +1 -1
- package/lib/components/MetadataInput.d.ts +13 -3
- package/lib/components/MetadataInput.js +1 -1
- package/lib/components/PaymentGateway.d.ts +4 -4
- package/lib/components/PaymentGateway.js +1 -1
- package/lib/components/PaymentMethod.d.ts +9 -3
- package/lib/components/PaymentMethod.js +1 -1
- package/lib/components/PaymentMethodAmount.d.ts +16 -2
- package/lib/components/PaymentMethodAmount.js +1 -1
- package/lib/components/PaymentMethodName.d.ts +10 -4
- package/lib/components/PaymentMethodName.js +1 -1
- package/lib/components/PaymentMethodPrice.d.ts +15 -4
- package/lib/components/PaymentMethodPrice.js +1 -1
- package/lib/components/PaymentMethodRadioButton.d.ts +11 -4
- package/lib/components/PaymentMethodRadioButton.js +1 -1
- package/lib/components/PaymentMethodsContainer.d.ts +9 -3
- package/lib/components/PaymentMethodsContainer.js +1 -1
- package/lib/components/PaymentSource.d.ts +9 -2
- package/lib/components/PaymentSource.js +1 -1
- package/lib/components/PaymentSourceBrandIcon.d.ts +14 -4
- package/lib/components/PaymentSourceBrandIcon.js +1 -1
- package/lib/components/PaymentSourceBrandName.d.ts +11 -4
- package/lib/components/PaymentSourceBrandName.js +1 -1
- package/lib/components/PaymentSourceDetail.d.ts +8 -2
- package/lib/components/PaymentSourceDetail.js +1 -1
- package/lib/components/PaymentSourceEditButton.d.ts +9 -2
- package/lib/components/PaymentSourceEditButton.js +1 -1
- package/lib/components/PaypalPayment.d.ts +2 -2
- package/lib/components/PaypalPayment.js +1 -1
- package/lib/components/Price.d.ts +15 -3
- package/lib/components/Price.js +1 -1
- package/lib/components/PricesContainer.d.ts +19 -3
- package/lib/components/PricesContainer.js +1 -1
- package/lib/components/QuantitySelector.d.ts +19 -5
- package/lib/components/QuantitySelector.js +1 -1
- package/lib/components/SaveAddressesButton.d.ts +18 -5
- package/lib/components/SaveAddressesButton.js +1 -1
- package/lib/components/SaveCustomerButton.d.ts +16 -5
- package/lib/components/SaveCustomerButton.js +1 -1
- package/lib/components/Shipment.d.ts +9 -2
- package/lib/components/Shipment.js +1 -1
- package/lib/components/ShipmentField.d.ts +11 -4
- package/lib/components/ShipmentField.js +1 -1
- package/lib/components/ShipmentsContainer.d.ts +9 -3
- package/lib/components/ShipmentsContainer.js +1 -1
- package/lib/components/ShippingAddressContainer.d.ts +7 -2
- package/lib/components/ShippingAddressContainer.js +1 -1
- package/lib/components/ShippingAddressForm.d.ts +8 -3
- package/lib/components/ShippingAddressForm.js +1 -1
- package/lib/components/ShippingAmount.d.ts +13 -2
- package/lib/components/ShippingAmount.js +1 -1
- package/lib/components/ShippingMethod.d.ts +10 -3
- package/lib/components/ShippingMethod.js +1 -1
- package/lib/components/ShippingMethodName.d.ts +11 -5
- package/lib/components/ShippingMethodName.js +1 -1
- package/lib/components/ShippingMethodPrice.d.ts +15 -3
- package/lib/components/ShippingMethodPrice.js +1 -1
- package/lib/components/ShippingMethodRadioButton.d.ts +11 -5
- package/lib/components/ShippingMethodRadioButton.js +1 -1
- package/lib/components/StockTransfer.d.ts +9 -3
- package/lib/components/StockTransfer.js +1 -1
- package/lib/components/StockTransferField.d.ts +9 -8
- package/lib/components/StockTransferField.js +1 -1
- package/lib/components/StripePayment.d.ts +3 -3
- package/lib/components/StripePayment.js +1 -1
- package/lib/components/SubmitButton.d.ts +15 -5
- package/lib/components/SubmitButton.js +1 -1
- package/lib/components/VariantSelector.d.ts +28 -5
- package/lib/components/VariantSelector.js +1 -1
- package/lib/components/VariantsContainer.d.ts +15 -3
- package/lib/components/VariantsContainer.js +1 -1
- package/lib/components/WireTransferPayment.d.ts +2 -2
- package/lib/components/WireTransferPayment.js +1 -1
- package/lib/components/addresses/Address.d.ts +18 -0
- package/lib/components/addresses/Address.js +1 -0
- package/lib/components/addresses/AddressCountrySelector.d.ts +26 -0
- package/lib/components/addresses/AddressCountrySelector.js +1 -0
- package/lib/components/addresses/AddressField.d.ts +43 -0
- package/lib/components/addresses/AddressField.js +1 -0
- package/lib/components/addresses/AddressInput.d.ts +19 -0
- package/lib/components/addresses/AddressInput.js +1 -0
- package/lib/components/addresses/AddressStateSelector.d.ts +27 -0
- package/lib/components/addresses/AddressStateSelector.js +1 -0
- package/lib/components/addresses/AddressesContainer.d.ts +15 -0
- package/lib/components/addresses/AddressesContainer.js +1 -0
- package/lib/components/auth/CommerceLayer.d.ts +15 -0
- package/lib/components/auth/CommerceLayer.js +1 -0
- package/lib/components/customers/CustomerAddressForm.d.ts +13 -0
- package/lib/components/customers/CustomerAddressForm.js +1 -0
- package/lib/components/customers/CustomerContainer.d.ts +17 -0
- package/lib/components/customers/CustomerContainer.js +1 -0
- package/lib/components/customers/CustomerField.d.ts +10 -0
- package/lib/components/customers/CustomerField.js +1 -0
- package/lib/components/customers/CustomerInput.d.ts +23 -0
- package/lib/components/customers/CustomerInput.js +1 -0
- package/lib/components/gateways/AdyenGateway.d.ts +2 -2
- package/lib/components/gateways/AdyenGateway.js +1 -1
- package/lib/components/gateways/BraintreeGateway.d.ts +2 -2
- package/lib/components/gateways/BraintreeGateway.js +1 -1
- package/lib/components/gateways/CheckoutComGateway.d.ts +5 -0
- package/lib/components/gateways/CheckoutComGateway.js +1 -0
- package/lib/components/gateways/KlarnaGateway.d.ts +5 -0
- package/lib/components/gateways/KlarnaGateway.js +1 -0
- package/lib/components/gateways/PaypalGateway.d.ts +3 -3
- package/lib/components/gateways/PaypalGateway.js +1 -1
- package/lib/components/gateways/StripeGateway.d.ts +2 -2
- package/lib/components/gateways/StripeGateway.js +1 -1
- package/lib/components/gateways/WireTransferGateway.d.ts +2 -2
- package/lib/components/gateways/WireTransferGateway.js +1 -1
- package/lib/components/orders/AddToCartButton.d.ts +34 -0
- package/lib/components/orders/AddToCartButton.js +1 -0
- package/lib/components/orders/AdjustmentAmount.d.ts +18 -0
- package/lib/components/orders/AdjustmentAmount.js +1 -0
- package/lib/components/orders/CartLink.d.ts +12 -0
- package/lib/components/orders/CartLink.js +1 -0
- package/lib/components/orders/GiftCardAmount.d.ts +15 -0
- package/lib/components/orders/GiftCardAmount.js +1 -0
- package/lib/components/orders/OrderContainer.d.ts +26 -0
- package/lib/components/orders/OrderContainer.js +1 -0
- package/lib/components/orders/OrderList.d.ts +61 -0
- package/lib/components/orders/OrderList.js +1 -0
- package/lib/components/orders/OrderListRow.d.ts +30 -0
- package/lib/components/orders/OrderListRow.js +1 -0
- package/lib/components/orders/OrderNumber.d.ts +11 -0
- package/lib/components/orders/OrderNumber.js +1 -0
- package/lib/components/orders/OrderStorage.d.ts +16 -0
- package/lib/components/orders/OrderStorage.js +1 -0
- package/lib/components/orders/PlaceOrderButton.d.ts +24 -0
- package/lib/components/orders/PlaceOrderButton.js +1 -0
- package/lib/components/orders/PlaceOrderContainer.d.ts +14 -0
- package/lib/components/orders/PlaceOrderContainer.js +1 -0
- package/lib/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
- package/lib/components/orders/PrivacyAndTermsCheckbox.js +1 -0
- package/lib/components/orders/SubTotalAmount.d.ts +18 -0
- package/lib/components/orders/SubTotalAmount.js +1 -0
- package/lib/components/orders/TaxesAmount.d.ts +18 -0
- package/lib/components/orders/TaxesAmount.js +1 -0
- package/lib/components/orders/TotalAmount.d.ts +18 -0
- package/lib/components/orders/TotalAmount.js +1 -0
- package/lib/components/skus/SkuField.d.ts +14 -0
- package/lib/components/skus/SkuField.js +1 -0
- package/lib/components/skus/SkuList.d.ts +14 -0
- package/lib/components/skus/SkuList.js +1 -0
- package/lib/components/skus/SkuListsContainer.d.ts +12 -0
- package/lib/components/skus/SkuListsContainer.js +1 -0
- package/lib/components/skus/SkuOption.d.ts +14 -0
- package/lib/components/skus/SkuOption.js +1 -0
- package/lib/components/skus/SkuOptionInput.d.ts +15 -0
- package/lib/components/skus/SkuOptionInput.js +1 -0
- package/lib/components/skus/SkuOptionsContainer.d.ts +14 -0
- package/lib/components/skus/SkuOptionsContainer.js +1 -0
- package/lib/components/skus/Skus.d.ts +11 -0
- package/lib/components/skus/Skus.js +1 -0
- package/lib/components/skus/SkusContainer.d.ts +23 -0
- package/lib/components/skus/SkusContainer.js +1 -0
- package/lib/components/utils/AddressCardsTemplate.d.ts +1 -1
- package/lib/components/utils/AddressCardsTemplate.js +1 -1
- package/lib/components/utils/BaseField.js +1 -1
- package/lib/components/utils/BaseInput.d.ts +1 -1
- package/lib/components/utils/BaseInput.js +1 -1
- package/lib/components/utils/BaseOrderPrice.js +1 -1
- package/lib/components/utils/BaseSelect.js +1 -1
- package/lib/components/utils/GenericFieldComponent.d.ts +42 -0
- package/lib/components/utils/GenericFieldComponent.js +1 -0
- package/lib/components/utils/Parent.d.ts +3 -5
- package/lib/components/utils/Parent.js +1 -1
- package/lib/components/utils/PaymentCardsTemplate.d.ts +2 -2
- package/lib/components/utils/PaymentCardsTemplate.js +1 -1
- package/lib/components/utils/PriceTemplate.d.ts +2 -2
- package/lib/components/utils/PriceTemplate.js +1 -1
- package/lib/components/utils/VariantTemplate.js +1 -1
- package/lib/components/utils/getAllErrors.js +1 -1
- package/lib/config/components.d.ts +77 -35
- package/lib/config/components.js +1 -1
- package/lib/context/AddressChildrenContext.d.ts +1 -1
- package/lib/context/AddressChildrenContext.js +1 -1
- package/lib/context/AddressContext.d.ts +1 -1
- package/lib/context/BillingAddressContext.d.ts +2 -4
- package/lib/context/BillingAddressContext.js +1 -1
- package/lib/context/BillingAddressFormContext.d.ts +17 -10
- package/lib/context/CouponAndGiftCardFormContext.d.ts +2 -0
- package/lib/context/CustomerAddressFormContext.d.ts +20 -0
- package/lib/context/CustomerAddressFormContext.js +1 -0
- package/lib/context/CustomerContext.d.ts +17 -11
- package/lib/context/CustomerContext.js +1 -1
- package/lib/context/OrderContext.d.ts +8 -4
- package/lib/context/OrderContext.js +1 -1
- package/lib/context/OrderListChildrenContext.d.ts +60 -0
- package/lib/context/OrderListChildrenContext.js +1 -0
- package/lib/context/PaymentSourceContext.d.ts +4 -4
- package/lib/context/PlaceOrderContext.d.ts +4 -2
- package/lib/context/ShippingAddressContext.d.ts +1 -1
- package/lib/context/SkuChildrenContext.d.ts +9 -0
- package/lib/context/SkuChildrenContext.js +1 -0
- package/lib/context/SkuContext.d.ts +9 -0
- package/lib/context/SkuContext.js +1 -0
- package/lib/index.d.ts +101 -90
- package/lib/index.js +1 -1
- package/lib/reducers/AddressReducer.d.ts +4 -2
- package/lib/reducers/AddressReducer.js +1 -1
- package/lib/reducers/AvailabilityReducer.d.ts +8 -0
- package/lib/reducers/AvailabilityReducer.js +1 -1
- package/lib/reducers/BillingAddressReducer.js +1 -1
- package/lib/reducers/CustomerReducer.d.ts +98 -17
- package/lib/reducers/CustomerReducer.js +1 -1
- package/lib/reducers/GiftCardReducer.js +1 -1
- package/lib/reducers/LineItemReducer.js +1 -1
- package/lib/reducers/OrderReducer.d.ts +24 -8
- package/lib/reducers/OrderReducer.js +1 -1
- package/lib/reducers/PaymentMethodReducer.d.ts +51 -5
- package/lib/reducers/PaymentMethodReducer.js +1 -1
- package/lib/reducers/PlaceOrderReducer.d.ts +9 -2
- package/lib/reducers/PlaceOrderReducer.js +1 -1
- package/lib/reducers/ShipmentReducer.js +1 -1
- package/lib/reducers/ShippingAddressReducer.js +1 -1
- package/lib/reducers/SkuReducer.d.ts +21 -0
- package/lib/reducers/SkuReducer.js +1 -0
- package/lib/reducers/VariantReducer.d.ts +1 -0
- package/lib/reducers/VariantReducer.js +1 -1
- package/lib/typings/errors.d.ts +13 -4
- package/lib/typings/errors.js +1 -1
- package/lib/typings/index.d.ts +17 -6
- package/lib/utils/addressesManager.d.ts +1 -1
- package/lib/utils/addressesManager.js +1 -1
- package/lib/utils/checkIncludeResource.d.ts +8 -0
- package/lib/utils/checkIncludeResource.js +1 -0
- package/lib/utils/childrenTypes.d.ts +1 -1
- package/lib/utils/childrenTypes.js +1 -1
- package/lib/utils/compareObjAttribute.d.ts +7 -0
- package/lib/utils/compareObjAttribute.js +1 -0
- package/lib/utils/customMessages.d.ts +1 -7
- package/lib/utils/customMessages.js +1 -1
- package/lib/utils/getCardDetails.d.ts +15 -0
- package/lib/utils/getCardDetails.js +1 -0
- package/lib/utils/getCartLink.d.ts +7 -0
- package/lib/utils/getCartLink.js +1 -0
- package/lib/utils/getCurrentItemKey.js +1 -1
- package/lib/utils/getErrors.d.ts +1 -1
- package/lib/utils/getErrors.js +1 -1
- package/lib/utils/getLineItemsCount.d.ts +8 -10
- package/lib/utils/getLineItemsCount.js +1 -1
- package/lib/utils/getLoaderComponent.js +1 -1
- package/lib/utils/getPrices.js +1 -1
- package/lib/utils/getSkus.js +1 -1
- package/lib/utils/hooks/useExternalScript.d.ts +1 -0
- package/lib/utils/hooks/useExternalScript.js +1 -0
- package/lib/utils/icons.d.ts +3 -0
- package/lib/utils/icons.js +1 -0
- package/lib/utils/isDate.d.ts +1 -0
- package/lib/utils/isDate.js +1 -0
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/placeholderImages.d.ts +2 -0
- package/lib/utils/placeholderImages.js +1 -0
- package/lib/utils/promisify.js +1 -1
- package/lib/utils/scrollbarWidth.d.ts +1 -0
- package/lib/utils/scrollbarWidth.js +1 -0
- package/lib/utils/shipments.d.ts +2 -1
- package/lib/utils/shipments.js +1 -1
- package/lib/utils/validateFormFields.d.ts +2 -0
- package/lib/utils/validateFormFields.js +1 -1
- package/package.json +96 -93
- package/lib/components/AddToCartButton.d.ts +0 -20
- package/lib/components/AddToCartButton.js +0 -1
- package/lib/components/Address.d.ts +0 -13
- package/lib/components/Address.js +0 -1
- package/lib/components/AddressCountrySelector.d.ts +0 -9
- package/lib/components/AddressCountrySelector.js +0 -1
- package/lib/components/AddressField.d.ts +0 -15
- package/lib/components/AddressField.js +0 -1
- package/lib/components/AddressInput.d.ts +0 -7
- package/lib/components/AddressInput.js +0 -1
- package/lib/components/AddressStateSelector.d.ts +0 -11
- package/lib/components/AddressStateSelector.js +0 -1
- package/lib/components/AddressesContainer.d.ts +0 -7
- package/lib/components/AddressesContainer.js +0 -1
- package/lib/components/AdjustmentAmount.d.ts +0 -4
- package/lib/components/AdjustmentAmount.js +0 -1
- package/lib/components/CommerceLayer.d.ts +0 -8
- package/lib/components/CommerceLayer.js +0 -1
- package/lib/components/CustomerContainer.d.ts +0 -7
- package/lib/components/CustomerContainer.js +0 -1
- package/lib/components/CustomerInput.d.ts +0 -11
- package/lib/components/CustomerInput.js +0 -1
- package/lib/components/GiftCardAmount.d.ts +0 -4
- package/lib/components/GiftCardAmount.js +0 -1
- package/lib/components/OrderContainer.d.ts +0 -11
- package/lib/components/OrderContainer.js +0 -1
- package/lib/components/OrderNumber.d.ts +0 -5
- package/lib/components/OrderNumber.js +0 -1
- package/lib/components/OrderStorage.d.ts +0 -8
- package/lib/components/OrderStorage.js +0 -1
- package/lib/components/PlaceOrderButton.d.ts +0 -12
- package/lib/components/PlaceOrderButton.js +0 -1
- package/lib/components/PlaceOrderContainer.d.ts +0 -8
- package/lib/components/PlaceOrderContainer.js +0 -1
- package/lib/components/PrivacyAndTermsCheckbox.d.ts +0 -4
- package/lib/components/PrivacyAndTermsCheckbox.js +0 -1
- package/lib/components/SkuList.d.ts +0 -7
- package/lib/components/SkuList.js +0 -1
- package/lib/components/SkuListsContainer.d.ts +0 -6
- package/lib/components/SkuListsContainer.js +0 -1
- package/lib/components/SkuOption.d.ts +0 -7
- package/lib/components/SkuOption.js +0 -1
- package/lib/components/SkuOptionInput.d.ts +0 -5
- package/lib/components/SkuOptionInput.js +0 -1
- package/lib/components/SkuOptionsContainer.d.ts +0 -7
- package/lib/components/SkuOptionsContainer.js +0 -1
- package/lib/components/SubTotalAmount.d.ts +0 -4
- package/lib/components/SubTotalAmount.js +0 -1
- package/lib/components/TaxesAmount.d.ts +0 -4
- package/lib/components/TaxesAmount.js +0 -1
- package/lib/components/TotalAmount.d.ts +0 -4
- package/lib/components/TotalAmount.js +0 -1
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { Order } from '@commercelayer/sdk';
|
|
3
|
+
import { AddToCart, OrderState, CreateOrder, SetGiftCardOrCouponCode, RemoveGiftCardOrCouponCode, SaveAddressToCustomerAddressBook, addResourceToInclude, updateOrder, getOrderContext } from '../reducers/OrderReducer';
|
|
4
|
+
import { BaseError } from '../typings/errors';
|
|
3
5
|
declare type DefaultContext = {
|
|
4
6
|
createOrder: CreateOrder;
|
|
5
7
|
addToCart: AddToCart;
|
|
6
|
-
setOrderErrors:
|
|
8
|
+
setOrderErrors: (errors: BaseError[]) => void;
|
|
7
9
|
setGiftCardOrCouponCode: SetGiftCardOrCouponCode;
|
|
8
10
|
removeGiftCardOrCouponCode: RemoveGiftCardOrCouponCode;
|
|
9
11
|
saveAddressToCustomerAddressBook: SaveAddressToCustomerAddressBook;
|
|
10
12
|
addResourceToInclude: typeof addResourceToInclude;
|
|
11
13
|
getOrder: getOrderContext;
|
|
12
14
|
updateOrder: typeof updateOrder;
|
|
15
|
+
setOrder: (order: Order) => void;
|
|
13
16
|
} & OrderState;
|
|
14
17
|
export declare const defaultOrderContext: {
|
|
15
18
|
addToCart: AddToCart;
|
|
16
19
|
createOrder: CreateOrder;
|
|
17
|
-
setOrderErrors:
|
|
20
|
+
setOrderErrors: () => void;
|
|
21
|
+
setOrder: () => void;
|
|
18
22
|
setGiftCardOrCouponCode: SetGiftCardOrCouponCode;
|
|
19
23
|
removeGiftCardOrCouponCode: RemoveGiftCardOrCouponCode;
|
|
20
24
|
saveAddressToCustomerAddressBook: SaveAddressToCustomerAddressBook;
|
|
21
25
|
addResourceToInclude: typeof addResourceToInclude;
|
|
22
|
-
getOrder: (
|
|
26
|
+
getOrder: () => Promise<void>;
|
|
23
27
|
updateOrder: typeof updateOrder;
|
|
24
28
|
};
|
|
25
29
|
declare const OrderContext: import("react").Context<DefaultContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext}from"react";import{addToCart,
|
|
1
|
+
import{createContext}from"react";import{addToCart,createOrder,setGiftCardOrCouponCode,removeGiftCardOrCouponCode,saveAddressToCustomerAddressBook,addResourceToInclude,updateOrder}from"../reducers/OrderReducer";export const defaultOrderContext={addToCart,createOrder,setOrderErrors:()=>{},setOrder:()=>{},setGiftCardOrCouponCode,removeGiftCardOrCouponCode,saveAddressToCustomerAddressBook,addResourceToInclude,getOrder:async()=>{},updateOrder};const OrderContext=createContext(defaultOrderContext);export default OrderContext;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Order } from '@commercelayer/sdk';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { Row } from 'react-table';
|
|
4
|
+
export declare type InitialOrderListContext = Partial<{
|
|
5
|
+
/**
|
|
6
|
+
* The current order
|
|
7
|
+
*/
|
|
8
|
+
order: Order | null;
|
|
9
|
+
/**
|
|
10
|
+
* The current row
|
|
11
|
+
*/
|
|
12
|
+
row: Row<Order>;
|
|
13
|
+
/**
|
|
14
|
+
* Show the row actions
|
|
15
|
+
*/
|
|
16
|
+
showActions: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Function to assign as custom row renderer
|
|
19
|
+
*/
|
|
20
|
+
actionsComponent: (props: {
|
|
21
|
+
order: Order;
|
|
22
|
+
}) => ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Class name to assign as custom row renderer
|
|
25
|
+
*/
|
|
26
|
+
actionsContainerClassName: string;
|
|
27
|
+
/**
|
|
28
|
+
* Infinite scroll enabled
|
|
29
|
+
*/
|
|
30
|
+
infiniteScroll: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
declare const OrderListChildrenContext: import("react").Context<Partial<{
|
|
33
|
+
/**
|
|
34
|
+
* The current order
|
|
35
|
+
*/
|
|
36
|
+
order: Order | null;
|
|
37
|
+
/**
|
|
38
|
+
* The current row
|
|
39
|
+
*/
|
|
40
|
+
row: Row<Order>;
|
|
41
|
+
/**
|
|
42
|
+
* Show the row actions
|
|
43
|
+
*/
|
|
44
|
+
showActions: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Function to assign as custom row renderer
|
|
47
|
+
*/
|
|
48
|
+
actionsComponent: (props: {
|
|
49
|
+
order: Order;
|
|
50
|
+
}) => ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* Class name to assign as custom row renderer
|
|
53
|
+
*/
|
|
54
|
+
actionsContainerClassName: string;
|
|
55
|
+
/**
|
|
56
|
+
* Infinite scroll enabled
|
|
57
|
+
*/
|
|
58
|
+
infiniteScroll: boolean;
|
|
59
|
+
}>>;
|
|
60
|
+
export default OrderListChildrenContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext}from"react";const initial={showActions:!1},OrderListChildrenContext=createContext(initial);export default OrderListChildrenContext;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare type
|
|
2
|
+
export declare type IconBrand = 'visa' | 'credit-card' | 'amex' | 'mastercard' | 'jcb' | 'wire-transfer' | 'maestro' | 'cirrus' | 'paypal';
|
|
3
3
|
declare type DefaultContext = {
|
|
4
|
-
brand?:
|
|
5
|
-
exp_month?: number;
|
|
6
|
-
exp_year?: number;
|
|
4
|
+
brand?: IconBrand | string;
|
|
5
|
+
exp_month?: number | string;
|
|
6
|
+
exp_year?: number | string;
|
|
7
7
|
last4?: string;
|
|
8
8
|
showCard?: boolean;
|
|
9
9
|
readonly?: boolean;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { PlaceOrderState, SetPlaceOrderErrors } from '../reducers/PlaceOrderReducer';
|
|
2
|
+
import { PlaceOrderOptions, PlaceOrderState, SetPlaceOrderErrors } from '../reducers/PlaceOrderReducer';
|
|
3
|
+
import { PaymentSourceType } from '../reducers/PaymentMethodReducer';
|
|
3
4
|
declare type DefaultContext = {
|
|
4
5
|
setPlaceOrderErrors?: SetPlaceOrderErrors;
|
|
5
6
|
setPlaceOrder?: ({ paymentSource, }: {
|
|
6
|
-
paymentSource
|
|
7
|
+
paymentSource?: PaymentSourceType;
|
|
8
|
+
options?: PlaceOrderOptions;
|
|
7
9
|
}) => Promise<{
|
|
8
10
|
placed: boolean;
|
|
9
11
|
}>;
|
|
@@ -3,7 +3,7 @@ import { ShippingAddressState } from '../reducers/ShippingAddressReducer';
|
|
|
3
3
|
declare type DefaultContext = {
|
|
4
4
|
setShippingAddress?: (id: string, options?: {
|
|
5
5
|
customerAddressId: string;
|
|
6
|
-
}) => void
|
|
6
|
+
}) => Promise<void>;
|
|
7
7
|
} & ShippingAddressState;
|
|
8
8
|
export declare const defaultShippingAddressContext: {};
|
|
9
9
|
declare const ShippingAddressContext: import("react").Context<DefaultContext>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Sku } from '@commercelayer/sdk';
|
|
3
|
+
export declare type InitialSkuContext = Partial<{
|
|
4
|
+
sku: Sku;
|
|
5
|
+
}>;
|
|
6
|
+
declare const SkuChildrenContext: import("react").Context<Partial<{
|
|
7
|
+
sku: Sku;
|
|
8
|
+
}>>;
|
|
9
|
+
export default SkuChildrenContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext}from"react";const initial={},SkuChildrenContext=createContext(initial);export default SkuChildrenContext;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SkuState } from '../reducers/SkuReducer';
|
|
3
|
+
export declare type SkuContextValue = SkuState;
|
|
4
|
+
declare const SkuContext: import("react").Context<Partial<{
|
|
5
|
+
skus: import("@commercelayer/sdk/lib/cjs/resources/skus").Sku[];
|
|
6
|
+
loading: boolean;
|
|
7
|
+
skuCodes: string[];
|
|
8
|
+
}>>;
|
|
9
|
+
export default SkuContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext}from"react";const SkuContext=createContext({});export default SkuContext;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,96 +1,107 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
export
|
|
77
|
-
export
|
|
78
|
-
export
|
|
79
|
-
export
|
|
80
|
-
export
|
|
81
|
-
export
|
|
82
|
-
export
|
|
83
|
-
export
|
|
84
|
-
export
|
|
85
|
-
export
|
|
86
|
-
export
|
|
87
|
-
export
|
|
88
|
-
export
|
|
89
|
-
export
|
|
1
|
+
export * from './components/orders/AddToCartButton';
|
|
2
|
+
export * from './components/addresses/AddressCountrySelector';
|
|
3
|
+
export * from './components/addresses/Address';
|
|
4
|
+
export * from './components/addresses/AddressField';
|
|
5
|
+
export * from './components/addresses/AddressInput';
|
|
6
|
+
export * from './components/addresses/AddressStateSelector';
|
|
7
|
+
export * from './components/addresses/AddressesContainer';
|
|
8
|
+
export * from './components/orders/AdjustmentAmount';
|
|
9
|
+
export * from './components/AvailabilityContainer';
|
|
10
|
+
export * from './components/AvailabilityTemplate';
|
|
11
|
+
export * from './components/BillingAddressContainer';
|
|
12
|
+
export * from './components/BillingAddressForm';
|
|
13
|
+
export * from './components/orders/CartLink';
|
|
14
|
+
export * from './components/CheckoutLink';
|
|
15
|
+
export * from './components/auth/CommerceLayer';
|
|
16
|
+
export * from './components/customers/CustomerContainer';
|
|
17
|
+
export * from './components/customers/CustomerField';
|
|
18
|
+
export * from './components/customers/CustomerAddressForm';
|
|
19
|
+
export * from './components/customers/CustomerInput';
|
|
20
|
+
export * from './components/DeliveryLeadTime';
|
|
21
|
+
export * from './components/DiscountAmount';
|
|
22
|
+
export * from './components/Errors';
|
|
23
|
+
export * from './components/ExternalFunction';
|
|
24
|
+
export * from './components/GiftCard';
|
|
25
|
+
export * from './components/orders/GiftCardAmount';
|
|
26
|
+
export * from './components/GiftCardContainer';
|
|
27
|
+
export * from './components/GiftCardCurrencySelector';
|
|
28
|
+
export * from './components/GiftCardInput';
|
|
29
|
+
export * from './components/GiftCardOrCouponCode';
|
|
30
|
+
export * from './components/GiftCardOrCouponForm';
|
|
31
|
+
export * from './components/GiftCardOrCouponInput';
|
|
32
|
+
export * from './components/GiftCardOrCouponRemoveButton';
|
|
33
|
+
export * from './components/GiftCardOrCouponSubmit';
|
|
34
|
+
export * from './components/ItemContainer';
|
|
35
|
+
export * from './components/LineItem';
|
|
36
|
+
export * from './components/LineItemAmount';
|
|
37
|
+
export * from './components/LineItemCode';
|
|
38
|
+
export * from './components/LineItemImage';
|
|
39
|
+
export * from './components/LineItemName';
|
|
40
|
+
export * from './components/LineItemOption';
|
|
41
|
+
export * from './components/LineItemOptions';
|
|
42
|
+
export * from './components/LineItemQuantity';
|
|
43
|
+
export * from './components/LineItemRemoveLink';
|
|
44
|
+
export * from './components/LineItemsContainer';
|
|
45
|
+
export * from './components/LineItemsCount';
|
|
46
|
+
export * from './components/LineItemsEmpty';
|
|
47
|
+
export * from './components/MetadataInput';
|
|
48
|
+
export * from './components/orders/OrderContainer';
|
|
49
|
+
export * from './components/orders/OrderNumber';
|
|
50
|
+
export * from './components/orders/OrderStorage';
|
|
51
|
+
export * from './components/orders/OrderList';
|
|
52
|
+
export * from './components/orders/OrderListRow';
|
|
53
|
+
export * from './components/PaymentMethod';
|
|
54
|
+
export * from './components/PaymentMethodAmount';
|
|
55
|
+
export * from './components/PaymentMethodName';
|
|
56
|
+
export * from './components/PaymentMethodPrice';
|
|
57
|
+
export * from './components/PaymentMethodRadioButton';
|
|
58
|
+
export * from './components/PaymentMethodsContainer';
|
|
59
|
+
export * from './components/PaymentSource';
|
|
60
|
+
export * from './components/PaymentSourceBrandIcon';
|
|
61
|
+
export * from './components/PaymentSourceBrandName';
|
|
62
|
+
export * from './components/PaymentSourceDetail';
|
|
63
|
+
export * from './components/PaymentSourceEditButton';
|
|
64
|
+
export * from './components/orders/PlaceOrderButton';
|
|
65
|
+
export * from './components/orders/PlaceOrderContainer';
|
|
66
|
+
export * from './components/Price';
|
|
67
|
+
export * from './components/PricesContainer';
|
|
68
|
+
export * from './components/orders/PrivacyAndTermsCheckbox';
|
|
69
|
+
export * from './components/QuantitySelector';
|
|
70
|
+
export * from './components/SaveAddressesButton';
|
|
71
|
+
export * from './components/SaveCustomerButton';
|
|
72
|
+
export * from './components/Shipment';
|
|
73
|
+
export * from './components/ShipmentField';
|
|
74
|
+
export * from './components/ShipmentsContainer';
|
|
75
|
+
export * from './components/ShippingAddressContainer';
|
|
76
|
+
export * from './components/ShippingAddressForm';
|
|
77
|
+
export * from './components/ShippingAmount';
|
|
78
|
+
export * from './components/ShippingMethod';
|
|
79
|
+
export * from './components/ShippingMethodName';
|
|
80
|
+
export * from './components/ShippingMethodPrice';
|
|
81
|
+
export * from './components/ShippingMethodRadioButton';
|
|
82
|
+
export * from './components/skus/SkuField';
|
|
83
|
+
export * from './components/skus/SkuList';
|
|
84
|
+
export * from './components/skus/SkuListsContainer';
|
|
85
|
+
export * from './components/skus/SkuOption';
|
|
86
|
+
export * from './components/skus/SkuOptionInput';
|
|
87
|
+
export * from './components/skus/SkuOptionsContainer';
|
|
88
|
+
export * from './components/skus/Skus';
|
|
89
|
+
export * from './components/skus/SkusContainer';
|
|
90
|
+
export * from './components/StockTransfer';
|
|
91
|
+
export * from './components/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
|
+
export * from './components/VariantSelector';
|
|
97
|
+
export * from './components/VariantsContainer';
|
|
90
98
|
export type { CustomerCardsType } from './components/utils/PaymentCardsTemplate';
|
|
91
99
|
export type { AddressCardsType } from './components/utils/AddressCardsTemplate';
|
|
92
|
-
export type { AddToCartButtonType } from './components/AddToCartButton';
|
|
100
|
+
export type { AddToCartButtonType } from './components/orders/AddToCartButton';
|
|
93
101
|
export type { ShippingMethodRadioButtonType, ShippingMethodRadioButtonOnChangeType, } from './components/ShippingMethodRadioButton';
|
|
94
102
|
export type { LineItemCodeType } from './components/LineItemCode';
|
|
95
103
|
export type { LineItemNameType } from './components/LineItemName';
|
|
96
104
|
export type { LineItemImageType } from './components/LineItemImage';
|
|
105
|
+
export type { LineItemType } from './typings/index';
|
|
106
|
+
export type { ErrorComponentProps, ResourceErrorType } from './typings/errors';
|
|
107
|
+
export type { AddressCountrySelectName, AddressInputName, AddressStateSelectName, BaseInputType, } from './typings/index';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export*from"./components/orders/AddToCartButton";export*from"./components/addresses/AddressCountrySelector";export*from"./components/addresses/Address";export*from"./components/addresses/AddressField";export*from"./components/addresses/AddressInput";export*from"./components/addresses/AddressStateSelector";export*from"./components/addresses/AddressesContainer";export*from"./components/orders/AdjustmentAmount";export*from"./components/AvailabilityContainer";export*from"./components/AvailabilityTemplate";export*from"./components/BillingAddressContainer";export*from"./components/BillingAddressForm";export*from"./components/orders/CartLink";export*from"./components/CheckoutLink";export*from"./components/auth/CommerceLayer";export*from"./components/customers/CustomerContainer";export*from"./components/customers/CustomerField";export*from"./components/customers/CustomerAddressForm";export*from"./components/customers/CustomerInput";export*from"./components/DeliveryLeadTime";export*from"./components/DiscountAmount";export*from"./components/Errors";export*from"./components/ExternalFunction";export*from"./components/GiftCard";export*from"./components/orders/GiftCardAmount";export*from"./components/GiftCardContainer";export*from"./components/GiftCardCurrencySelector";export*from"./components/GiftCardInput";export*from"./components/GiftCardOrCouponCode";export*from"./components/GiftCardOrCouponForm";export*from"./components/GiftCardOrCouponInput";export*from"./components/GiftCardOrCouponRemoveButton";export*from"./components/GiftCardOrCouponSubmit";export*from"./components/ItemContainer";export*from"./components/LineItem";export*from"./components/LineItemAmount";export*from"./components/LineItemCode";export*from"./components/LineItemImage";export*from"./components/LineItemName";export*from"./components/LineItemOption";export*from"./components/LineItemOptions";export*from"./components/LineItemQuantity";export*from"./components/LineItemRemoveLink";export*from"./components/LineItemsContainer";export*from"./components/LineItemsCount";export*from"./components/LineItemsEmpty";export*from"./components/MetadataInput";export*from"./components/orders/OrderContainer";export*from"./components/orders/OrderNumber";export*from"./components/orders/OrderStorage";export*from"./components/orders/OrderList";export*from"./components/orders/OrderListRow";export*from"./components/PaymentMethod";export*from"./components/PaymentMethodAmount";export*from"./components/PaymentMethodName";export*from"./components/PaymentMethodPrice";export*from"./components/PaymentMethodRadioButton";export*from"./components/PaymentMethodsContainer";export*from"./components/PaymentSource";export*from"./components/PaymentSourceBrandIcon";export*from"./components/PaymentSourceBrandName";export*from"./components/PaymentSourceDetail";export*from"./components/PaymentSourceEditButton";export*from"./components/orders/PlaceOrderButton";export*from"./components/orders/PlaceOrderContainer";export*from"./components/Price";export*from"./components/PricesContainer";export*from"./components/orders/PrivacyAndTermsCheckbox";export*from"./components/QuantitySelector";export*from"./components/SaveAddressesButton";export*from"./components/SaveCustomerButton";export*from"./components/Shipment";export*from"./components/ShipmentField";export*from"./components/ShipmentsContainer";export*from"./components/ShippingAddressContainer";export*from"./components/ShippingAddressForm";export*from"./components/ShippingAmount";export*from"./components/ShippingMethod";export*from"./components/ShippingMethodName";export*from"./components/ShippingMethodPrice";export*from"./components/ShippingMethodRadioButton";export*from"./components/skus/SkuField";export*from"./components/skus/SkuList";export*from"./components/skus/SkuListsContainer";export*from"./components/skus/SkuOption";export*from"./components/skus/SkuOptionInput";export*from"./components/skus/SkuOptionsContainer";export*from"./components/skus/Skus";export*from"./components/skus/SkusContainer";export*from"./components/StockTransfer";export*from"./components/StockTransferField";export*from"./components/orders/SubTotalAmount";export*from"./components/SubmitButton";export*from"./components/orders/TaxesAmount";export*from"./components/orders/TotalAmount";export*from"./components/VariantSelector";export*from"./components/VariantsContainer";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Dispatch } from 'react';
|
|
2
2
|
import { BaseError, ResourceErrorType } from '../typings/errors';
|
|
3
3
|
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
4
|
-
import { Address, AddressCreate, Order } from '@commercelayer/sdk';
|
|
4
|
+
import type { Address, AddressCreate, Order } from '@commercelayer/sdk';
|
|
5
5
|
import { updateOrder } from './OrderReducer';
|
|
6
|
+
import { TCustomerAddress } from './CustomerReducer';
|
|
6
7
|
export declare type AddressActionType = 'setErrors' | 'setAddress' | 'setShipToDifferentAddress' | 'setCloneAddress' | 'cleanup';
|
|
7
8
|
export declare type AddressField = 'city' | 'company' | 'country_code' | 'first_name' | 'last_name' | 'line_1' | 'line_2' | 'phone' | 'state_code' | 'zip_code' | 'billing_info';
|
|
8
9
|
export declare type AddressFieldView = AddressField | 'full_address' | 'full_name';
|
|
@@ -11,11 +12,12 @@ export declare type AddressResource = Extract<ResourceErrorType, 'billing_addres
|
|
|
11
12
|
export declare type AddressSchema = Address;
|
|
12
13
|
export interface AddressActionPayload {
|
|
13
14
|
errors: BaseError[];
|
|
14
|
-
billing_address:
|
|
15
|
+
billing_address: TCustomerAddress;
|
|
15
16
|
shipping_address: AddressCreate;
|
|
16
17
|
shipToDifferentAddress: boolean;
|
|
17
18
|
billingAddressId: string;
|
|
18
19
|
shippingAddressId: string;
|
|
20
|
+
isBusiness: boolean;
|
|
19
21
|
}
|
|
20
22
|
export declare type AddressState = Partial<AddressActionPayload>;
|
|
21
23
|
export interface AddressAction {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";export const addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],addressInitialState={errors:[]},setAddressErrors=({errors,dispatch,currentErrors=[],resource})=>{const billingErrors=resource==="billing_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="billing_address"),shippingErrors=resource==="shipping_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="shipping_address"),finalErrors=[...billingErrors,...shippingErrors];dispatch&&dispatch({type:"setErrors",payload:{errors:finalErrors}})},setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})},setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${camelCase(resource)}Id`]:id}})},saveAddresses=async({config,updateOrder,order,state})=>{var _a,_b,_c;const{shipToDifferentAddress,billing_address,shipping_address,billingAddressId,shippingAddressId}=state;try{const sdk=getSdk(config);if(order){const currentBillingAddressRef=(_a=order
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";export const addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],addressInitialState={errors:[]},setAddressErrors=({errors,dispatch,currentErrors=[],resource})=>{const billingErrors=resource==="billing_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="billing_address"),shippingErrors=resource==="shipping_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="shipping_address"),finalErrors=[...billingErrors,...shippingErrors];dispatch&&dispatch({type:"setErrors",payload:{errors:finalErrors}})},setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})},setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${camelCase(resource)}Id`]:id}})},saveAddresses=async({config,updateOrder,order,state})=>{var _a,_b,_c;const{shipToDifferentAddress,billing_address,shipping_address,billingAddressId,shippingAddressId}=state;try{const sdk=getSdk(config);if(order){const currentBillingAddressRef=(_a=order?.billing_address)===null||_a===void 0?void 0:_a.reference,orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId};if(currentBillingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=(_b=order?.billing_address)===null||_b===void 0?void 0:_b.id,orderAttributes._shipping_address_clone_id=(_c=order?.shipping_address)===null||_c===void 0?void 0:_c.id),!isEmpty(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),!isEmpty(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)}!isEmpty(orderAttributes)&&updateOrder&&await updateOrder({id:order.id,attributes:orderAttributes})}}catch(error){console.error(error)}};const type=["setErrors","setAddress","setShipToDifferentAddress","setCloneAddress","cleanup"],addressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default addressReducer;
|
|
@@ -46,8 +46,16 @@ declare type GetAvailability = (args: {
|
|
|
46
46
|
dispatch: Dispatch<AvailabilityAction>;
|
|
47
47
|
config: CommerceLayerConfig;
|
|
48
48
|
setItem?: (item: Items) => void;
|
|
49
|
+
item?: Items;
|
|
49
50
|
}) => void;
|
|
50
51
|
export declare const getAvailability: GetAvailability;
|
|
52
|
+
declare type GetAvailabilityArgs = {
|
|
53
|
+
skusIds: string[];
|
|
54
|
+
dispatch: Dispatch<AvailabilityAction>;
|
|
55
|
+
config: CommerceLayerConfig;
|
|
56
|
+
setItem?: (item: Items) => void;
|
|
57
|
+
};
|
|
58
|
+
export declare function getAvailabilityByIds({ skusIds, config, setItem, }: GetAvailabilityArgs): Promise<void>;
|
|
51
59
|
export declare type AvailabilityActionType = 'setAvailability' | 'setErrors';
|
|
52
60
|
declare const availabilityReducer: (state: AvailabilityState, reducer: AvailabilityAction) => AvailabilityState;
|
|
53
61
|
export default availabilityReducer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const availabilityInitialState={quantity:null,min:{days:0,hours:0},max:{days:0,hours:0},errors:[]},getAvailability=async({skuCode,dispatch,config,setItem})=>{var _a;const sdk=getSdk(config);try{const[sku]=await sdk.skus.list({fields:{skus:["id"]},filters:{code_in:skuCode}})
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const availabilityInitialState={quantity:null,min:{days:0,hours:0},max:{days:0,hours:0},errors:[]},getAvailability=async({skuCode,dispatch,config,setItem,item})=>{var _a;const sdk=getSdk(config);try{const[sku]=await sdk.skus.list({fields:{skus:["id"]},filters:{code_in:skuCode}});if(sku){const skuInventory=await sdk.skus.retrieve(sku.id,{fields:{skus:["inventory"]}}),[level]=((_a=skuInventory.inventory)===null||_a===void 0?void 0:_a.levels)||[],[delivery]=level?.delivery_lead_times||[];dispatch({type:"setAvailability",payload:Object.assign(Object.assign({},delivery),{quantity:skuInventory.inventory.quantity})}),setItem&&setItem(Object.assign(Object.assign({},item),{[skuCode]:skuInventory}))}}catch(error){console.error("Get SKU availability",error)}};export async function getAvailabilityByIds({skusIds,config,setItem}){const sdk=getSdk(config);try{const inventories=await Promise.all(skusIds.map(async id=>await sdk.skus.retrieve(id,{fields:{skus:["inventory","code"]}}))),item={};inventories.forEach(v=>{v?.code&&(item[v.code]=v)}),setItem&&setItem(item)}catch(error){console.error("Get SKU availability",error)}}const typeAction=["setAvailability","setErrors"],availabilityReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default availabilityReducer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const billingAddressInitialState={_billing_address_clone_id:""},setBillingAddress=async(id,options)=>{try{if(options
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const billingAddressInitialState={_billing_address_clone_id:""},setBillingAddress=async(id,options)=>{try{if(options?.order){if(options.customerAddressId){const sdk=getSdk(options.config),attributes={id,reference:options.customerAddressId};await sdk.addresses.update(attributes)}options.dispatch({type:"setBillingAddress",payload:{_billing_address_clone_id:id}})}}catch(error){console.error("Set billing address",error)}},setBillingCustomerAddressId=async({dispatch,order,setCloneAddress})=>{var _a;const customerAddressId=(_a=order?.billing_address)===null||_a===void 0?void 0:_a.reference;try{customerAddressId&&(dispatch({type:"setBillingCustomerAddressId",payload:{billingCustomerAddressId:customerAddressId}}),setCloneAddress(customerAddressId,"billing_address"))}catch(error){console.error("error",error)}};const type=["setBillingAddress","setBillingCustomerAddressId","cleanup"],billingAddressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default billingAddressReducer;
|