@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
interface Props {
|
|
3
3
|
children: JSX.Element | JSX.Element[];
|
|
4
|
+
filterBy?: string[];
|
|
4
5
|
}
|
|
5
|
-
export declare function Parcels({ children }: Props): JSX.Element;
|
|
6
|
+
export declare function Parcels({ children, filterBy }: Props): JSX.Element;
|
|
6
7
|
export default Parcels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import ParcelChildrenContext from"../../context/ParcelChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import{useContext}from"react";export function Parcels({children}){const{parcels}=useContext(ShipmentChildrenContext),components=parcels?.map((parcel,key)=>_jsx(ParcelChildrenContext.Provider,{value:{parcel},children},key));return _jsx(_Fragment,{children:components})}export default Parcels;
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import ParcelChildrenContext from"../../context/ParcelChildrenContext";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import{useContext}from"react";export function Parcels({children,filterBy}){const{parcels}=useContext(ShipmentChildrenContext),components=parcels?.filter(parcel=>filterBy?.includes(parcel.id)??!0).map((parcel,key)=>_jsx(ParcelChildrenContext.Provider,{value:{parcel},children},key));return _jsx(_Fragment,{children:components})}export default Parcels;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChildrenFunction } from '../../typings/index';
|
|
3
|
+
import type { Parcel } from '@commercelayer/sdk';
|
|
4
|
+
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
5
|
+
/**
|
|
6
|
+
* Shipments of the current order
|
|
7
|
+
*/
|
|
8
|
+
parcels?: Parcel[];
|
|
9
|
+
/**
|
|
10
|
+
* Quantity of the parcels
|
|
11
|
+
*/
|
|
12
|
+
quantity: number;
|
|
13
|
+
}
|
|
14
|
+
interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
|
|
15
|
+
children?: ChildrenFunction<ChildrenProps>;
|
|
16
|
+
}
|
|
17
|
+
export declare function ParcelsCount({ children, ...p }: Props): JSX.Element;
|
|
18
|
+
export default ParcelsCount;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import ShipmentChildrenContext from"../../context/ShipmentChildrenContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function ParcelsCount({children,...p}){const{parcels}=useCustomContext({context:ShipmentChildrenContext,contextComponentName:"ShipmentsContainer",currentComponentName:"ParcelsCount",key:"parcels"}),quantity=parcels?.length??0,childrenProps={...p,quantity,parcels};return children?_jsx(Parent,{...childrenProps,children}):_jsx("span",{...p,children:quantity})}export default ParcelsCount;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
declare type
|
|
4
|
-
export declare function AdyenGateway(props:
|
|
3
|
+
declare type Props = GatewayBaseType;
|
|
4
|
+
export declare function AdyenGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default AdyenGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import{
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import{useContext}from"react";import AdyenPayment from"../payment_source/AdyenPayment";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";import jwt from"../../utils/jwt";import getCardDetails from"../../utils/getCardDetails";export function AdyenGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=useContext(OrderContext),{accessToken}=useContext(CommerceLayerContext),{payment}=useContext(PaymentMethodChildrenContext),{payments,isGuest}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="adyen_payments",locale=order?.language_code,paymentMethods=paymentSource?.payment_methods;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const clientKey=paymentSource?.public_key,environment=accessToken&&jwt(accessToken).test?"test":"live",adyenConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="adyen_payments"):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?clientKey&&!loading&&paymentMethods?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(AdyenPayment,{templateCustomerSaveToWallet,clientKey,locale,environment,config:adyenConfig})]}):loaderComponent:clientKey&&!loading&&paymentMethods?_jsx(AdyenPayment,{clientKey,locale,config:adyenConfig,environment}):loaderComponent}export default AdyenGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
declare type
|
|
4
|
-
export declare function BraintreeGateway(props:
|
|
3
|
+
declare type Props = GatewayBaseType;
|
|
4
|
+
export declare function BraintreeGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default BraintreeGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import BraintreePayment from"../payment_source/BraintreePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import{
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import BraintreePayment from"../payment_source/BraintreePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import{useContext}from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function BraintreeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=useContext(OrderContext),{payment}=useContext(PaymentMethodChildrenContext),{payments,isGuest}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=useContext(PaymentMethodContext),paymentResource="braintree_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const authorization=paymentSource?.client_token,braintreeConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type==="braintree_payments"):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?authorization&&!loading?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(BraintreePayment,{templateCustomerSaveToWallet,authorization,locale,config:braintreeConfig})]}):loaderComponent:authorization&&!loading?_jsx(BraintreePayment,{locale,authorization,config:braintreeConfig}):loaderComponent}export default BraintreeGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
declare type
|
|
4
|
-
export declare function CheckoutComGateway(props:
|
|
3
|
+
declare type Props = GatewayBaseType;
|
|
4
|
+
export declare function CheckoutComGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default CheckoutComGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
declare type
|
|
4
|
-
export declare function KlarnaGateway(props:
|
|
3
|
+
declare type Props = GatewayBaseType;
|
|
4
|
+
export declare function KlarnaGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default KlarnaGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import getPaypalConfig from"../../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import CustomerContext from"../../context/CustomerContext";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource){const attributes=config&&paymentResource==="paypal_payments"?getPaypalConfig(paymentResource,config):{},setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||!paymentSource||paymentSource.type!==paymentResource)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import getPaypalConfig from"../../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource){const attributes=config&&paymentResource==="paypal_payments"?getPaypalConfig(paymentResource,config):{},setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||!paymentSource||paymentSource.type!==paymentResource)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
declare type
|
|
4
|
-
export declare function PaypalGateway(props:
|
|
3
|
+
declare type Props = Partial<GatewayBaseType>;
|
|
4
|
+
export declare function PaypalGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default PaypalGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
declare type
|
|
4
|
-
export declare function StripeGateway(props:
|
|
3
|
+
declare type Props = GatewayBaseType;
|
|
4
|
+
export declare function StripeGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default StripeGateway;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GatewayBaseType } from '../payment_gateways/PaymentGateway';
|
|
3
|
-
declare type
|
|
4
|
-
export declare function WireTransferGateway(props:
|
|
3
|
+
declare type Props = GatewayBaseType;
|
|
4
|
+
export declare function WireTransferGateway(props: Props): JSX.Element | null;
|
|
5
5
|
export default WireTransferGateway;
|
|
@@ -6,7 +6,7 @@ declare type Props = {
|
|
|
6
6
|
/**
|
|
7
7
|
* Hide payment methods by an array of strings
|
|
8
8
|
*/
|
|
9
|
-
hide?:
|
|
9
|
+
hide?: PaymentResource[];
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
activeClass?: string;
|
|
12
12
|
loader?: LoaderType;
|
|
@@ -18,10 +18,4 @@ declare type Props = {
|
|
|
18
18
|
onClick?: never;
|
|
19
19
|
});
|
|
20
20
|
export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, hide, onClick, ...p }: Props): JSX.Element;
|
|
21
|
-
export declare namespace PaymentMethod {
|
|
22
|
-
var propTypes: {
|
|
23
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
24
|
-
};
|
|
25
|
-
var displayName: string;
|
|
26
|
-
}
|
|
27
21
|
export default PaymentMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=useCustomContext({context:PaymentMethodContext,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"});useEffect(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(hide){const source=payment?.payment_source_type;return!hide?.includes(source)}return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-test-id":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default PaymentMethod;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { ChildrenFunction } from '../../typings/index';
|
|
3
|
+
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
3
4
|
labelName: string;
|
|
4
|
-
};
|
|
5
|
-
declare type Props = {
|
|
6
|
-
children?: (props: PaymentMethodNameChildrenProps) => JSX.Element;
|
|
7
|
-
} & JSX.IntrinsicElements['label'];
|
|
8
|
-
export declare function PaymentMethodName(props: Props): JSX.Element;
|
|
9
|
-
export declare namespace PaymentMethodName {
|
|
10
|
-
var propTypes: {
|
|
11
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
12
|
-
};
|
|
13
|
-
var displayName: string;
|
|
14
5
|
}
|
|
6
|
+
interface Props extends Omit<JSX.IntrinsicElements['label'], 'children'> {
|
|
7
|
+
children?: ChildrenFunction<ChildrenProps>;
|
|
8
|
+
}
|
|
9
|
+
export declare function PaymentMethodName(props: Props): JSX.Element;
|
|
15
10
|
export default PaymentMethodName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodName(props){const{payment}=useCustomContext({context:PaymentMethodChildrenContext,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodName",key:"payment"}),labelName=payment?.name,htmlFor=payment?.payment_source_type,parentProps={htmlFor,labelName,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("label",{htmlFor,...props,children:labelName})}export default PaymentMethodName;
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseAmountComponent } from '../../typings/index';
|
|
3
|
-
|
|
3
|
+
interface Props extends BaseAmountComponent {
|
|
4
4
|
type?: 'amount';
|
|
5
5
|
labelFree?: string;
|
|
6
|
-
} & BaseAmountComponent;
|
|
7
|
-
export declare function PaymentMethodPrice(props: Props): JSX.Element;
|
|
8
|
-
export declare namespace PaymentMethodPrice {
|
|
9
|
-
var propTypes: {
|
|
10
|
-
type: import("prop-types").Requireable<"amount">;
|
|
11
|
-
id: import("prop-types").Requireable<string>;
|
|
12
|
-
className: import("prop-types").Requireable<string>;
|
|
13
|
-
style: import("prop-types").Requireable<object>;
|
|
14
|
-
name: import("prop-types").Requireable<string>;
|
|
15
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
16
|
-
format: import("prop-types").Requireable<import("../../typings/index").BaseFormatPrice>;
|
|
17
|
-
};
|
|
18
|
-
var displayName: string;
|
|
19
6
|
}
|
|
7
|
+
export declare function PaymentMethodPrice(props: Props): JSX.Element;
|
|
20
8
|
export default PaymentMethodPrice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect}from"react";import getAmount from"../../utils/getAmount";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodPrice(props){const{format="formatted",type="amount",labelFree="Free",...p}=props,{payment}=useCustomContext({context:PaymentMethodChildrenContext,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodPrice",key:"payment"}),[price,setPrice]=useState(""),[priceCents,setPriceCents]=useState(0);useEffect(()=>{if(payment){const p2=getAmount({base:"price",type,format,obj:payment});setPrice(p2);const c=getAmount({base:"price",type,format:"cents",obj:payment});setPriceCents(c)}return()=>{setPrice(""),setPriceCents(0)}},[payment]);const parentProps={labelFree,price,priceCents,...p};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("span",{...p,children:priceCents===0?labelFree:price})}export default PaymentMethodPrice;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { ChangeEvent } from 'react';
|
|
2
2
|
import { PaymentMethod } from '@commercelayer/sdk';
|
|
3
|
-
|
|
3
|
+
import { ChildrenFunction } from '../../typings/index';
|
|
4
|
+
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
4
5
|
checked: boolean;
|
|
5
6
|
handleOnChange: (event: ChangeEvent<HTMLInputElement>) => Promise<void>;
|
|
6
|
-
}
|
|
7
|
+
}
|
|
7
8
|
declare type Props = {
|
|
8
|
-
children?:
|
|
9
|
+
children?: ChildrenFunction<ChildrenProps>;
|
|
9
10
|
onChange?: (payment?: PaymentMethod | Record<string, any>) => void;
|
|
10
11
|
} & JSX.IntrinsicElements['input'];
|
|
11
12
|
export declare function PaymentMethodRadioButton(props: Props): JSX.Element;
|
|
12
|
-
export declare namespace PaymentMethodRadioButton {
|
|
13
|
-
var propTypes: {
|
|
14
|
-
children: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
15
|
-
};
|
|
16
|
-
var displayName: string;
|
|
17
|
-
}
|
|
18
13
|
export default PaymentMethodRadioButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import Parent from"../utils/Parent";import PaymentMethodContext from"../../context/PaymentMethodContext";import OrderContext from"../../context/OrderContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodRadioButton(props){const{onChange,...p}=props,{payment,paymentSelected,setPaymentSelected,clickableContainer}=useCustomContext({context:PaymentMethodChildrenContext,contextComponentName:"PaymentMethod",currentComponentName:"PaymentMethodRadioButton",key:"payment"}),{order}=useContext(OrderContext),{setPaymentMethod,setLoading}=useContext(PaymentMethodContext),orderId=order?.id||"",paymentResource=payment?.payment_source_type,paymentMethodId=payment?.id,name=`payment-${orderId}`,checked=paymentSelected===payment?.id,handleOnChange=async e=>{e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer&&await setPaymentMethod({paymentResource,paymentMethodId}),onChange&&onChange(payment),setLoading({loading:!1})},id=payment?.payment_source_type,parentProps={handleOnChange,checked,id,name,...props};return props.children?_jsx(Parent,{...parentProps,children:props.children}):_jsx("input",{title:name,type:"radio",id,onChange:e=>{handleOnChange(e)},checked,...p})}export default PaymentMethodRadioButton;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { PaymentMethodConfig } from '../../reducers/PaymentMethodReducer';
|
|
3
|
-
|
|
3
|
+
interface Props {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
config?: PaymentMethodConfig;
|
|
6
|
-
};
|
|
7
|
-
export declare function PaymentMethodsContainer(props: Props): JSX.Element;
|
|
8
|
-
export declare namespace PaymentMethodsContainer {
|
|
9
|
-
var propTypes: {
|
|
10
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
11
|
-
};
|
|
12
|
-
var displayName: string;
|
|
13
6
|
}
|
|
7
|
+
export declare function PaymentMethodsContainer(props: Props): JSX.Element;
|
|
14
8
|
export default PaymentMethodsContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig,setPaymentRef}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import{isEmpty}from"lodash";import useCustomContext from"../../utils/hooks/useCustomContext";export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PaymentMethodsContainer",key:"order"}),credentials=useContext(CommerceLayerContext);async function getPayMethods(){order&&await getPaymentMethods({order,dispatch})}useEffect(()=>{include?.includes("available_payment_methods")?includeLoaded?.available_payment_methods||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0,"line_items.line_item_options.sku_option":!0,"line_items.item":!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method","line_items.line_item_options.sku_option","line_items.item"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPayMethods(),order?.payment_source&&dispatch({type:"setPaymentSource",payload:{paymentSource:order?.payment_source}}),order?.payment_source===null&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},[order,credentials,include,includeLoaded]);const contextValue=useMemo(()=>({...state,setLoading:({loading})=>defaultPaymentMethodContext.setLoading({loading,dispatch}),setPaymentRef:({ref})=>setPaymentRef({ref,dispatch}),setPaymentMethodErrors:errors=>defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch),setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod({...args,config:credentials,updateOrder,order,dispatch,setOrderErrors}),setPaymentSource:async args=>await defaultPaymentMethodContext.setPaymentSource({...state,...args,config:credentials,dispatch,getOrder,updateOrder,order}),updatePaymentSource:async args=>await defaultPaymentMethodContext.updatePaymentSource({...args,config:credentials,dispatch}),destroyPaymentSource:async args=>await defaultPaymentMethodContext.destroyPaymentSource({...args,dispatch,config:credentials,updateOrder,orderId:order?.id})}),[state]);return _jsx(PaymentMethodContext.Provider,{value:contextValue,children})}export default PaymentMethodsContainer;
|
|
@@ -36,20 +36,20 @@ interface PaymentMethodsStyle {
|
|
|
36
36
|
card?: Styles;
|
|
37
37
|
paypal?: PaypalStyle;
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export interface AdyenPaymentConfig {
|
|
40
40
|
cardContainerClassName?: string;
|
|
41
41
|
threeDSecureContainerClassName?: string;
|
|
42
42
|
placeOrderCallback?: (response: {
|
|
43
43
|
placed: boolean;
|
|
44
44
|
}) => void;
|
|
45
45
|
styles?: PaymentMethodsStyle;
|
|
46
|
-
}
|
|
47
|
-
|
|
46
|
+
}
|
|
47
|
+
interface Props {
|
|
48
48
|
clientKey?: string;
|
|
49
49
|
config?: AdyenPaymentConfig;
|
|
50
50
|
templateCustomerSaveToWallet?: PaymentSourceProps['templateCustomerSaveToWallet'];
|
|
51
51
|
locale?: string;
|
|
52
52
|
environment?: string;
|
|
53
|
-
}
|
|
54
|
-
export declare function AdyenPayment({ clientKey, config, templateCustomerSaveToWallet, environment, locale
|
|
53
|
+
}
|
|
54
|
+
export declare function AdyenPayment({ clientKey, config, templateCustomerSaveToWallet, environment, locale }: Props): JSX.Element | null;
|
|
55
55
|
export default AdyenPayment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import{setCustomerOrderParam}from"../../utils/localStorage";import Parent from"../utils/Parent";import getBrowserInfo
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import{setCustomerOrderParam}from"../../utils/localStorage";import Parent from"../utils/Parent";import getBrowserInfo,{cleanUrlBy}from"../../utils/browserInfo";import PlaceOrderContext from"../../context/PlaceOrderContext";import OrderContext from"../../context/OrderContext";const threeDSConfiguration={challengeWindowSize:"05"},defaultConfig={};export function AdyenPayment({clientKey,config,templateCustomerSaveToWallet,environment="test",locale="en_US"}){const{cardContainerClassName,threeDSecureContainerClassName,styles}={...defaultConfig,...config},[loadAdyen,setLoadAdyen]=useState(!1),[checkout,setCheckout]=useState(null),{setPaymentSource,paymentSource,setPaymentMethodErrors,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),{placeOrderButtonRef}=useContext(PlaceOrderContext),ref=useRef(null),handleSubmit=async(e,component)=>{const savePaymentSourceToCustomerWallet=e?.elements?.save_payment_source_to_customer_wallet?.checked;return savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),component?.submit&&component.submit(),!1},handleChange=async(state,checkout2)=>{if(state.isValid){ref.current&&(ref.current.onsubmit=async()=>await handleSubmit(ref.current,checkout2),setPaymentRef({ref}));const browserInfo=getBrowserInfo(),attributes={payment_request_data:{payment_method:state.data.paymentMethod,shopperInteraction:"Ecommerce",recurringProcessingModel:"CardOnFile",origin:window.location.origin,return_url:window.location.href,redirect_from_issuer_method:"GET",browser_info:{acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",...browserInfo}}};paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"adyen_payments",attributes})}},handleOnAdditionalDetails=async(state,component)=>{const attributes={payment_request_details:state.data,_details:1};try{const pSource=paymentSource&&await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:"adyen_payments",attributes}),adyenAction=pSource?.payment_response?.action,resultCode=pSource?.payment_response?.resultCode;if(adyenAction&&component)return component.handleAction(adyenAction),!1;if(["Authorised","Pending","Received"].includes(resultCode))return placeOrderButtonRef?.current!=null&&(placeOrderButtonRef.current.disabled&&(placeOrderButtonRef.current.disabled=!1),placeOrderButtonRef.current?.click()),!0;if(["Cancelled","Refused"].includes(resultCode)){const message=pSource?.payment_response?.refusalReason;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}]),component&&component.mount("#adyen-dropin")}return!1}catch(error){return console.error("Adyen additional details error:",error),!1}},onSubmit=async(state,component)=>{const browserInfo=getBrowserInfo(),url=cleanUrlBy();let control=await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments"});if(control?.payment_response?.resultCode==="Authorised")return!0;const paymentDataAvailable=Object.keys(control?.payment_request_data).length>0,paymentMethodSelected=control?.payment_request_data?.payment_method?.type;(!paymentDataAvailable||paymentMethodSelected!==state.data.paymentMethod.type)&&(control=await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes:{payment_request_data:{...state.data,payment_method:state.data.paymentMethod,return_url:url,origin:window.location.origin,redirect_from_issuer_method:"GET",browser_info:{acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",...browserInfo}}}}));const attributes={payment_request_data:{...state.data,payment_method:state.data.paymentMethod,return_url:url,origin:window.location.origin,redirect_from_issuer_method:"GET",browser_info:{acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",...browserInfo}},_authorize:1};delete attributes.payment_request_data.paymentMethod;try{const res=await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}),action=res?.payment_response?.action;if(component&&action)return component.handleAction(action),!1;const resultCode=res?.payment_response?.resultCode;if(["Authorised","Pending","Received"].includes(resultCode))return placeOrderButtonRef?.current!=null&&(placeOrderButtonRef.current.disabled&&(placeOrderButtonRef.current.disabled=!1),placeOrderButtonRef.current?.click()),!0;if(["Cancelled"].includes(resultCode)){const message=res?.payment_response?.refusalReason;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])}if(res?.payment_response?.errorType)if(res?.payment_response?.errorCode==="14_006")onSubmit(state,component);else{const message=res?.payment_response?.message;setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])}return!1}catch(error){return setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1}};return useEffect(()=>{const paymentMethodsResponse=paymentSource?.payment_methods?.paymentMethods?paymentSource?.payment_methods.paymentMethods:[],[firstPaymentMethod]=paymentMethodsResponse,isOnlyCard=paymentMethodsResponse?.length===1&&firstPaymentMethod.type==="scheme";paymentMethodsResponse.length===0&&console.error("Payment methods are not available. Please, check your Adyen configuration.");const options={locale,environment,clientKey,amount:{currency:order?.currency_code||"",value:order?.total_amount_with_taxes_cents||0},countryCode:order?.country_code||"",paymentMethodsResponse:{paymentMethods:paymentMethodsResponse},showPayButton:!1,paymentMethodsConfiguration:{threeDS2:threeDSConfiguration,paypal:{showPayButton:!0,style:styles?.paypal},card:{styles:styles?.card,holderNameRequired:!1}},onAdditionalDetails:handleOnAdditionalDetails,onChange:handleChange,onSubmit};return!ref&&clientKey&&setCustomerOrderParam("_save_payment_source_to_customer_wallet","false"),clientKey&&!loadAdyen&&window&&!checkout&&import("@adyen/adyen-web").then(({default:AdyenCheckout})=>{const type=isOnlyCard?"card":"dropin";AdyenCheckout(options).then(adyenCheckout=>{const component=adyenCheckout.create(type,{onSelect:component2=>{const id=component2._id;id.search("scheme")===-1&&ref.current&&(id.search("paypal")===-1?ref.current.onsubmit=async()=>await handleSubmit(ref.current,component2):ref.current.onsubmit=null,setPaymentRef({ref}))}}).mount("#adyen-dropin");component&&(setCheckout(component),setLoadAdyen(!0))})}),()=>{setPaymentRef({ref:{current:null}}),setLoadAdyen(!1)}},[clientKey,ref]),!clientKey&&!loadAdyen&&!checkout?null:_jsxs("form",{ref,onSubmit:e=>{handleSubmit(e,checkout)},children:[_jsx("div",{className:cardContainerClassName,id:"adyen-dropin"}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet}),_jsx("div",{className:threeDSecureContainerClassName,id:"adyen-action"})]})}export default AdyenPayment;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { LoaderType } from '../../typings/index';
|
|
3
3
|
import { CustomerCardsTemplateChildren } from '../utils/PaymentCardsTemplate';
|
|
4
|
-
export
|
|
4
|
+
export interface CustomerCardsProps {
|
|
5
5
|
handleClick: () => void;
|
|
6
|
-
}
|
|
7
|
-
export
|
|
6
|
+
}
|
|
7
|
+
export interface CustomerSaveToWalletProps {
|
|
8
8
|
name: 'save_payment_source_to_customer_wallet';
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
export declare type PaymentSourceProps = {
|
|
11
11
|
children?: ReactNode;
|
|
12
12
|
readonly?: boolean;
|
|
@@ -16,11 +16,4 @@ export declare type PaymentSourceProps = {
|
|
|
16
16
|
loader?: LoaderType;
|
|
17
17
|
} & JSX.IntrinsicElements['div'];
|
|
18
18
|
export declare function PaymentSource(props: PaymentSourceProps): JSX.Element;
|
|
19
|
-
export declare namespace PaymentSource {
|
|
20
|
-
var propTypes: {
|
|
21
|
-
children: import("prop-types").Requireable<ReactNode | (() => JSX.Element)>;
|
|
22
|
-
readonly: import("prop-types").Requireable<boolean>;
|
|
23
|
-
};
|
|
24
|
-
var displayName: string;
|
|
25
|
-
}
|
|
26
19
|
export default PaymentSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!1),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const gatewayProps={...props,show,showCard,handleEditClick:async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},readonly};return _jsx(PaymentGateway,{...gatewayProps})}export default PaymentSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import Parent from"../utils/Parent";import PricesContext from"../../context/PricesContext";import{useState,useEffect,useContext}from"react";import{
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import Parent from"../utils/Parent";import PricesContext from"../../context/PricesContext";import{useState,useEffect,useContext}from"react";import{getPricesComponent}from"../../utils/getPrices";import SkuChildrenContext from"../../context/SkuChildrenContext";export function Price(props){const{children,skuCode=""}=props,{prices,skuCode:pricesSkuCode,loading,skuCodes,setSkuCodes,loader}=useContext(PricesContext),{sku}=useContext(SkuChildrenContext),[skuPrices,setSkuPrices]=useState([]),sCode=pricesSkuCode||skuCode||sku?.code;useEffect(()=>(prices!=null&&`${sCode}`in prices?setSkuPrices(prices[sCode]):sCode&&!skuCodes.includes(sCode)&&(skuCodes.push(sCode),setSkuCodes&&setSkuCodes({skuCodes})),()=>{setSkuPrices([])}),[prices,sCode]);const parentProps={loading,loader,prices:skuPrices,...props},pricesComponent=prices==null||skuPrices==null?null:getPricesComponent(skuPrices,props);return children?_jsx(Parent,{...parentProps,children}):_jsx(_Fragment,{children:loading||pricesComponent==null?loader:pricesComponent})}export default Price;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useContext,useReducer}from"react";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useContext,useReducer}from"react";import CommerceLayerContext from"../../context/CommerceLayerContext";import priceReducer,{priceInitialState,getSkusPrice,setSkuCodes}from"../../reducers/PriceReducer";import PricesContext from"../../context/PricesContext";import SkuContext from"../../context/SkuContext";export function PricesContainer(props){const{children,skuCode="",loader="Loading...",perPage=10,filters={}}=props,[state,dispatch]=useReducer(priceReducer,priceInitialState),config=useContext(CommerceLayerContext),{skuCodes}=useContext(SkuContext);!state.skuCodes.includes(skuCode)&&skuCode&&state.skuCodes.push(skuCode);const sCode=skuCodes&&skuCodes?.length>0?"":skuCode??"";useEffect(()=>{state.skuCodes.length===0&&skuCodes!=null&&skuCodes.length>0&&state.setSkuCodes!=null&&state.setSkuCodes({skuCodes,dispatch}),config.accessToken&&(state.skuCodes.length>0||sCode)&&getSkusPrice(sCode&&[sCode]||state.skuCodes,{config,dispatch,perPage,filters})},[config.accessToken,sCode,state.skuCodes.length]);const priceValue={...state,skuCode:sCode,loader,setSkuCodes:params=>setSkuCodes({...params,dispatch})};return _jsx(PricesContext.Provider,{value:priceValue,children})}export default PricesContainer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChildrenFunction } from '../../typings/index';
|
|
3
|
+
import type { Shipment } from '@commercelayer/sdk';
|
|
4
|
+
interface ChildrenProps extends Omit<Props, 'children'> {
|
|
5
|
+
/**
|
|
6
|
+
* Shipments of the current order
|
|
7
|
+
*/
|
|
8
|
+
shipments?: Shipment[];
|
|
9
|
+
/**
|
|
10
|
+
* Quantity of the shipments
|
|
11
|
+
*/
|
|
12
|
+
quantity: number;
|
|
13
|
+
}
|
|
14
|
+
interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
|
|
15
|
+
children?: ChildrenFunction<ChildrenProps>;
|
|
16
|
+
}
|
|
17
|
+
export declare function ShipmentsCount({ children, ...p }: Props): JSX.Element;
|
|
18
|
+
export default ShipmentsCount;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import Parent from"../utils/Parent";import ShipmentContext from"../../context/ShipmentContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function ShipmentsCount({children,...p}){const{shipments}=useCustomContext({context:ShipmentContext,contextComponentName:"ShipmentsContainer",currentComponentName:"ShipmentsCount",key:"shipments"}),quantity=shipments?.length??0,childrenProps={...p,quantity,shipments};return children?_jsx(Parent,{...childrenProps,children}):_jsx("span",{...p,children:quantity})}export default ShipmentsCount;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
interface Props {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
skuCode?: string;
|
|
5
|
-
|
|
6
|
-
export declare function AvailabilityContainer(props: Props): JSX.Element;
|
|
7
|
-
export declare namespace AvailabilityContainer {
|
|
8
|
-
var propTypes: {
|
|
9
|
-
children: import("prop-types").Validator<NonNullable<ReactNode | (() => JSX.Element)>>;
|
|
10
|
-
skuCode: import("prop-types").Requireable<string>;
|
|
11
|
-
};
|
|
12
|
-
var displayName: string;
|
|
5
|
+
getQuantity?: (quantity: number) => void;
|
|
13
6
|
}
|
|
7
|
+
export declare function AvailabilityContainer({ children, skuCode, getQuantity }: Props): JSX.Element;
|
|
14
8
|
export default AvailabilityContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useReducer,useEffect}from"react";import availabilityReducer,{availabilityInitialState,getAvailability
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useReducer,useEffect}from"react";import availabilityReducer,{availabilityInitialState,getAvailability}from"../../reducers/AvailabilityReducer";import AvailabilityContext from"../../context/AvailabilityContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import SkuChildrenContext from"../../context/SkuChildrenContext";import useCustomContext from"../../utils/hooks/useCustomContext";export function AvailabilityContainer({children,skuCode,getQuantity}){const{lineItem}=useContext(LineItemChildrenContext),{sku}=useContext(SkuChildrenContext),{accessToken,endpoint}=useCustomContext({context:CommerceLayerContext,contextComponentName:"CommerceLayer",currentComponentName:"AvailabilityContainer",key:"accessToken"}),[state,dispatch]=useReducer(availabilityReducer,availabilityInitialState),sCode=skuCode||lineItem?.sku_code||sku?.code;return useEffect(()=>(accessToken!=null&&accessToken!==""&&sCode&&getAvailability({skuCode:sCode,config:{accessToken,endpoint},dispatch}),()=>{dispatch({type:"setAvailability",payload:{}})}),[accessToken,sCode]),useEffect(()=>{getQuantity!=null&&state?.quantity!=null&&getQuantity(state?.quantity)},[state.quantity]),_jsx(AvailabilityContext.Provider,{value:{...state,parent:!0},children})}export default AvailabilityContainer;
|
|
@@ -5,11 +5,30 @@ interface AvailabilityTemplateChildrenProps extends Omit<Props, 'children'>, Del
|
|
|
5
5
|
text: string;
|
|
6
6
|
quantity: number;
|
|
7
7
|
}
|
|
8
|
-
declare type
|
|
9
|
-
|
|
8
|
+
declare type FormatRules = {
|
|
9
|
+
/**
|
|
10
|
+
* Set time format for shipping method
|
|
11
|
+
*/
|
|
10
12
|
timeFormat?: TimeFormat;
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Show shipping method name
|
|
15
|
+
*/
|
|
16
|
+
showShippingMethodName?: false;
|
|
17
|
+
/**
|
|
18
|
+
* Show shipping method price
|
|
19
|
+
*/
|
|
20
|
+
showShippingMethodPrice?: false;
|
|
21
|
+
} | {
|
|
22
|
+
timeFormat: TimeFormat;
|
|
23
|
+
showShippingMethodName: true;
|
|
12
24
|
showShippingMethodPrice?: boolean;
|
|
13
|
-
}
|
|
25
|
+
} | {
|
|
26
|
+
timeFormat: TimeFormat;
|
|
27
|
+
showShippingMethodName?: boolean;
|
|
28
|
+
showShippingMethodPrice: true;
|
|
29
|
+
};
|
|
30
|
+
declare type Props = {
|
|
31
|
+
children?: ChildrenFunction<AvailabilityTemplateChildrenProps>;
|
|
32
|
+
} & Omit<JSX.IntrinsicElements['span'], 'children'> & FormatRules;
|
|
14
33
|
export declare function AvailabilityTemplate(props: Props): JSX.Element;
|
|
15
34
|
export default AvailabilityTemplate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import AvailabilityContext from"../../context/AvailabilityContext";import Parent from"../utils/Parent";import useCustomContext from"../../utils/hooks/useCustomContext";export function AvailabilityTemplate(props){const{timeFormat,showShippingMethodName,showShippingMethodPrice,children,...p}=props,{min,max,shipping_method:shippingMethod,quantity}=useCustomContext({context:AvailabilityContext,contextComponentName:"AvailabilityContainer",currentComponentName:"AvailabilityTemplate",key:"parent"}),text=[],mn=min!=null&&timeFormat!=null?min?.[timeFormat]:"",mx=max!=null&&timeFormat!=null?max?.[timeFormat]:"",shippingMethodPrice=showShippingMethodPrice&&shippingMethod?.formatted_price_amount?`(${shippingMethod?.formatted_price_amount})`:"",name=showShippingMethodName&&shippingMethod?`with ${shippingMethod.name}`:"";quantity&&quantity>0?(text.push("Available"),mn&&mx&&timeFormat&&text.push(`in ${mn} - ${mx} ${timeFormat} ${name} ${shippingMethodPrice}`)):quantity===0&&text.push("Out of stock");const parentProps={min,max,shipping_method:shippingMethod,quantity,text:text.join(" "),...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...p,children:text.join(" ")})}export default AvailabilityTemplate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function SkuField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function SkuField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"sku",attribute,tagElement,context:SkuChildrenContext,...p,children})}export default SkuField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QueryParamsList } from '@commercelayer/sdk';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
|
|
3
|
+
interface Props {
|
|
4
4
|
/**
|
|
5
5
|
* An array of skus to display.
|
|
6
6
|
*/
|
|
@@ -13,6 +13,6 @@ declare type Props = {
|
|
|
13
13
|
* An object params to query the skus resource
|
|
14
14
|
*/
|
|
15
15
|
queryParams?: QueryParamsList;
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
export declare function SkusContainer<P extends Props>(props: P): JSX.Element;
|
|
18
18
|
export default SkusContainer;
|