@commercelayer/react-components 4.0.0-alpha.8 → 4.0.0-beta.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/lib/cjs/components/auth/CommerceLayer.d.ts +2 -2
- package/lib/cjs/components/line_items/LineItem.d.ts +4 -11
- package/lib/cjs/components/line_items/LineItem.js +1 -1
- package/lib/cjs/components/line_items/LineItemAmount.d.ts +0 -13
- package/lib/cjs/components/line_items/LineItemAmount.js +1 -1
- package/lib/cjs/components/line_items/LineItemCode.d.ts +6 -11
- package/lib/cjs/components/line_items/LineItemCode.js +1 -1
- package/lib/cjs/components/line_items/LineItemField.d.ts +14 -0
- package/lib/cjs/components/line_items/LineItemField.js +1 -0
- package/lib/cjs/components/line_items/LineItemImage.d.ts +4 -11
- package/lib/cjs/components/line_items/LineItemImage.js +1 -1
- package/lib/cjs/components/line_items/LineItemName.d.ts +6 -11
- package/lib/cjs/components/line_items/LineItemName.js +1 -1
- package/lib/cjs/components/line_items/LineItemOption.d.ts +5 -16
- package/lib/cjs/components/line_items/LineItemOption.js +1 -1
- package/lib/cjs/components/line_items/LineItemOptions.d.ts +2 -5
- package/lib/cjs/components/line_items/LineItemOptions.js +1 -1
- package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
- package/lib/cjs/components/line_items/LineItemsContainer.d.ts +2 -14
- package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
- package/lib/cjs/components/orders/AddToCartButton.d.ts +34 -9
- package/lib/cjs/components/orders/AddToCartButton.js +1 -1
- package/lib/cjs/components/orders/AdjustmentAmount.d.ts +2 -2
- package/lib/cjs/components/orders/AdjustmentAmount.js +1 -1
- package/lib/cjs/components/orders/CartLink.js +1 -1
- package/lib/cjs/components/orders/CheckoutLink.js +1 -1
- package/lib/cjs/components/orders/DiscountAmount.d.ts +0 -14
- package/lib/cjs/components/orders/DiscountAmount.js +1 -1
- package/lib/cjs/components/orders/GiftCardAmount.d.ts +0 -11
- package/lib/cjs/components/orders/GiftCardAmount.js +1 -1
- package/lib/cjs/components/orders/OrderContainer.js +1 -1
- package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +4 -0
- package/lib/cjs/components/orders/PaymentMethodAmount.js +1 -0
- package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
- package/lib/cjs/components/orders/PlaceOrderContainer.d.ts +2 -8
- package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -1
- package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -6
- package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -1
- package/lib/cjs/components/orders/ShippingAmount.d.ts +0 -11
- package/lib/cjs/components/orders/ShippingAmount.js +1 -1
- package/lib/cjs/components/orders/SubTotalAmount.d.ts +0 -14
- package/lib/cjs/components/orders/SubTotalAmount.js +1 -1
- package/lib/cjs/components/orders/TaxesAmount.d.ts +0 -14
- package/lib/cjs/components/orders/TaxesAmount.js +1 -1
- package/lib/cjs/components/orders/TotalAmount.d.ts +0 -14
- package/lib/cjs/components/orders/TotalAmount.js +1 -1
- package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +18 -0
- package/lib/cjs/components/parcels/ParcelLineItemsCount.js +1 -0
- package/lib/cjs/components/parcels/Parcels.d.ts +2 -1
- package/lib/cjs/components/parcels/Parcels.js +1 -1
- package/lib/cjs/components/parcels/ParcelsCount.d.ts +18 -0
- package/lib/cjs/components/parcels/ParcelsCount.js +1 -0
- package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +2 -2
- package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +2 -2
- package/lib/cjs/components/payment_gateways/BraintreeGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +2 -2
- package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +2 -2
- package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +2 -2
- package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +2 -2
- package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +2 -2
- package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -7
- package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +6 -11
- package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +2 -14
- package/lib/cjs/components/payment_methods/PaymentMethodPrice.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.d.ts +4 -9
- package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodsContainer.d.ts +2 -8
- package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -1
- package/lib/cjs/components/payment_source/AdyenPayment.d.ts +5 -5
- package/lib/cjs/components/payment_source/AdyenPayment.js +1 -1
- package/lib/cjs/components/payment_source/PaymentSource.d.ts +4 -11
- package/lib/cjs/components/payment_source/PaymentSource.js +1 -1
- package/lib/cjs/components/prices/Price.js +1 -1
- package/lib/cjs/components/prices/PricesContainer.js +1 -1
- package/lib/cjs/components/shipments/ShipmentsCount.d.ts +18 -0
- package/lib/cjs/components/shipments/ShipmentsCount.js +1 -0
- package/lib/cjs/components/skus/AvailabilityContainer.d.ts +3 -9
- package/lib/cjs/components/skus/AvailabilityContainer.js +1 -1
- package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +23 -4
- package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -1
- package/lib/cjs/components/skus/SkuField.js +1 -1
- package/lib/cjs/components/skus/SkusContainer.d.ts +2 -2
- package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +3 -4
- package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
- package/lib/cjs/components/utils/BaseOrderPrice.d.ts +3 -3
- package/lib/cjs/components/utils/BaseOrderPrice.js +1 -1
- package/lib/cjs/components/utils/GenericFieldComponent.d.ts +4 -4
- package/lib/cjs/components/utils/GenericFieldComponent.js +1 -1
- package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +3 -3
- package/lib/cjs/context/CommerceLayerContext.d.ts +2 -2
- package/lib/cjs/context/CommerceLayerContext.js +1 -1
- package/lib/cjs/context/ExternalFunctionContext.d.ts +2 -2
- package/lib/cjs/context/ExternalFunctionContext.js +1 -1
- package/lib/cjs/context/LineItemContext.d.ts +1 -1
- package/lib/cjs/context/OrderContext.d.ts +2 -3
- package/lib/cjs/context/OrderContext.js +1 -1
- package/lib/cjs/context/PaymentMethodContext.d.ts +2 -11
- package/lib/cjs/context/PaymentMethodContext.js +1 -1
- package/lib/cjs/index.d.ts +6 -16
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/reducers/AvailabilityReducer.d.ts +13 -23
- package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
- package/lib/cjs/reducers/OrderReducer.d.ts +36 -22
- package/lib/cjs/reducers/OrderReducer.js +1 -1
- package/lib/cjs/reducers/PaymentMethodReducer.d.ts +9 -11
- package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
- package/lib/cjs/reducers/PriceReducer.d.ts +12 -19
- package/lib/cjs/reducers/PriceReducer.js +1 -1
- package/lib/cjs/reducers/SkuReducer.d.ts +3 -3
- package/lib/cjs/typings/errors.d.ts +4 -4
- package/lib/cjs/typings/index.d.ts +3 -3
- package/lib/cjs/utils/browserInfo.d.ts +5 -2
- package/lib/cjs/utils/browserInfo.js +1 -1
- package/lib/cjs/utils/getLineItemsCount.d.ts +3 -3
- package/lib/cjs/utils/getSdk.js +1 -1
- package/lib/cjs/utils/hooks/useCustomContext.d.ts +21 -0
- package/lib/cjs/utils/hooks/useCustomContext.js +1 -0
- package/lib/esm/components/auth/CommerceLayer.d.ts +2 -2
- package/lib/esm/components/line_items/LineItem.d.ts +4 -11
- package/lib/esm/components/line_items/LineItem.js +1 -1
- package/lib/esm/components/line_items/LineItemAmount.d.ts +0 -13
- package/lib/esm/components/line_items/LineItemAmount.js +1 -1
- package/lib/esm/components/line_items/LineItemCode.d.ts +6 -11
- package/lib/esm/components/line_items/LineItemCode.js +1 -1
- package/lib/esm/components/line_items/LineItemField.d.ts +14 -0
- package/lib/esm/components/line_items/LineItemField.js +1 -0
- package/lib/esm/components/line_items/LineItemImage.d.ts +4 -11
- package/lib/esm/components/line_items/LineItemImage.js +1 -1
- package/lib/esm/components/line_items/LineItemName.d.ts +6 -11
- package/lib/esm/components/line_items/LineItemName.js +1 -1
- package/lib/esm/components/line_items/LineItemOption.d.ts +5 -16
- package/lib/esm/components/line_items/LineItemOption.js +1 -1
- package/lib/esm/components/line_items/LineItemOptions.d.ts +2 -5
- package/lib/esm/components/line_items/LineItemOptions.js +1 -1
- package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -1
- package/lib/esm/components/line_items/LineItemsContainer.d.ts +2 -14
- package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
- package/lib/esm/components/orders/AddToCartButton.d.ts +34 -9
- package/lib/esm/components/orders/AddToCartButton.js +1 -1
- package/lib/esm/components/orders/AdjustmentAmount.d.ts +2 -2
- package/lib/esm/components/orders/AdjustmentAmount.js +1 -1
- package/lib/esm/components/orders/CartLink.js +1 -1
- package/lib/esm/components/orders/CheckoutLink.js +1 -1
- package/lib/esm/components/orders/DiscountAmount.d.ts +0 -14
- package/lib/esm/components/orders/DiscountAmount.js +1 -1
- package/lib/esm/components/orders/GiftCardAmount.d.ts +0 -11
- package/lib/esm/components/orders/GiftCardAmount.js +1 -1
- package/lib/esm/components/orders/OrderContainer.js +1 -1
- package/lib/esm/components/orders/PaymentMethodAmount.d.ts +4 -0
- package/lib/esm/components/orders/PaymentMethodAmount.js +1 -0
- package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
- package/lib/esm/components/orders/PlaceOrderContainer.d.ts +2 -8
- package/lib/esm/components/orders/PlaceOrderContainer.js +1 -1
- package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +0 -6
- package/lib/esm/components/orders/PrivacyAndTermsCheckbox.js +1 -1
- package/lib/esm/components/orders/ShippingAmount.d.ts +0 -11
- package/lib/esm/components/orders/ShippingAmount.js +1 -1
- package/lib/esm/components/orders/SubTotalAmount.d.ts +0 -14
- package/lib/esm/components/orders/SubTotalAmount.js +1 -1
- package/lib/esm/components/orders/TaxesAmount.d.ts +0 -14
- package/lib/esm/components/orders/TaxesAmount.js +1 -1
- package/lib/esm/components/orders/TotalAmount.d.ts +0 -14
- package/lib/esm/components/orders/TotalAmount.js +1 -1
- package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +18 -0
- package/lib/esm/components/parcels/ParcelLineItemsCount.js +1 -0
- package/lib/esm/components/parcels/Parcels.d.ts +2 -1
- package/lib/esm/components/parcels/Parcels.js +1 -1
- package/lib/esm/components/parcels/ParcelsCount.d.ts +18 -0
- package/lib/esm/components/parcels/ParcelsCount.js +1 -0
- package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +2 -2
- package/lib/esm/components/payment_gateways/AdyenGateway.js +1 -1
- package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +2 -2
- package/lib/esm/components/payment_gateways/BraintreeGateway.js +1 -1
- package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +2 -2
- package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +2 -2
- package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
- package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +2 -2
- package/lib/esm/components/payment_gateways/StripeGateway.d.ts +2 -2
- package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +2 -2
- package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -7
- package/lib/esm/components/payment_methods/PaymentMethod.js +1 -1
- package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +6 -11
- package/lib/esm/components/payment_methods/PaymentMethodName.js +1 -1
- package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +2 -14
- package/lib/esm/components/payment_methods/PaymentMethodPrice.js +1 -1
- package/lib/esm/components/payment_methods/PaymentMethodRadioButton.d.ts +4 -9
- package/lib/esm/components/payment_methods/PaymentMethodRadioButton.js +1 -1
- package/lib/esm/components/payment_methods/PaymentMethodsContainer.d.ts +2 -8
- package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -1
- package/lib/esm/components/payment_source/AdyenPayment.d.ts +5 -5
- package/lib/esm/components/payment_source/AdyenPayment.js +1 -1
- package/lib/esm/components/payment_source/PaymentSource.d.ts +4 -11
- package/lib/esm/components/payment_source/PaymentSource.js +1 -1
- package/lib/esm/components/prices/Price.js +1 -1
- package/lib/esm/components/prices/PricesContainer.js +1 -1
- package/lib/esm/components/shipments/ShipmentsCount.d.ts +18 -0
- package/lib/esm/components/shipments/ShipmentsCount.js +1 -0
- package/lib/esm/components/skus/AvailabilityContainer.d.ts +3 -9
- package/lib/esm/components/skus/AvailabilityContainer.js +1 -1
- package/lib/esm/components/skus/AvailabilityTemplate.d.ts +23 -4
- package/lib/esm/components/skus/AvailabilityTemplate.js +1 -1
- package/lib/esm/components/skus/SkuField.js +1 -1
- package/lib/esm/components/skus/SkusContainer.d.ts +2 -2
- package/lib/esm/components/utils/AddressCardsTemplate.d.ts +3 -4
- package/lib/esm/components/utils/BaseInput.d.ts +1 -1
- package/lib/esm/components/utils/BaseOrderPrice.d.ts +3 -3
- package/lib/esm/components/utils/BaseOrderPrice.js +1 -1
- package/lib/esm/components/utils/GenericFieldComponent.d.ts +4 -4
- package/lib/esm/components/utils/GenericFieldComponent.js +1 -1
- package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +3 -3
- package/lib/esm/context/CommerceLayerContext.d.ts +2 -2
- package/lib/esm/context/CommerceLayerContext.js +1 -1
- package/lib/esm/context/ExternalFunctionContext.d.ts +2 -2
- package/lib/esm/context/ExternalFunctionContext.js +1 -1
- package/lib/esm/context/LineItemContext.d.ts +1 -1
- package/lib/esm/context/OrderContext.d.ts +2 -3
- package/lib/esm/context/OrderContext.js +1 -1
- package/lib/esm/context/PaymentMethodContext.d.ts +2 -11
- package/lib/esm/context/PaymentMethodContext.js +1 -1
- package/lib/esm/index.d.ts +6 -16
- package/lib/esm/index.js +1 -1
- package/lib/esm/reducers/AvailabilityReducer.d.ts +13 -23
- package/lib/esm/reducers/AvailabilityReducer.js +1 -1
- package/lib/esm/reducers/OrderReducer.d.ts +36 -22
- package/lib/esm/reducers/OrderReducer.js +1 -1
- package/lib/esm/reducers/PaymentMethodReducer.d.ts +9 -11
- package/lib/esm/reducers/PaymentMethodReducer.js +1 -1
- package/lib/esm/reducers/PriceReducer.d.ts +12 -19
- package/lib/esm/reducers/PriceReducer.js +1 -1
- package/lib/esm/reducers/SkuReducer.d.ts +3 -3
- package/lib/esm/typings/errors.d.ts +4 -4
- package/lib/esm/typings/index.d.ts +3 -3
- package/lib/esm/utils/browserInfo.d.ts +5 -2
- package/lib/esm/utils/browserInfo.js +1 -1
- package/lib/esm/utils/getLineItemsCount.d.ts +3 -3
- package/lib/esm/utils/getSdk.js +1 -1
- package/lib/esm/utils/hooks/useCustomContext.d.ts +21 -0
- package/lib/esm/utils/hooks/useCustomContext.js +1 -0
- package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +9 -15
- package/lib/cjs/components/orders/ItemContainer.d.ts +0 -11
- package/lib/cjs/components/orders/ItemContainer.js +0 -1
- package/lib/cjs/components/payment_methods/PaymentMethodAmount.d.ts +0 -18
- package/lib/cjs/components/payment_methods/PaymentMethodAmount.js +0 -1
- package/lib/cjs/components/skus/QuantitySelector.d.ts +0 -17
- package/lib/cjs/components/skus/QuantitySelector.js +0 -1
- package/lib/cjs/components/skus/SkuOption.d.ts +0 -14
- package/lib/cjs/components/skus/SkuOption.js +0 -1
- package/lib/cjs/components/skus/SkuOptionInput.d.ts +0 -15
- package/lib/cjs/components/skus/SkuOptionInput.js +0 -1
- package/lib/cjs/components/skus/SkuOptionsContainer.d.ts +0 -14
- package/lib/cjs/components/skus/SkuOptionsContainer.js +0 -1
- package/lib/cjs/components/skus/VariantSelector.d.ts +0 -29
- package/lib/cjs/components/skus/VariantSelector.js +0 -1
- package/lib/cjs/components/skus/VariantsContainer.d.ts +0 -20
- package/lib/cjs/components/skus/VariantsContainer.js +0 -1
- package/lib/cjs/components/utils/VariantTemplate.d.ts +0 -36
- package/lib/cjs/components/utils/VariantTemplate.js +0 -1
- package/lib/cjs/context/ItemContext.d.ts +0 -13
- package/lib/cjs/context/ItemContext.js +0 -1
- package/lib/cjs/context/SkuOptionChildrenContext.d.ts +0 -8
- package/lib/cjs/context/SkuOptionChildrenContext.js +0 -1
- package/lib/cjs/context/SkuOptionsContext.d.ts +0 -3
- package/lib/cjs/context/SkuOptionsContext.js +0 -1
- package/lib/cjs/context/VariantsContext.d.ts +0 -3
- package/lib/cjs/context/VariantsContext.js +0 -1
- package/lib/cjs/reducers/ItemReducer.d.ts +0 -69
- package/lib/cjs/reducers/ItemReducer.js +0 -1
- package/lib/cjs/reducers/SkuOptionsReducer.d.ts +0 -26
- package/lib/cjs/reducers/SkuOptionsReducer.js +0 -1
- package/lib/cjs/reducers/VariantReducer.d.ts +0 -72
- package/lib/cjs/reducers/VariantReducer.js +0 -1
- package/lib/cjs/utils/getCurrentItemKey.d.ts +0 -6
- package/lib/cjs/utils/getCurrentItemKey.js +0 -1
- package/lib/esm/components/orders/ItemContainer.d.ts +0 -11
- package/lib/esm/components/orders/ItemContainer.js +0 -1
- package/lib/esm/components/payment_methods/PaymentMethodAmount.d.ts +0 -18
- package/lib/esm/components/payment_methods/PaymentMethodAmount.js +0 -1
- package/lib/esm/components/skus/QuantitySelector.d.ts +0 -17
- package/lib/esm/components/skus/QuantitySelector.js +0 -1
- package/lib/esm/components/skus/SkuOption.d.ts +0 -14
- package/lib/esm/components/skus/SkuOption.js +0 -1
- package/lib/esm/components/skus/SkuOptionInput.d.ts +0 -15
- package/lib/esm/components/skus/SkuOptionInput.js +0 -1
- package/lib/esm/components/skus/SkuOptionsContainer.d.ts +0 -14
- package/lib/esm/components/skus/SkuOptionsContainer.js +0 -1
- package/lib/esm/components/skus/VariantSelector.d.ts +0 -29
- package/lib/esm/components/skus/VariantSelector.js +0 -1
- package/lib/esm/components/skus/VariantsContainer.d.ts +0 -20
- package/lib/esm/components/skus/VariantsContainer.js +0 -1
- package/lib/esm/components/utils/VariantTemplate.d.ts +0 -36
- package/lib/esm/components/utils/VariantTemplate.js +0 -1
- package/lib/esm/context/ItemContext.d.ts +0 -13
- package/lib/esm/context/ItemContext.js +0 -1
- package/lib/esm/context/SkuOptionChildrenContext.d.ts +0 -8
- package/lib/esm/context/SkuOptionChildrenContext.js +0 -1
- package/lib/esm/context/SkuOptionsContext.d.ts +0 -3
- package/lib/esm/context/SkuOptionsContext.js +0 -1
- package/lib/esm/context/VariantsContext.d.ts +0 -3
- package/lib/esm/context/VariantsContext.js +0 -1
- package/lib/esm/reducers/ItemReducer.d.ts +0 -69
- package/lib/esm/reducers/ItemReducer.js +0 -1
- package/lib/esm/reducers/SkuOptionsReducer.d.ts +0 -26
- package/lib/esm/reducers/SkuOptionsReducer.js +0 -1
- package/lib/esm/reducers/VariantReducer.d.ts +0 -72
- package/lib/esm/reducers/VariantReducer.js +0 -1
- package/lib/esm/utils/getCurrentItemKey.d.ts +0 -6
- package/lib/esm/utils/getCurrentItemKey.js +0 -1
|
@@ -2,8 +2,7 @@ import { BaseError } from '../typings/errors';
|
|
|
2
2
|
import { Sku } from '@commercelayer/sdk';
|
|
3
3
|
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
4
4
|
import { Dispatch } from 'react';
|
|
5
|
-
|
|
6
|
-
export declare type DeliveryLeadTime = {
|
|
5
|
+
export interface DeliveryLeadTime {
|
|
7
6
|
shipping_method: {
|
|
8
7
|
name: string;
|
|
9
8
|
reference: string;
|
|
@@ -14,26 +13,27 @@ export declare type DeliveryLeadTime = {
|
|
|
14
13
|
};
|
|
15
14
|
min: LeadTimes;
|
|
16
15
|
max: LeadTimes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
delivery_lead_times: Partial<DeliveryLeadTime
|
|
16
|
+
}
|
|
17
|
+
interface Level {
|
|
18
|
+
delivery_lead_times: Array<Partial<DeliveryLeadTime>>;
|
|
20
19
|
quantity: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
20
|
+
}
|
|
21
|
+
interface Inventory {
|
|
23
22
|
inventory: {
|
|
24
23
|
available: boolean;
|
|
25
24
|
quantity: number;
|
|
26
25
|
levels: Level[];
|
|
27
26
|
};
|
|
28
|
-
}
|
|
27
|
+
}
|
|
29
28
|
export declare type SkuInventory = Sku & Inventory;
|
|
30
|
-
export
|
|
29
|
+
export interface LeadTimes {
|
|
31
30
|
hours: number;
|
|
32
31
|
days: number;
|
|
33
|
-
}
|
|
32
|
+
}
|
|
34
33
|
export declare type AvailabilityPayload = {
|
|
35
|
-
quantity?: number
|
|
34
|
+
quantity?: number;
|
|
36
35
|
errors?: BaseError[];
|
|
36
|
+
parent?: boolean;
|
|
37
37
|
} & Partial<DeliveryLeadTime>;
|
|
38
38
|
export declare type AvailabilityState = AvailabilityPayload;
|
|
39
39
|
export interface AvailabilityAction {
|
|
@@ -41,21 +41,11 @@ export interface AvailabilityAction {
|
|
|
41
41
|
payload: AvailabilityPayload;
|
|
42
42
|
}
|
|
43
43
|
export declare const availabilityInitialState: AvailabilityState;
|
|
44
|
-
declare
|
|
44
|
+
export declare function getAvailability({ skuCode, dispatch, config }: {
|
|
45
45
|
skuCode: string;
|
|
46
46
|
dispatch: Dispatch<AvailabilityAction>;
|
|
47
47
|
config: CommerceLayerConfig;
|
|
48
|
-
|
|
49
|
-
item?: Items;
|
|
50
|
-
}) => void;
|
|
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>;
|
|
48
|
+
}): Promise<void>;
|
|
59
49
|
export declare type AvailabilityActionType = 'setAvailability' | 'setErrors';
|
|
60
50
|
declare const availabilityReducer: (state: AvailabilityState, reducer: AvailabilityAction) => AvailabilityState;
|
|
61
51
|
export default availabilityReducer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAvailability=exports.availabilityInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.availabilityInitialState={};async function getAvailability({skuCode,dispatch,config}){const sdk=(0,getSdk_1.default)(config);try{const[sku]=await sdk.skus.list({fields:{skus:["id"]},filters:{code_in:skuCode}});if(sku){const skuInventory=await sdk.skus.retrieve(sku.id,{fields:{skus:["inventory"]}}),[level]=skuInventory.inventory?.levels||[],[delivery]=level?.delivery_lead_times||[];dispatch({type:"setAvailability",payload:{...delivery,quantity:skuInventory.inventory.quantity}})}}catch(error){console.error("Get SKU availability",error)}}exports.getAvailability=getAvailability;const typeAction=["setAvailability","setErrors"],availabilityReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,typeAction);exports.default=availabilityReducer;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'react';
|
|
2
2
|
import { SetLocalOrder, DeleteLocalOrder } from '../utils/localStorage';
|
|
3
3
|
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
4
|
-
import { ItemOption, CustomLineItem } from './ItemReducer';
|
|
5
4
|
import { BaseMetadataObject } from '../typings/index';
|
|
6
5
|
import { BaseError } from '../typings/errors';
|
|
7
6
|
import { AddressResource } from './AddressReducer';
|
|
@@ -18,24 +17,6 @@ export declare type GetOrderParams = Partial<{
|
|
|
18
17
|
export declare type GetOrder = (params: GetOrderParams) => Promise<undefined | Order>;
|
|
19
18
|
declare type CreateOrderParams = Pick<AddToCartParams, 'config' | 'dispatch' | 'persistKey' | 'state' | 'orderMetadata' | 'orderAttributes' | 'setLocalOrder'>;
|
|
20
19
|
export declare type CreateOrder = (params?: CreateOrderParams) => Promise<string>;
|
|
21
|
-
export declare type AddToCartParams = Partial<{
|
|
22
|
-
bundleCode: string;
|
|
23
|
-
skuCode: string;
|
|
24
|
-
persistKey: string;
|
|
25
|
-
config: CommerceLayerConfig;
|
|
26
|
-
dispatch: Dispatch<OrderActions>;
|
|
27
|
-
state: Partial<OrderState>;
|
|
28
|
-
skuId: string;
|
|
29
|
-
quantity: number;
|
|
30
|
-
option: ItemOption;
|
|
31
|
-
lineItem: CustomLineItem;
|
|
32
|
-
orderMetadata: BaseMetadataObject;
|
|
33
|
-
orderAttributes: Record<string, any>;
|
|
34
|
-
errors: BaseError[];
|
|
35
|
-
setLocalOrder: SetLocalOrder;
|
|
36
|
-
buyNowMode: boolean;
|
|
37
|
-
checkoutUrl: string;
|
|
38
|
-
}>;
|
|
39
20
|
export interface AddToCartImportParams extends Omit<AddToCartParams, 'skuCode' | 'skuId' | 'quantity' | 'option' | 'lineItem'> {
|
|
40
21
|
lineItems: CustomLineItem[];
|
|
41
22
|
}
|
|
@@ -43,7 +24,6 @@ export declare type AddToCartReturn = Promise<{
|
|
|
43
24
|
success: boolean;
|
|
44
25
|
orderId: string | undefined;
|
|
45
26
|
}>;
|
|
46
|
-
export declare type AddToCart = (params: AddToCartParams) => AddToCartReturn;
|
|
47
27
|
export declare type AddToCartImport = (params: AddToCartImportParams) => AddToCartReturn;
|
|
48
28
|
export declare type UnsetOrderState = (dispatch: Dispatch<OrderActions>) => void;
|
|
49
29
|
export declare type ResourceIncluded = 'billing_address' | 'shipping_address' | 'line_items.line_item_options.sku_option' | 'line_items.item' | 'available_customer_payment_sources.payment_source' | 'shipments.available_shipping_methods' | 'shipments.stock_transfers' | 'shipments.stock_transfers.line_item' | 'shipments.shipment_line_items.line_item' | 'shipments.shipping_method' | 'shipments.stock_location' | 'shipments.parcels' | 'shipments.parcels.parcel_line_items' | 'payment_source' | 'available_payment_methods' | 'payment_method';
|
|
@@ -57,7 +37,6 @@ export interface OrderPayload {
|
|
|
57
37
|
includeLoaded?: ResourceIncludedLoaded;
|
|
58
38
|
withoutIncludes?: boolean;
|
|
59
39
|
}
|
|
60
|
-
export declare type AddToCartValues = Pick<AddToCartParams, 'bundleCode' | 'lineItem' | 'quantity' | 'skuCode' | 'skuId' | 'option' | 'buyNowMode' | 'checkoutUrl'>;
|
|
61
40
|
export declare type AddToCartImportValues = Pick<AddToCartImportParams, 'lineItems'>;
|
|
62
41
|
export declare type getOrderContext = (id: string) => Promise<undefined | Order>;
|
|
63
42
|
export declare type OrderState = Partial<OrderPayload>;
|
|
@@ -89,7 +68,42 @@ export interface AddResourceToInclude {
|
|
|
89
68
|
newResourceLoaded?: ResourceIncludedLoaded;
|
|
90
69
|
}
|
|
91
70
|
export declare function addResourceToInclude({ resourcesIncluded, dispatch, newResource, newResourceLoaded, resourceIncludedLoaded }: AddResourceToInclude): void;
|
|
92
|
-
export
|
|
71
|
+
export interface LineItemOption {
|
|
72
|
+
/**
|
|
73
|
+
* SKU Option ID. Ex: mNJEgsJwBn
|
|
74
|
+
*/
|
|
75
|
+
skuOptionId: string;
|
|
76
|
+
/**
|
|
77
|
+
* Set of key-value pairs that represent the selected options. Ex: { message: 'This is a option message' }
|
|
78
|
+
*/
|
|
79
|
+
options: Record<string, string>;
|
|
80
|
+
quantity?: number;
|
|
81
|
+
}
|
|
82
|
+
export interface CustomLineItem {
|
|
83
|
+
name?: string;
|
|
84
|
+
imageUrl?: string | null;
|
|
85
|
+
}
|
|
86
|
+
export declare type AddToCartParams = Partial<{
|
|
87
|
+
bundleCode: string;
|
|
88
|
+
skuCode: string;
|
|
89
|
+
persistKey: string;
|
|
90
|
+
config: CommerceLayerConfig;
|
|
91
|
+
dispatch: Dispatch<OrderActions>;
|
|
92
|
+
state: Partial<OrderState>;
|
|
93
|
+
quantity: number;
|
|
94
|
+
lineItemOption: LineItemOption;
|
|
95
|
+
lineItem: CustomLineItem;
|
|
96
|
+
orderMetadata: BaseMetadataObject;
|
|
97
|
+
orderAttributes: Record<string, any>;
|
|
98
|
+
errors: BaseError[];
|
|
99
|
+
setLocalOrder: SetLocalOrder;
|
|
100
|
+
buyNowMode: boolean;
|
|
101
|
+
checkoutUrl: string;
|
|
102
|
+
}>;
|
|
103
|
+
export declare function addToCart(params: AddToCartParams): Promise<{
|
|
104
|
+
success: boolean;
|
|
105
|
+
orderId?: string;
|
|
106
|
+
}>;
|
|
93
107
|
export declare const unsetOrderState: UnsetOrderState;
|
|
94
108
|
interface OrderErrors {
|
|
95
109
|
dispatch?: Dispatch<OrderActions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.orderInitialState=exports.removeGiftCardOrCouponCode=exports.setGiftCardOrCouponCode=exports.saveAddressToCustomerAddressBook=exports.setOrderErrors=exports.unsetOrderState=exports.addToCart=exports.addResourceToInclude=exports.setOrder=exports.updateOrder=exports.getApiOrder=exports.createOrder=void 0;const tslib_1=require("tslib"),localStorage_1=require("../utils/localStorage"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.orderInitialState=exports.removeGiftCardOrCouponCode=exports.setGiftCardOrCouponCode=exports.saveAddressToCustomerAddressBook=exports.setOrderErrors=exports.unsetOrderState=exports.addToCart=exports.addResourceToInclude=exports.setOrder=exports.updateOrder=exports.getApiOrder=exports.createOrder=void 0;const tslib_1=require("tslib"),localStorage_1=require("../utils/localStorage"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),organization_1=tslib_1.__importDefault(require("../utils/organization")),actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"],createOrder=async params=>{if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=(0,getSdk_1.default)(config);try{const o=await sdk?.orders.create({metadata,...orderAttributes});return dispatch&&dispatch({type:"setOrderId",payload:{orderId:o?.id}}),persistKey&&setLocalOrder&&setLocalOrder(persistKey,o.id),o.id}catch(error){const errors=(0,getErrors_1.default)(error,"orders");console.error("Create order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""};exports.createOrder=createOrder;const getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=(0,getSdk_1.default)(config);try{const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.status==="placed"||clearWhenPlaced&&order.status==="approved"||clearWhenPlaced&&order.status==="cancelled"?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=(0,getErrors_1.default)(error,"orders");console.error("Retrieve order",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors,dispatch});return}};exports.getApiOrder=getApiOrder;async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=(0,getSdk_1.default)(config);try{const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await(0,exports.getApiOrder)({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0}}catch(error){const errors=(0,getErrors_1.default)(error,"orders");return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}exports.updateOrder=updateOrder;const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};exports.setOrder=setOrder;function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...resourcesIncluded,...resources],resources.forEach(resource=>{const includeLoaded={...payload.includeLoaded,[resource]:!0};payload.includeLoaded=includeLoaded})}else delete payload.include;const payloadIncludeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded};payload.includeLoaded=payloadIncludeLoaded,dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}exports.addResourceToInclude=addResourceToInclude;async function addToCart(params){const{skuCode,bundleCode,quantity,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl,lineItemOption}=params;try{if(config){const sdk=(0,getSdk_1.default)(config),id=await(0,exports.createOrder)(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items:lineItems}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});lineItems&&lineItems?.length>0&&await Promise.all(lineItems.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity??1,_update_quantity:!0,bundle_code:bundleCode},newLineItem=await sdk.line_items.create(attrs);if(lineItemOption!=null){const{skuOptionId,options,quantity:quantity2}=lineItemOption,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:quantity2??1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),await(0,exports.getApiOrder)({id,...params})}else await(0,exports.getApiOrder)({id,...params,state});if(!(0,isEmpty_1.default)(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=(0,organization_1.default)(config.endpoint??""),params2=`${id}?accessToken=${config.accessToken??""}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}return{success:!0,orderId:id}}}return{success:!1}}catch(error){const errors2=(0,getErrors_1.default)(error,"orders");return console.error("Add to cart",errors2),dispatch&&(0,getErrors_1.setErrors)({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1}}}exports.addToCart=addToCart;const unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};exports.unsetOrderState=unsetOrderState;function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}exports.setOrderErrors=setOrderErrors;const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value.toString()}`;(0,localStorage_1.setCustomerOrderParam)(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})};exports.saveAddressToCustomerAddressBook=saveAddressToCustomerAddressBook;const setGiftCardOrCouponCode=async({code,codeType,dispatch,config,order,include,state})=>{try{if(config&&order&&code&&dispatch){const attributes={[codeType]:code},{success,error}=await updateOrder({id:order.id,attributes,config,include,dispatch,state});if(!success)throw error;return dispatch({type:"setErrors",payload:{errors:[]}}),{success}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",codeType);return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}};exports.setGiftCardOrCouponCode=setGiftCardOrCouponCode;const removeGiftCardOrCouponCode=async({codeType,dispatch,config,order,include,state})=>{try{if(config&&order&&dispatch){const attributes={[codeType]:""};return await updateOrder({id:order.id,attributes,config,include,dispatch,state}),dispatch({type:"setErrors",payload:{errors:[]}}),{success:!0}}return{success:!1}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",codeType);return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}};exports.removeGiftCardOrCouponCode=removeGiftCardOrCouponCode,exports.orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,actionType);exports.default=orderReducer;
|
|
@@ -10,14 +10,14 @@ import { Order, PaymentMethod, StripePayment, WireTransfer, AdyenPayment, Braint
|
|
|
10
10
|
import { Dispatch, MutableRefObject } from 'react';
|
|
11
11
|
import { CheckoutComConfig } from '../components/payment_source/CheckoutComPayment';
|
|
12
12
|
export declare type PaymentSourceType = AdyenPayment | BraintreePayment | CheckoutComPayment | ExternalPayment | PaypalPayment | StripePayment | WireTransfer;
|
|
13
|
-
|
|
13
|
+
interface Card {
|
|
14
14
|
type: string;
|
|
15
15
|
brand: string;
|
|
16
16
|
last4: string;
|
|
17
17
|
exp_year: number;
|
|
18
18
|
exp_month: number;
|
|
19
|
-
}
|
|
20
|
-
export
|
|
19
|
+
}
|
|
20
|
+
export interface PaymentSourceObject {
|
|
21
21
|
adyen_payments: AdyenPayment & {
|
|
22
22
|
payment_request_data?: {
|
|
23
23
|
payment_method?: Card;
|
|
@@ -51,7 +51,7 @@ export declare type PaymentSourceObject = {
|
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
klarna_payments: KlarnaPayment;
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
export declare type PaymentMethodActionType = 'setErrors' | 'setPaymentMethods' | 'setPaymentMethodConfig' | 'setPaymentSource' | 'setPaymentRef' | 'setLoading';
|
|
56
56
|
export declare type PaymentRef = MutableRefObject<null | HTMLFormElement>;
|
|
57
57
|
export interface PaymentMethodActionPayload {
|
|
@@ -64,7 +64,7 @@ export interface PaymentMethodActionPayload {
|
|
|
64
64
|
paymentSource: PaymentSourceTypes;
|
|
65
65
|
loading: boolean;
|
|
66
66
|
}
|
|
67
|
-
export declare function setLoading({ loading, dispatch
|
|
67
|
+
export declare function setLoading({ loading, dispatch }: {
|
|
68
68
|
loading: boolean;
|
|
69
69
|
dispatch?: Dispatch<PaymentMethodAction>;
|
|
70
70
|
}): void;
|
|
@@ -79,9 +79,7 @@ export interface PaymentMethodAction {
|
|
|
79
79
|
payload: Partial<PaymentMethodActionPayload>;
|
|
80
80
|
}
|
|
81
81
|
export declare const paymentMethodInitialState: PaymentMethodState;
|
|
82
|
-
export
|
|
83
|
-
<V extends BaseError[]>(errors: V, dispatch?: Dispatch<PaymentMethodAction>): void;
|
|
84
|
-
}
|
|
82
|
+
export declare type SetPaymentMethodErrors = <V extends BaseError[]>(errors: V, dispatch?: Dispatch<PaymentMethodAction>) => void;
|
|
85
83
|
export declare const setPaymentMethodErrors: SetPaymentMethodErrors;
|
|
86
84
|
declare type GetPaymentMethods = (args: {
|
|
87
85
|
order: Order;
|
|
@@ -118,7 +116,7 @@ export declare type SetPaymentSource = (args: {
|
|
|
118
116
|
paymentSourceId?: string;
|
|
119
117
|
customerPaymentSourceId?: string;
|
|
120
118
|
updateOrder?: typeof updateOrder;
|
|
121
|
-
} & PaymentMethodState) => Promise<PaymentSourceType |
|
|
119
|
+
} & PaymentMethodState) => Promise<PaymentSourceType | undefined>;
|
|
122
120
|
export declare const setPaymentSource: SetPaymentSource;
|
|
123
121
|
export declare type UpdatePaymentSource = (args: {
|
|
124
122
|
id: string;
|
|
@@ -136,7 +134,7 @@ export declare type DestroyPaymentSource = (args: {
|
|
|
136
134
|
orderId?: string;
|
|
137
135
|
}) => Promise<void>;
|
|
138
136
|
export declare const destroyPaymentSource: DestroyPaymentSource;
|
|
139
|
-
export
|
|
137
|
+
export interface PaymentMethodConfig {
|
|
140
138
|
stripePayment?: StripeConfig;
|
|
141
139
|
braintreePayment?: BraintreeConfig;
|
|
142
140
|
wireTransfer?: Partial<WireTransferConfig>;
|
|
@@ -144,7 +142,7 @@ export declare type PaymentMethodConfig = {
|
|
|
144
142
|
adyenPayment?: AdyenPaymentConfig;
|
|
145
143
|
checkoutComPayment?: CheckoutComConfig;
|
|
146
144
|
klarnaPayment?: Pick<AdyenPaymentConfig, 'placeOrderCallback'> & Pick<StripeConfig, 'containerClassName'>;
|
|
147
|
-
}
|
|
145
|
+
}
|
|
148
146
|
declare type SetPaymentMethodConfig = (config: PaymentMethodConfig, dispatch: Dispatch<PaymentMethodAction>) => void;
|
|
149
147
|
export declare const setPaymentMethodConfig: SetPaymentMethodConfig;
|
|
150
148
|
export declare function getPaymentConfig<K extends PaymentResourceKey>(paymentResource: PaymentResource, config: PaymentMethodConfig): PaymentMethodConfig[K];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPaymentConfig=exports.setPaymentMethodConfig=exports.destroyPaymentSource=exports.updatePaymentSource=exports.setPaymentSource=exports.setPaymentMethod=exports.getPaymentMethods=exports.setPaymentMethodErrors=exports.paymentMethodInitialState=exports.setPaymentRef=exports.setLoading=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),camelCase_1=tslib_1.__importDefault(require("lodash/camelCase")),has_1=tslib_1.__importDefault(require("lodash/has")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty"));function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}exports.setLoading=setLoading;const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})};exports.setPaymentRef=setPaymentRef,exports.paymentMethodInitialState={errors:[]};const setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})};exports.setPaymentMethodErrors=setPaymentMethodErrors;const getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod?.id,currentPaymentMethodType:paymentMethod?.payment_source_type,paymentSource}})};exports.getPaymentMethods=getPaymentMethods;const setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:(0,getSdk_1.default)(config).payment_methods.relationship(paymentMethodId)};updateOrder&&await updateOrder({id:order.id,attributes}),dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",paymentResource);console.error("Set payment method",errors)}};exports.setPaymentMethod=setPaymentMethod;const setPaymentSource=async({config,dispatch,getOrder,attributes
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPaymentConfig=exports.setPaymentMethodConfig=exports.destroyPaymentSource=exports.updatePaymentSource=exports.setPaymentSource=exports.setPaymentMethod=exports.getPaymentMethods=exports.setPaymentMethodErrors=exports.paymentMethodInitialState=exports.setPaymentRef=exports.setLoading=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getErrors_1=tslib_1.__importStar(require("../utils/getErrors")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),camelCase_1=tslib_1.__importDefault(require("lodash/camelCase")),has_1=tslib_1.__importDefault(require("lodash/has")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty"));function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}exports.setLoading=setLoading;const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})};exports.setPaymentRef=setPaymentRef,exports.paymentMethodInitialState={errors:[],paymentMethods:void 0};const setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})};exports.setPaymentMethodErrors=setPaymentMethodErrors;const getPaymentMethods=async({order,dispatch})=>{const paymentMethods=order.available_payment_methods,paymentMethod=order.payment_method,paymentSource=order.payment_source;dispatch({type:"setPaymentMethods",payload:{paymentMethods,currentPaymentMethodId:paymentMethod?.id,currentPaymentMethodType:paymentMethod?.payment_source_type,paymentSource}})};exports.getPaymentMethods=getPaymentMethods;const setPaymentMethod=async({config,dispatch,order,paymentMethodId,updateOrder,setOrderErrors,paymentResource})=>{try{if(config&&order&&dispatch&&paymentResource){localStorage.removeItem("_save_payment_source_to_customer_wallet");const attributes={payment_method:(0,getSdk_1.default)(config).payment_methods.relationship(paymentMethodId)};updateOrder&&await updateOrder({id:order.id,attributes}),dispatch({type:"setPaymentMethods",payload:{currentPaymentMethodId:paymentMethodId,currentPaymentMethodType:paymentResource,errors:[]}}),setOrderErrors&&setOrderErrors([])}}catch(error){const errors=(0,getErrors_1.default)(error,"orders",paymentResource);console.error("Set payment method",errors)}};exports.setPaymentMethod=setPaymentMethod;const setPaymentSource=async({config,dispatch,getOrder,attributes,order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=(0,getSdk_1.default)(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs={id:paymentSourceId,...attributes};paymentSource=attributes!=null?await sdk[paymentResource].update(attrs):sdk[paymentResource].retrieve(paymentSourceId)}else{const attrs={...attributes,order:sdk.orders.relationship(order.id)};paymentSource=await sdk[paymentResource].create(attrs)}return getOrder&&await getOrder(order.id),dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource,errors:[]}}),paymentSource}}}catch(error){const errors=(0,getErrors_1.default)(error,"payment_methods",paymentResource);console.error("Set payment source:",errors),dispatch&&(0,getErrors_1.setErrors)({currentErrors,newErrors:errors,dispatch})}};exports.setPaymentSource=setPaymentSource;const updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await(0,getSdk_1.default)(config)[paymentResource].update({id,...attributes});dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}};exports.updatePaymentSource=updatePaymentSource;const destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})};exports.destroyPaymentSource=destroyPaymentSource;const setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};exports.setPaymentMethodConfig=setPaymentMethodConfig;function getPaymentConfig(paymentResource,config){const resource=(0,camelCase_1.default)(paymentResource).replace("Payments","Payment").replace("Transfers","Transfer");return!(0,isEmpty_1.default)(config)&&(0,has_1.default)(config,resource)?config[resource]:void 0}exports.getPaymentConfig=getPaymentConfig;const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=paymentMethodReducer;
|
|
@@ -2,42 +2,35 @@ import { BaseAction, LoaderType } from '../typings/index';
|
|
|
2
2
|
import { Price } from '@commercelayer/sdk';
|
|
3
3
|
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
4
4
|
import { Dispatch } from 'react';
|
|
5
|
-
import { ItemPrices } from './ItemReducer';
|
|
6
5
|
import { BaseError } from '../typings/errors';
|
|
7
6
|
export interface Prices {
|
|
8
7
|
[key: string]: Price | Price[];
|
|
9
8
|
}
|
|
10
9
|
declare type SkuCodesPrice = string[];
|
|
11
|
-
export interface SetSkuCodesPrice {
|
|
12
|
-
(skuCodes: SkuCodesPrice): void;
|
|
13
|
-
}
|
|
14
10
|
export interface PriceState {
|
|
15
11
|
loading: boolean;
|
|
16
12
|
prices: Prices;
|
|
17
13
|
skuCodes: SkuCodesPrice;
|
|
18
14
|
errors?: BaseError[];
|
|
19
15
|
skuCode?: string;
|
|
20
|
-
setSkuCodes?:
|
|
16
|
+
setSkuCodes?: typeof setSkuCodes;
|
|
21
17
|
loader?: LoaderType;
|
|
22
18
|
}
|
|
23
19
|
export interface PriceAction extends BaseAction {
|
|
24
20
|
type: PriceActionType;
|
|
25
21
|
}
|
|
26
22
|
export declare const priceInitialState: PriceState;
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
export declare
|
|
38
|
-
export interface UnsetPriceState {
|
|
39
|
-
(dispatch: Dispatch<PriceAction>): void;
|
|
40
|
-
}
|
|
23
|
+
export declare function setSkuCodes({ skuCodes, dispatch }: {
|
|
24
|
+
skuCodes: SkuCodesPrice;
|
|
25
|
+
dispatch?: Dispatch<PriceAction>;
|
|
26
|
+
}): void;
|
|
27
|
+
export declare function getSkusPrice(skuCodes: SkuCodesPrice, { config, dispatch, perPage, filters }: {
|
|
28
|
+
config: CommerceLayerConfig;
|
|
29
|
+
dispatch: Dispatch<PriceAction>;
|
|
30
|
+
perPage: number;
|
|
31
|
+
filters: Record<string, any>;
|
|
32
|
+
}): void;
|
|
33
|
+
export declare type UnsetPriceState = (dispatch: Dispatch<PriceAction>) => void;
|
|
41
34
|
export declare const unsetPriceState: UnsetPriceState;
|
|
42
35
|
export declare type PriceActionType = 'setLoading' | 'setPrices' | 'setSkuCodes' | 'setErrors';
|
|
43
36
|
declare const priceReducer: (state: PriceState, reducer: PriceAction) => PriceState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unsetPriceState=exports.getSkusPrice=exports.priceInitialState=void 0;const tslib_1=require("tslib"),getPrices_1=tslib_1.__importDefault(require("../utils/getPrices")),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors"));exports.priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unsetPriceState=exports.getSkusPrice=exports.setSkuCodes=exports.priceInitialState=void 0;const tslib_1=require("tslib"),getPrices_1=tslib_1.__importDefault(require("../utils/getPrices")),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk")),getErrors_1=tslib_1.__importDefault(require("../utils/getErrors"));exports.priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]};function setSkuCodes({skuCodes,dispatch}){dispatch&&dispatch({type:"setSkuCodes",payload:{skuCodes}})}exports.setSkuCodes=setSkuCodes;function getSkusPrice(skuCodes,{config,dispatch,perPage,filters}){let allPrices={};const sdk=(0,getSdk_1.default)(config);sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage}).then(async response=>{const pricesObj=(0,getPrices_1.default)(response);allPrices={...allPrices,...pricesObj},dispatch({type:"setPrices",payload:{prices:allPrices}}),dispatch({type:"setLoading",payload:{loading:!1}});const meta=response.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const pageResponse=await sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage,pageNumber}),pricesObj2=(0,getPrices_1.default)(pageResponse);allPrices={...allPrices,...pricesObj2},dispatch({type:"setPrices",payload:{prices:allPrices}})}}).catch(error=>{const errors=(0,getErrors_1.default)(error,"prices");dispatch({type:"setErrors",payload:{errors}})})}exports.getSkusPrice=getSkusPrice;const unsetPriceState=dispatch=>{dispatch({type:"setPrices",payload:{prices:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})};exports.unsetPriceState=unsetPriceState;const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"],priceReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,typeAction);exports.default=priceReducer;
|
|
@@ -10,12 +10,12 @@ export declare type SkuState = Partial<{
|
|
|
10
10
|
skuCodes: string[];
|
|
11
11
|
}>;
|
|
12
12
|
export declare const skuInitialState: SkuState;
|
|
13
|
-
|
|
13
|
+
interface GetSku {
|
|
14
14
|
config: CommerceLayerConfig;
|
|
15
15
|
skus: string[];
|
|
16
16
|
dispatch: Dispatch<SkuAction>;
|
|
17
17
|
queryParams?: QueryParamsList;
|
|
18
|
-
}
|
|
19
|
-
export declare function getSku<T extends GetSku>({ config, skus, dispatch, queryParams
|
|
18
|
+
}
|
|
19
|
+
export declare function getSku<T extends GetSku>({ config, skus, dispatch, queryParams }: T): Promise<void>;
|
|
20
20
|
export default function skuReducer(state: SkuState, reducer: SkuAction): SkuState;
|
|
21
21
|
export {};
|
|
@@ -27,7 +27,7 @@ export declare const ErrorPropTypes: {
|
|
|
27
27
|
declare type ErrorChildrenComponentProps = ChildrenFunction<Omit<ErrorComponentProps, 'children'> & {
|
|
28
28
|
errors: string[];
|
|
29
29
|
}>;
|
|
30
|
-
export
|
|
30
|
+
export interface ErrorComponentProps {
|
|
31
31
|
/**
|
|
32
32
|
* Resource which caused the error
|
|
33
33
|
*/
|
|
@@ -40,12 +40,12 @@ export declare type ErrorComponentProps = {
|
|
|
40
40
|
/**
|
|
41
41
|
* Error message which you can translate
|
|
42
42
|
*/
|
|
43
|
-
messages?: {
|
|
43
|
+
messages?: Array<{
|
|
44
44
|
code: CodeErrorType;
|
|
45
45
|
message: string;
|
|
46
46
|
resource?: ResourceErrorType;
|
|
47
47
|
field?: string;
|
|
48
48
|
id?: string;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
51
|
export {};
|
|
@@ -109,13 +109,13 @@ export declare const baseOrderComponentPricePropTypes: {
|
|
|
109
109
|
export declare type BasePriceType = 'total' | 'option' | 'unit';
|
|
110
110
|
export declare type BaseSelectorType = 'select' | 'radio';
|
|
111
111
|
export declare type BaseAmountComponentChildren = Omit<BaseAmountComponent, 'children'>;
|
|
112
|
-
export
|
|
113
|
-
children?:
|
|
112
|
+
export interface BaseAmountComponent extends Omit<JSX.IntrinsicElements['span'], 'children'> {
|
|
113
|
+
children?: ChildrenFunction<BaseAmountComponentChildren>;
|
|
114
114
|
format?: BaseFormatPrice;
|
|
115
115
|
price?: string;
|
|
116
116
|
priceCents?: number;
|
|
117
117
|
labelFree?: string;
|
|
118
|
-
}
|
|
118
|
+
}
|
|
119
119
|
export declare type ChildrenFunction<P = Record<string, any>> = (props: P) => JSX.Element;
|
|
120
120
|
export declare type ExcludeTag<T extends keyof JSX.IntrinsicElements> = Exclude<keyof JSX.IntrinsicElements, T>;
|
|
121
121
|
export declare type ExtractTag<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements, T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
interface TReturn {
|
|
2
2
|
screenWidth: string | number;
|
|
3
3
|
screenHeight: string | number;
|
|
4
4
|
colorDepth: string | number;
|
|
@@ -6,4 +6,7 @@ export default function getBrowserInfo(): {
|
|
|
6
6
|
timeZoneOffset: number;
|
|
7
7
|
language: string;
|
|
8
8
|
javaEnabled: boolean;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
|
+
export default function getBrowserInfo(): TReturn;
|
|
11
|
+
export declare function cleanUrlBy(symbol?: string): string;
|
|
12
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function getBrowserInfo(){const screenWidth=window
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cleanUrlBy=void 0;function getBrowserInfo(){const screenWidth=window?.screen?window.screen.width:"",screenHeight=window?.screen?window.screen.height:"",colorDepth=window?.screen?window.screen.colorDepth:"",userAgent=window?.navigator?window.navigator.userAgent:"",javaEnabled=window?.navigator?navigator.javaEnabled():!1;let language="";window?.navigator&&(language=window.navigator.language);const timeZoneOffset=new Date().getTimezoneOffset();return{screenWidth,screenHeight,colorDepth,userAgent,timeZoneOffset,language,javaEnabled}}exports.default=getBrowserInfo;function cleanUrlBy(symbol="&"){const currentLocation=window?.location.href,[splitLocation]=currentLocation.split(symbol);return splitLocation??currentLocation}exports.cleanUrlBy=cleanUrlBy;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LineItem } from '@commercelayer/sdk';
|
|
2
2
|
import { LineItemType } from '../typings/index';
|
|
3
3
|
export declare type TypeAccepted = Extract<LineItemType, 'skus' | 'gift_cards' | 'bundles' | 'adjustments'>;
|
|
4
|
-
|
|
4
|
+
interface Args {
|
|
5
5
|
lineItems: LineItem[];
|
|
6
6
|
quantity?: number;
|
|
7
7
|
typeAccepted?: TypeAccepted[];
|
|
8
|
-
}
|
|
9
|
-
export default function getLineItemsCount({ lineItems, quantity, typeAccepted
|
|
8
|
+
}
|
|
9
|
+
export default function getLineItemsCount({ lineItems, quantity, typeAccepted }: Args): number;
|
|
10
10
|
export {};
|
package/lib/cjs/utils/getSdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),organization_1=tslib_1.__importDefault(require("./organization")),sdk_1=tslib_1.__importDefault(require("@commercelayer/sdk"));function getSdk({endpoint,accessToken}){const org=(0,organization_1.default)(endpoint);return(0,sdk_1.default)({accessToken,...org})}exports.default=getSdk;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),organization_1=tslib_1.__importDefault(require("./organization")),sdk_1=tslib_1.__importDefault(require("@commercelayer/sdk"));function getSdk({endpoint,accessToken}){if(accessToken==null||endpoint==null)throw new Error("accessToken and endpoint are required parameters");const org=(0,organization_1.default)(endpoint);return(0,sdk_1.default)({accessToken,...org})}exports.default=getSdk;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Context } from 'react';
|
|
2
|
+
interface TParams<C> {
|
|
3
|
+
/**
|
|
4
|
+
* Context to check
|
|
5
|
+
*/
|
|
6
|
+
context: Context<C>;
|
|
7
|
+
/**
|
|
8
|
+
* Name of the component has the context
|
|
9
|
+
*/
|
|
10
|
+
contextComponentName: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name of the current component
|
|
13
|
+
*/
|
|
14
|
+
currentComponentName: string;
|
|
15
|
+
/**
|
|
16
|
+
* Key of the context to check
|
|
17
|
+
*/
|
|
18
|
+
key?: string;
|
|
19
|
+
}
|
|
20
|
+
export default function useCustomContext<T>({ context, key, currentComponentName, contextComponentName }: TParams<T>): T;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const react_1=require("react");function useCustomContext({context,key,currentComponentName,contextComponentName}){const currentContext=(0,react_1.useContext)(context),isProduction=process.env.NODE_ENV==="production",msg=`Cannot use <${currentComponentName}/> outside of <${contextComponentName}/>`;if(key!=null&&key in currentContext||key==null&¤tContext!=null)return currentContext;if(isProduction)console.error(msg);else throw new Error(msg);return currentContext}exports.default=useCustomContext;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
interface Props {
|
|
3
3
|
children: JSX.Element[] | JSX.Element;
|
|
4
4
|
accessToken: string;
|
|
5
5
|
endpoint: string;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
export declare function CommerceLayer(props: Props): JSX.Element;
|
|
8
8
|
export default CommerceLayer;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { LineItemType } from '../../typings/index';
|
|
3
|
-
|
|
4
|
-
children:
|
|
3
|
+
interface Props {
|
|
4
|
+
children: JSX.Element | JSX.Element[];
|
|
5
5
|
type?: LineItemType;
|
|
6
|
-
};
|
|
7
|
-
export declare function LineItem(props: Props): JSX.Element;
|
|
8
|
-
export declare namespace LineItem {
|
|
9
|
-
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
|
-
type: import("prop-types").Requireable<LineItemType>;
|
|
12
|
-
};
|
|
13
|
-
var displayName: string;
|
|
14
6
|
}
|
|
7
|
+
export declare function LineItem(props: Props): JSX.Element;
|
|
15
8
|
export default LineItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemContext from"../../context/LineItemContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useContext}from"react";import LineItemContext from"../../context/LineItemContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";export function LineItem(props){const{type="skus",children}=props,{lineItems}=useContext(LineItemContext),{lineItems:shipmentLineItems}=useContext(ShipmentChildrenContext),components=(shipmentLineItems&&shipmentLineItems?.length>0?shipmentLineItems:lineItems)?.filter(l=>l.item_type===type).map((lineItem,k,check)=>{if(lineItem.item_type==="bundles"&&k>0&&check[k-1]?.bundle_code===lineItem.bundle_code||lineItem.item_type==="gift_cards"&&lineItem?.total_amount_cents&&lineItem?.total_amount_cents<=0)return null;const lineProps={lineItem};return _jsx(LineItemChildrenContext.Provider,{value:lineProps,children},k)});return _jsx(_Fragment,{children:components})}export default LineItem;
|
|
@@ -4,17 +4,4 @@ declare type Props = BaseAmountComponent & {
|
|
|
4
4
|
type?: BasePriceType;
|
|
5
5
|
};
|
|
6
6
|
export declare function LineItemAmount(props: Props): JSX.Element;
|
|
7
|
-
export declare namespace LineItemAmount {
|
|
8
|
-
var propTypes: {
|
|
9
|
-
type: import("prop-types").Requireable<BasePriceType>;
|
|
10
|
-
id: import("prop-types").Requireable<string>;
|
|
11
|
-
className: import("prop-types").Requireable<string>;
|
|
12
|
-
style: import("prop-types").Requireable<object>;
|
|
13
|
-
name: import("prop-types").Requireable<string>;
|
|
14
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
15
|
-
format: import("prop-types").Requireable<import("../../typings/index").BaseFormatPrice>;
|
|
16
|
-
};
|
|
17
|
-
var defaultProps: Props;
|
|
18
|
-
var displayName: string;
|
|
19
|
-
}
|
|
20
7
|
export default LineItemAmount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../../utils/getAmount";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../../utils/getAmount";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";export function LineItemAmount(props){const{format="formatted",type="total",...p}=props,{lineItem}=useContext(LineItemChildrenContext),[price,setPrice]=useState("");useEffect(()=>{if(lineItem){const p2=getAmount({base:"amount",type,format,obj:lineItem});setPrice(p2)}return()=>{setPrice("")}},[lineItem]);const parentProps={price,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:price})}export default LineItemAmount;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LineItem } from '@commercelayer/sdk';
|
|
3
|
-
|
|
3
|
+
import { ChildrenFunction } from '../../typings/index';
|
|
4
|
+
export interface TLineItemCode extends Omit<Props, 'children'> {
|
|
4
5
|
lineItem: LineItem;
|
|
5
6
|
skuCode: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
children?:
|
|
7
|
+
}
|
|
8
|
+
interface Props extends Omit<JSX.IntrinsicElements['p'], 'children'> {
|
|
9
|
+
children?: ChildrenFunction<TLineItemCode>;
|
|
9
10
|
type?: 'sku_code' | 'bundle_code';
|
|
10
|
-
} & JSX.IntrinsicElements['p'];
|
|
11
|
-
export declare function LineItemCode({ type, children, ...p }: Props): JSX.Element;
|
|
12
|
-
export declare namespace LineItemCode {
|
|
13
|
-
var propTypes: {
|
|
14
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
15
|
-
};
|
|
16
|
-
var displayName: string;
|
|
17
11
|
}
|
|
12
|
+
export declare function LineItemCode({ type, children, ...p }: Props): JSX.Element;
|
|
18
13
|
export default LineItemCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import Parent from"../utils/Parent";export function LineItemCode({type="sku_code",children,...p}){const{lineItem}=useContext(LineItemChildrenContext),labelName=lineItem?.[type],parentProps={lineItem,skuCode:labelName,...p};return children?_jsx(Parent,{...parentProps,children}):_jsx("p",{...p,children:labelName})}export default LineItemCode;
|