@commercelayer/react-components 2.53.2 → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +3 -3
- package/lib/cjs/components/AdjustmentAmount.js +1 -1
- package/lib/cjs/components/AdyenPayment.d.ts +3 -3
- package/lib/cjs/components/AdyenPayment.js +1 -1
- package/lib/cjs/components/AvailabilityContainer.d.ts +10 -3
- package/lib/cjs/components/AvailabilityContainer.js +1 -1
- package/lib/cjs/components/AvailabilityTemplate.d.ts +13 -4
- package/lib/cjs/components/AvailabilityTemplate.js +1 -1
- package/lib/cjs/components/BillingAddressContainer.d.ts +7 -2
- package/lib/cjs/components/BillingAddressContainer.js +1 -1
- package/lib/cjs/components/BillingAddressForm.d.ts +8 -3
- package/lib/cjs/components/BillingAddressForm.js +1 -1
- package/lib/cjs/components/BraintreePayment.d.ts +3 -3
- package/lib/cjs/components/BraintreePayment.js +1 -1
- package/lib/cjs/components/CartLink.d.ts +12 -0
- package/lib/cjs/components/CartLink.js +1 -0
- package/lib/cjs/components/CheckoutComPayment.d.ts +23 -0
- package/lib/cjs/components/CheckoutComPayment.js +1 -0
- package/lib/cjs/components/CheckoutLink.d.ts +16 -4
- package/lib/cjs/components/CheckoutLink.js +1 -1
- package/lib/cjs/components/DeliveryLeadTime.d.ts +11 -4
- package/lib/cjs/components/DeliveryLeadTime.js +1 -1
- package/lib/cjs/components/DiscountAmount.d.ts +16 -2
- package/lib/cjs/components/DiscountAmount.js +1 -1
- package/lib/cjs/components/Errors.d.ts +4 -4
- package/lib/cjs/components/Errors.js +1 -1
- package/lib/cjs/components/ExternalFunction.d.ts +9 -2
- package/lib/cjs/components/ExternalFunction.js +1 -1
- package/lib/cjs/components/GiftCard.d.ts +13 -3
- package/lib/cjs/components/GiftCard.js +1 -1
- package/lib/cjs/components/GiftCardContainer.d.ts +9 -3
- package/lib/cjs/components/GiftCardContainer.js +1 -1
- package/lib/cjs/components/GiftCardCurrencySelector.d.ts +18 -3
- package/lib/cjs/components/GiftCardCurrencySelector.js +1 -1
- package/lib/cjs/components/GiftCardInput.d.ts +12 -3
- package/lib/cjs/components/GiftCardInput.js +1 -1
- package/lib/cjs/components/GiftCardOrCouponCode.d.ts +17 -6
- package/lib/cjs/components/GiftCardOrCouponCode.js +1 -1
- package/lib/cjs/components/GiftCardOrCouponForm.d.ts +9 -4
- package/lib/cjs/components/GiftCardOrCouponForm.js +1 -1
- package/lib/cjs/components/GiftCardOrCouponInput.d.ts +14 -3
- package/lib/cjs/components/GiftCardOrCouponInput.js +1 -1
- package/lib/cjs/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
- package/lib/cjs/components/GiftCardOrCouponRemoveButton.js +1 -1
- package/lib/cjs/components/GiftCardOrCouponSubmit.d.ts +11 -4
- package/lib/cjs/components/GiftCardOrCouponSubmit.js +1 -1
- package/lib/cjs/components/ItemContainer.d.ts +14 -3
- package/lib/cjs/components/ItemContainer.js +1 -1
- package/lib/cjs/components/KlarnaPayment.d.ts +10 -0
- package/lib/cjs/components/KlarnaPayment.js +1 -0
- package/lib/cjs/components/LineItem.d.ts +10 -3
- package/lib/cjs/components/LineItem.js +1 -1
- package/lib/cjs/components/LineItemAmount.d.ts +16 -3
- package/lib/cjs/components/LineItemAmount.js +1 -1
- package/lib/cjs/components/LineItemCode.d.ts +10 -4
- package/lib/cjs/components/LineItemCode.js +1 -1
- package/lib/cjs/components/LineItemImage.d.ts +11 -4
- package/lib/cjs/components/LineItemImage.js +1 -1
- package/lib/cjs/components/LineItemName.d.ts +11 -5
- package/lib/cjs/components/LineItemName.js +1 -1
- package/lib/cjs/components/LineItemOption.d.ts +15 -4
- package/lib/cjs/components/LineItemOption.js +1 -1
- package/lib/cjs/components/LineItemOptions.d.ts +8 -3
- package/lib/cjs/components/LineItemOptions.js +1 -1
- package/lib/cjs/components/LineItemQuantity.d.ts +16 -4
- package/lib/cjs/components/LineItemQuantity.js +1 -1
- package/lib/cjs/components/LineItemRemoveLink.d.ts +15 -5
- package/lib/cjs/components/LineItemRemoveLink.js +1 -1
- package/lib/cjs/components/LineItemsContainer.d.ts +15 -3
- package/lib/cjs/components/LineItemsContainer.js +1 -1
- package/lib/cjs/components/LineItemsCount.d.ts +14 -4
- package/lib/cjs/components/LineItemsCount.js +1 -1
- package/lib/cjs/components/LineItemsEmpty.d.ts +13 -2
- package/lib/cjs/components/LineItemsEmpty.js +1 -1
- package/lib/cjs/components/MetadataInput.d.ts +13 -3
- package/lib/cjs/components/MetadataInput.js +1 -1
- package/lib/cjs/components/PaymentGateway.d.ts +4 -4
- package/lib/cjs/components/PaymentGateway.js +1 -1
- package/lib/cjs/components/PaymentMethod.d.ts +9 -3
- package/lib/cjs/components/PaymentMethod.js +1 -1
- package/lib/cjs/components/PaymentMethodAmount.d.ts +16 -2
- package/lib/cjs/components/PaymentMethodAmount.js +1 -1
- package/lib/cjs/components/PaymentMethodName.d.ts +10 -4
- package/lib/cjs/components/PaymentMethodName.js +1 -1
- package/lib/cjs/components/PaymentMethodPrice.d.ts +15 -4
- package/lib/cjs/components/PaymentMethodPrice.js +1 -1
- package/lib/cjs/components/PaymentMethodRadioButton.d.ts +11 -4
- package/lib/cjs/components/PaymentMethodRadioButton.js +1 -1
- package/lib/cjs/components/PaymentMethodsContainer.d.ts +9 -3
- package/lib/cjs/components/PaymentMethodsContainer.js +1 -1
- package/lib/cjs/components/PaymentSource.d.ts +9 -2
- package/lib/cjs/components/PaymentSource.js +1 -1
- package/lib/cjs/components/PaymentSourceBrandIcon.d.ts +14 -4
- package/lib/cjs/components/PaymentSourceBrandIcon.js +1 -1
- package/lib/cjs/components/PaymentSourceBrandName.d.ts +11 -4
- package/lib/cjs/components/PaymentSourceBrandName.js +1 -1
- package/lib/cjs/components/PaymentSourceDetail.d.ts +8 -2
- package/lib/cjs/components/PaymentSourceDetail.js +1 -1
- package/lib/cjs/components/PaymentSourceEditButton.d.ts +9 -2
- package/lib/cjs/components/PaymentSourceEditButton.js +1 -1
- package/lib/cjs/components/PaypalPayment.d.ts +2 -2
- package/lib/cjs/components/PaypalPayment.js +1 -1
- package/lib/cjs/components/Price.d.ts +15 -3
- package/lib/cjs/components/Price.js +1 -1
- package/lib/cjs/components/PricesContainer.d.ts +19 -3
- package/lib/cjs/components/PricesContainer.js +1 -1
- package/lib/cjs/components/QuantitySelector.d.ts +19 -5
- package/lib/cjs/components/QuantitySelector.js +1 -1
- package/lib/cjs/components/SaveAddressesButton.d.ts +18 -5
- package/lib/cjs/components/SaveAddressesButton.js +1 -1
- package/lib/cjs/components/SaveCustomerButton.d.ts +16 -5
- package/lib/cjs/components/SaveCustomerButton.js +1 -1
- package/lib/cjs/components/ShippingAddressContainer.d.ts +7 -2
- package/lib/cjs/components/ShippingAddressContainer.js +1 -1
- package/lib/cjs/components/ShippingAddressForm.d.ts +8 -3
- package/lib/cjs/components/ShippingAddressForm.js +1 -1
- package/lib/cjs/components/ShippingAmount.d.ts +13 -2
- package/lib/cjs/components/ShippingAmount.js +1 -1
- package/lib/cjs/components/ShippingMethod.d.ts +10 -3
- package/lib/cjs/components/ShippingMethod.js +1 -1
- package/lib/cjs/components/ShippingMethodName.d.ts +11 -5
- package/lib/cjs/components/ShippingMethodName.js +1 -1
- package/lib/cjs/components/ShippingMethodPrice.d.ts +15 -3
- package/lib/cjs/components/ShippingMethodPrice.js +1 -1
- package/lib/cjs/components/ShippingMethodRadioButton.d.ts +11 -5
- package/lib/cjs/components/ShippingMethodRadioButton.js +1 -1
- package/lib/cjs/components/SkuField.d.ts +10 -0
- package/lib/cjs/components/SkuField.js +1 -0
- package/lib/cjs/components/Skus.d.ts +11 -0
- package/lib/cjs/components/Skus.js +1 -0
- package/lib/cjs/components/SkusContainer.d.ts +14 -0
- package/lib/cjs/components/SkusContainer.js +1 -0
- package/lib/cjs/components/StockTransfer.d.ts +9 -3
- package/lib/cjs/components/StockTransfer.js +1 -1
- package/lib/cjs/components/StockTransferField.d.ts +9 -8
- package/lib/cjs/components/StockTransferField.js +1 -1
- package/lib/cjs/components/StripePayment.d.ts +3 -3
- package/lib/cjs/components/StripePayment.js +1 -1
- package/lib/cjs/components/SubmitButton.d.ts +15 -5
- package/lib/cjs/components/SubmitButton.js +1 -1
- package/lib/cjs/components/VariantSelector.d.ts +28 -5
- package/lib/cjs/components/VariantSelector.js +1 -1
- package/lib/cjs/components/VariantsContainer.d.ts +15 -3
- package/lib/cjs/components/VariantsContainer.js +1 -1
- package/lib/cjs/components/WireTransferPayment.d.ts +2 -2
- package/lib/cjs/components/WireTransferPayment.js +1 -1
- package/lib/cjs/components/addresses/Address.d.ts +18 -0
- package/lib/cjs/components/addresses/Address.js +1 -0
- package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +26 -0
- package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -0
- package/lib/cjs/components/addresses/AddressField.d.ts +43 -0
- package/lib/cjs/components/addresses/AddressField.js +1 -0
- package/lib/cjs/components/addresses/AddressInput.d.ts +19 -0
- package/lib/cjs/components/addresses/AddressInput.js +1 -0
- package/lib/cjs/components/addresses/AddressStateSelector.d.ts +27 -0
- package/lib/cjs/components/addresses/AddressStateSelector.js +1 -0
- package/lib/cjs/components/addresses/AddressesContainer.d.ts +15 -0
- package/lib/cjs/components/addresses/AddressesContainer.js +1 -0
- package/lib/cjs/components/auth/CommerceLayer.d.ts +15 -0
- package/lib/cjs/components/auth/CommerceLayer.js +1 -0
- package/lib/cjs/components/customers/CustomerAddressForm.d.ts +13 -0
- package/lib/cjs/components/customers/CustomerAddressForm.js +1 -0
- package/lib/cjs/components/customers/CustomerContainer.d.ts +17 -0
- package/lib/cjs/components/customers/CustomerContainer.js +1 -0
- package/lib/cjs/components/customers/CustomerField.d.ts +10 -0
- package/lib/cjs/components/customers/CustomerField.js +1 -0
- package/lib/cjs/components/customers/CustomerInput.d.ts +23 -0
- package/lib/cjs/components/customers/CustomerInput.js +1 -0
- package/lib/cjs/components/gateways/AdyenGateway.d.ts +2 -2
- package/lib/cjs/components/gateways/AdyenGateway.js +1 -1
- package/lib/cjs/components/gateways/BraintreeGateway.d.ts +2 -2
- package/lib/cjs/components/gateways/BraintreeGateway.js +1 -1
- package/lib/cjs/components/gateways/CheckoutComGateway.d.ts +5 -0
- package/lib/cjs/components/gateways/CheckoutComGateway.js +1 -0
- package/lib/cjs/components/gateways/KlarnaGateway.d.ts +5 -0
- package/lib/cjs/components/gateways/KlarnaGateway.js +1 -0
- package/lib/cjs/components/gateways/PaypalGateway.d.ts +3 -3
- package/lib/cjs/components/gateways/PaypalGateway.js +1 -1
- package/lib/cjs/components/gateways/StripeGateway.d.ts +2 -2
- package/lib/cjs/components/gateways/StripeGateway.js +1 -1
- package/lib/cjs/components/gateways/WireTransferGateway.d.ts +2 -2
- package/lib/cjs/components/gateways/WireTransferGateway.js +1 -1
- package/lib/cjs/components/orders/AddToCartButton.d.ts +34 -0
- package/lib/cjs/components/orders/AddToCartButton.js +1 -0
- package/lib/cjs/components/orders/AdjustmentAmount.d.ts +18 -0
- package/lib/cjs/components/orders/AdjustmentAmount.js +1 -0
- package/lib/cjs/components/orders/CartLink.d.ts +12 -0
- package/lib/cjs/components/orders/CartLink.js +1 -0
- package/lib/cjs/components/orders/GiftCardAmount.d.ts +15 -0
- package/lib/cjs/components/orders/GiftCardAmount.js +1 -0
- package/lib/cjs/components/orders/OrderContainer.d.ts +26 -0
- package/lib/cjs/components/orders/OrderContainer.js +1 -0
- package/lib/cjs/components/orders/OrderList.d.ts +61 -0
- package/lib/cjs/components/orders/OrderList.js +1 -0
- package/lib/cjs/components/orders/OrderListRow.d.ts +30 -0
- package/lib/cjs/components/orders/OrderListRow.js +1 -0
- package/lib/cjs/components/orders/OrderNumber.d.ts +11 -0
- package/lib/cjs/components/orders/OrderNumber.js +1 -0
- package/lib/cjs/components/orders/OrderStorage.d.ts +16 -0
- package/lib/cjs/components/orders/OrderStorage.js +1 -0
- package/lib/cjs/components/orders/PlaceOrderButton.d.ts +24 -0
- package/lib/cjs/components/orders/PlaceOrderButton.js +1 -0
- package/lib/cjs/components/orders/PlaceOrderContainer.d.ts +14 -0
- package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -0
- package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
- package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -0
- package/lib/cjs/components/orders/SubTotalAmount.d.ts +18 -0
- package/lib/cjs/components/orders/SubTotalAmount.js +1 -0
- package/lib/cjs/components/orders/TaxesAmount.d.ts +18 -0
- package/lib/cjs/components/orders/TaxesAmount.js +1 -0
- package/lib/cjs/components/orders/TotalAmount.d.ts +18 -0
- package/lib/cjs/components/orders/TotalAmount.js +1 -0
- package/lib/cjs/components/shipments/Shipment.d.ts +15 -0
- package/lib/cjs/components/shipments/Shipment.js +1 -0
- package/lib/cjs/components/shipments/ShipmentField.d.ts +19 -0
- package/lib/cjs/components/shipments/ShipmentField.js +1 -0
- package/lib/cjs/components/shipments/ShipmentsContainer.d.ts +12 -0
- package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -0
- package/lib/cjs/components/skus/SkuField.d.ts +14 -0
- package/lib/cjs/components/skus/SkuField.js +1 -0
- package/lib/cjs/components/skus/SkuList.d.ts +14 -0
- package/lib/cjs/components/skus/SkuList.js +1 -0
- package/lib/cjs/components/skus/SkuListsContainer.d.ts +12 -0
- package/lib/cjs/components/skus/SkuListsContainer.js +1 -0
- package/lib/cjs/components/skus/SkuOption.d.ts +14 -0
- package/lib/cjs/components/skus/SkuOption.js +1 -0
- package/lib/cjs/components/skus/SkuOptionInput.d.ts +15 -0
- package/lib/cjs/components/skus/SkuOptionInput.js +1 -0
- package/lib/cjs/components/skus/SkuOptionsContainer.d.ts +14 -0
- package/lib/cjs/components/skus/SkuOptionsContainer.js +1 -0
- package/lib/cjs/components/skus/Skus.d.ts +11 -0
- package/lib/cjs/components/skus/Skus.js +1 -0
- package/lib/cjs/components/skus/SkusContainer.d.ts +23 -0
- package/lib/cjs/components/skus/SkusContainer.js +1 -0
- package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -1
- package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -1
- package/lib/cjs/components/utils/BaseField.js +1 -1
- package/lib/cjs/components/utils/BaseInput.d.ts +1 -1
- package/lib/cjs/components/utils/BaseInput.js +1 -1
- package/lib/cjs/components/utils/BaseOrderPrice.js +1 -1
- package/lib/cjs/components/utils/BaseSelect.js +1 -1
- package/lib/cjs/components/utils/GenericFieldComponent.d.ts +42 -0
- package/lib/cjs/components/utils/GenericFieldComponent.js +1 -0
- package/lib/cjs/components/utils/Parent.d.ts +3 -5
- package/lib/cjs/components/utils/Parent.js +1 -1
- package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +2 -2
- package/lib/cjs/components/utils/PaymentCardsTemplate.js +1 -1
- package/lib/cjs/components/utils/PriceTemplate.d.ts +2 -2
- package/lib/cjs/components/utils/PriceTemplate.js +1 -1
- package/lib/cjs/components/utils/VariantTemplate.js +1 -1
- package/lib/cjs/components/utils/getAllErrors.js +1 -1
- package/lib/cjs/config/components.d.ts +78 -36
- package/lib/cjs/config/components.js +1 -1
- package/lib/cjs/context/AddressChildrenContext.d.ts +1 -1
- package/lib/cjs/context/AddressChildrenContext.js +1 -1
- package/lib/cjs/context/AddressContext.d.ts +1 -1
- package/lib/cjs/context/BillingAddressContext.d.ts +2 -4
- package/lib/cjs/context/BillingAddressContext.js +1 -1
- package/lib/cjs/context/BillingAddressFormContext.d.ts +18 -11
- package/lib/cjs/context/CouponAndGiftCardFormContext.d.ts +4 -2
- package/lib/cjs/context/CustomerAddressFormContext.d.ts +20 -0
- package/lib/cjs/context/CustomerAddressFormContext.js +1 -0
- package/lib/cjs/context/CustomerContext.d.ts +17 -11
- package/lib/cjs/context/CustomerContext.js +1 -1
- package/lib/cjs/context/ExternalFunctionContext.js +1 -1
- package/lib/cjs/context/OrderContext.d.ts +8 -4
- package/lib/cjs/context/OrderContext.js +1 -1
- package/lib/cjs/context/OrderListChildrenContext.d.ts +60 -0
- package/lib/cjs/context/OrderListChildrenContext.js +1 -0
- package/lib/cjs/context/PaymentSourceContext.d.ts +4 -4
- package/lib/cjs/context/PlaceOrderContext.d.ts +4 -2
- package/lib/cjs/context/ShippingAddressContext.d.ts +1 -1
- package/lib/cjs/context/SkuChildrenContext.d.ts +9 -0
- package/lib/cjs/context/SkuChildrenContext.js +1 -0
- package/lib/cjs/context/SkuContext.d.ts +9 -0
- package/lib/cjs/context/SkuContext.js +1 -0
- package/lib/cjs/index.d.ts +101 -90
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/reducers/AddressReducer.d.ts +4 -2
- package/lib/cjs/reducers/AddressReducer.js +1 -1
- package/lib/cjs/reducers/AvailabilityReducer.d.ts +8 -0
- package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
- package/lib/cjs/reducers/BillingAddressReducer.js +1 -1
- package/lib/cjs/reducers/CustomerReducer.d.ts +98 -17
- package/lib/cjs/reducers/CustomerReducer.js +1 -1
- package/lib/cjs/reducers/GiftCardReducer.js +1 -1
- package/lib/cjs/reducers/ItemReducer.js +1 -1
- package/lib/cjs/reducers/LineItemReducer.js +1 -1
- package/lib/cjs/reducers/OrderReducer.d.ts +24 -8
- package/lib/cjs/reducers/OrderReducer.js +1 -1
- package/lib/cjs/reducers/PaymentMethodReducer.d.ts +51 -5
- package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
- package/lib/cjs/reducers/PlaceOrderReducer.d.ts +9 -2
- package/lib/cjs/reducers/PlaceOrderReducer.js +1 -1
- package/lib/cjs/reducers/PriceReducer.js +1 -1
- package/lib/cjs/reducers/ShipmentReducer.js +1 -1
- package/lib/cjs/reducers/ShippingAddressReducer.js +1 -1
- package/lib/cjs/reducers/SkuListsReducer.js +1 -1
- package/lib/cjs/reducers/SkuOptionsReducer.js +1 -1
- package/lib/cjs/reducers/SkuReducer.d.ts +21 -0
- package/lib/cjs/reducers/SkuReducer.js +1 -0
- package/lib/cjs/reducers/VariantReducer.d.ts +1 -0
- package/lib/cjs/reducers/VariantReducer.js +1 -1
- package/lib/cjs/typings/errors.d.ts +13 -4
- package/lib/cjs/typings/errors.js +1 -1
- package/lib/cjs/typings/index.d.ts +18 -7
- package/lib/cjs/typings/index.js +1 -1
- package/lib/cjs/utils/addressesManager.d.ts +1 -1
- package/lib/cjs/utils/addressesManager.js +1 -1
- package/lib/cjs/utils/baseReducer.js +1 -1
- package/lib/cjs/utils/checkIncludeResource.d.ts +8 -0
- package/lib/cjs/utils/checkIncludeResource.js +1 -0
- package/lib/cjs/utils/childrenTypes.d.ts +1 -1
- package/lib/cjs/utils/childrenTypes.js +1 -1
- package/lib/cjs/utils/compareObjAttribute.d.ts +7 -0
- package/lib/cjs/utils/compareObjAttribute.js +1 -0
- package/lib/cjs/utils/customMessages.d.ts +1 -7
- package/lib/cjs/utils/customMessages.js +1 -1
- package/lib/cjs/utils/getCardDetails.d.ts +15 -0
- package/lib/cjs/utils/getCardDetails.js +1 -0
- package/lib/cjs/utils/getCartLink.d.ts +7 -0
- package/lib/cjs/utils/getCartLink.js +1 -0
- package/lib/cjs/utils/getCurrentItemKey.js +1 -1
- package/lib/cjs/utils/getErrors.d.ts +1 -1
- package/lib/cjs/utils/getErrors.js +1 -1
- package/lib/cjs/utils/getLineItemsCount.d.ts +8 -10
- package/lib/cjs/utils/getLineItemsCount.js +1 -1
- package/lib/cjs/utils/getLoaderComponent.js +1 -1
- package/lib/cjs/utils/getPrices.js +1 -1
- package/lib/cjs/utils/getSdk.js +1 -1
- package/lib/cjs/utils/getSkus.js +1 -1
- package/lib/cjs/utils/hooks/useExternalScript.d.ts +1 -0
- package/lib/cjs/utils/hooks/useExternalScript.js +1 -0
- package/lib/cjs/utils/icons.d.ts +3 -0
- package/lib/cjs/utils/icons.js +1 -0
- package/lib/cjs/utils/isDate.d.ts +1 -0
- package/lib/cjs/utils/isDate.js +1 -0
- package/lib/cjs/utils/jwt.d.ts +1 -1
- package/lib/cjs/utils/jwt.js +1 -1
- package/lib/cjs/utils/paypalPayment.js +1 -1
- package/lib/cjs/utils/placeholderImages.d.ts +2 -0
- package/lib/cjs/utils/placeholderImages.js +1 -0
- package/lib/cjs/utils/promisify.js +1 -1
- package/lib/cjs/utils/scrollbarWidth.d.ts +1 -0
- package/lib/cjs/utils/scrollbarWidth.js +1 -0
- package/lib/cjs/utils/shipments.d.ts +2 -1
- package/lib/cjs/utils/shipments.js +1 -1
- package/lib/cjs/utils/validateFormFields.d.ts +2 -0
- package/lib/cjs/utils/validateFormFields.js +1 -1
- package/lib/esm/components/AdjustmentAmount.js +1 -1
- package/lib/esm/components/AdyenPayment.d.ts +3 -3
- package/lib/esm/components/AdyenPayment.js +1 -1
- package/lib/esm/components/AvailabilityContainer.d.ts +10 -3
- package/lib/esm/components/AvailabilityContainer.js +1 -1
- package/lib/esm/components/AvailabilityTemplate.d.ts +13 -4
- package/lib/esm/components/AvailabilityTemplate.js +1 -1
- package/lib/esm/components/BillingAddressContainer.d.ts +7 -2
- package/lib/esm/components/BillingAddressContainer.js +1 -1
- package/lib/esm/components/BillingAddressForm.d.ts +8 -3
- package/lib/esm/components/BillingAddressForm.js +1 -1
- package/lib/esm/components/BraintreePayment.d.ts +3 -3
- package/lib/esm/components/BraintreePayment.js +1 -1
- package/lib/esm/components/CartLink.d.ts +12 -0
- package/lib/esm/components/CartLink.js +1 -0
- package/lib/esm/components/CheckoutComPayment.d.ts +23 -0
- package/lib/esm/components/CheckoutComPayment.js +1 -0
- package/lib/esm/components/CheckoutLink.d.ts +16 -4
- package/lib/esm/components/CheckoutLink.js +1 -1
- package/lib/esm/components/DeliveryLeadTime.d.ts +11 -4
- package/lib/esm/components/DeliveryLeadTime.js +1 -1
- package/lib/esm/components/DiscountAmount.d.ts +16 -2
- package/lib/esm/components/DiscountAmount.js +1 -1
- package/lib/esm/components/Errors.d.ts +4 -4
- package/lib/esm/components/Errors.js +1 -1
- package/lib/esm/components/ExternalFunction.d.ts +9 -2
- package/lib/esm/components/ExternalFunction.js +1 -1
- package/lib/esm/components/GiftCard.d.ts +13 -3
- package/lib/esm/components/GiftCard.js +1 -1
- package/lib/esm/components/GiftCardContainer.d.ts +9 -3
- package/lib/esm/components/GiftCardContainer.js +1 -1
- package/lib/esm/components/GiftCardCurrencySelector.d.ts +18 -3
- package/lib/esm/components/GiftCardCurrencySelector.js +1 -1
- package/lib/esm/components/GiftCardInput.d.ts +12 -3
- package/lib/esm/components/GiftCardInput.js +1 -1
- package/lib/esm/components/GiftCardOrCouponCode.d.ts +17 -6
- package/lib/esm/components/GiftCardOrCouponCode.js +1 -1
- package/lib/esm/components/GiftCardOrCouponForm.d.ts +9 -4
- package/lib/esm/components/GiftCardOrCouponForm.js +1 -1
- package/lib/esm/components/GiftCardOrCouponInput.d.ts +14 -3
- package/lib/esm/components/GiftCardOrCouponInput.js +1 -1
- package/lib/esm/components/GiftCardOrCouponRemoveButton.d.ts +15 -5
- package/lib/esm/components/GiftCardOrCouponRemoveButton.js +1 -1
- package/lib/esm/components/GiftCardOrCouponSubmit.d.ts +11 -4
- package/lib/esm/components/GiftCardOrCouponSubmit.js +1 -1
- package/lib/esm/components/ItemContainer.d.ts +14 -3
- package/lib/esm/components/ItemContainer.js +1 -1
- package/lib/esm/components/KlarnaPayment.d.ts +10 -0
- package/lib/esm/components/KlarnaPayment.js +1 -0
- package/lib/esm/components/LineItem.d.ts +10 -3
- package/lib/esm/components/LineItem.js +1 -1
- package/lib/esm/components/LineItemAmount.d.ts +16 -3
- package/lib/esm/components/LineItemAmount.js +1 -1
- package/lib/esm/components/LineItemCode.d.ts +10 -4
- package/lib/esm/components/LineItemCode.js +1 -1
- package/lib/esm/components/LineItemImage.d.ts +11 -4
- package/lib/esm/components/LineItemImage.js +1 -1
- package/lib/esm/components/LineItemName.d.ts +11 -5
- package/lib/esm/components/LineItemName.js +1 -1
- package/lib/esm/components/LineItemOption.d.ts +15 -4
- package/lib/esm/components/LineItemOption.js +1 -1
- package/lib/esm/components/LineItemOptions.d.ts +8 -3
- package/lib/esm/components/LineItemOptions.js +1 -1
- package/lib/esm/components/LineItemQuantity.d.ts +16 -4
- package/lib/esm/components/LineItemQuantity.js +1 -1
- package/lib/esm/components/LineItemRemoveLink.d.ts +15 -5
- package/lib/esm/components/LineItemRemoveLink.js +1 -1
- package/lib/esm/components/LineItemsContainer.d.ts +15 -3
- package/lib/esm/components/LineItemsContainer.js +1 -1
- package/lib/esm/components/LineItemsCount.d.ts +14 -4
- package/lib/esm/components/LineItemsCount.js +1 -1
- package/lib/esm/components/LineItemsEmpty.d.ts +13 -2
- package/lib/esm/components/LineItemsEmpty.js +1 -1
- package/lib/esm/components/MetadataInput.d.ts +13 -3
- package/lib/esm/components/MetadataInput.js +1 -1
- package/lib/esm/components/PaymentGateway.d.ts +4 -4
- package/lib/esm/components/PaymentGateway.js +1 -1
- package/lib/esm/components/PaymentMethod.d.ts +9 -3
- package/lib/esm/components/PaymentMethod.js +1 -1
- package/lib/esm/components/PaymentMethodAmount.d.ts +16 -2
- package/lib/esm/components/PaymentMethodAmount.js +1 -1
- package/lib/esm/components/PaymentMethodName.d.ts +10 -4
- package/lib/esm/components/PaymentMethodName.js +1 -1
- package/lib/esm/components/PaymentMethodPrice.d.ts +15 -4
- package/lib/esm/components/PaymentMethodPrice.js +1 -1
- package/lib/esm/components/PaymentMethodRadioButton.d.ts +11 -4
- package/lib/esm/components/PaymentMethodRadioButton.js +1 -1
- package/lib/esm/components/PaymentMethodsContainer.d.ts +9 -3
- package/lib/esm/components/PaymentMethodsContainer.js +1 -1
- package/lib/esm/components/PaymentSource.d.ts +9 -2
- package/lib/esm/components/PaymentSource.js +1 -1
- package/lib/esm/components/PaymentSourceBrandIcon.d.ts +14 -4
- package/lib/esm/components/PaymentSourceBrandIcon.js +1 -1
- package/lib/esm/components/PaymentSourceBrandName.d.ts +11 -4
- package/lib/esm/components/PaymentSourceBrandName.js +1 -1
- package/lib/esm/components/PaymentSourceDetail.d.ts +8 -2
- package/lib/esm/components/PaymentSourceDetail.js +1 -1
- package/lib/esm/components/PaymentSourceEditButton.d.ts +9 -2
- package/lib/esm/components/PaymentSourceEditButton.js +1 -1
- package/lib/esm/components/PaypalPayment.d.ts +2 -2
- package/lib/esm/components/PaypalPayment.js +1 -1
- package/lib/esm/components/Price.d.ts +15 -3
- package/lib/esm/components/Price.js +1 -1
- package/lib/esm/components/PricesContainer.d.ts +19 -3
- package/lib/esm/components/PricesContainer.js +1 -1
- package/lib/esm/components/QuantitySelector.d.ts +19 -5
- package/lib/esm/components/QuantitySelector.js +1 -1
- package/lib/esm/components/SaveAddressesButton.d.ts +18 -5
- package/lib/esm/components/SaveAddressesButton.js +1 -1
- package/lib/esm/components/SaveCustomerButton.d.ts +16 -5
- package/lib/esm/components/SaveCustomerButton.js +1 -1
- package/lib/esm/components/ShippingAddressContainer.d.ts +7 -2
- package/lib/esm/components/ShippingAddressContainer.js +1 -1
- package/lib/esm/components/ShippingAddressForm.d.ts +8 -3
- package/lib/esm/components/ShippingAddressForm.js +1 -1
- package/lib/esm/components/ShippingAmount.d.ts +13 -2
- package/lib/esm/components/ShippingAmount.js +1 -1
- package/lib/esm/components/ShippingMethod.d.ts +10 -3
- package/lib/esm/components/ShippingMethod.js +1 -1
- package/lib/esm/components/ShippingMethodName.d.ts +11 -5
- package/lib/esm/components/ShippingMethodName.js +1 -1
- package/lib/esm/components/ShippingMethodPrice.d.ts +15 -3
- package/lib/esm/components/ShippingMethodPrice.js +1 -1
- package/lib/esm/components/ShippingMethodRadioButton.d.ts +11 -5
- package/lib/esm/components/ShippingMethodRadioButton.js +1 -1
- package/lib/esm/components/SkuField.d.ts +10 -0
- package/lib/esm/components/SkuField.js +1 -0
- package/lib/esm/components/Skus.d.ts +11 -0
- package/lib/esm/components/Skus.js +1 -0
- package/lib/esm/components/SkusContainer.d.ts +14 -0
- package/lib/esm/components/SkusContainer.js +1 -0
- package/lib/esm/components/StockTransfer.d.ts +9 -3
- package/lib/esm/components/StockTransfer.js +1 -1
- package/lib/esm/components/StockTransferField.d.ts +9 -8
- package/lib/esm/components/StockTransferField.js +1 -1
- package/lib/esm/components/StripePayment.d.ts +3 -3
- package/lib/esm/components/StripePayment.js +1 -1
- package/lib/esm/components/SubmitButton.d.ts +15 -5
- package/lib/esm/components/SubmitButton.js +1 -1
- package/lib/esm/components/VariantSelector.d.ts +28 -5
- package/lib/esm/components/VariantSelector.js +1 -1
- package/lib/esm/components/VariantsContainer.d.ts +15 -3
- package/lib/esm/components/VariantsContainer.js +1 -1
- package/lib/esm/components/WireTransferPayment.d.ts +2 -2
- package/lib/esm/components/WireTransferPayment.js +1 -1
- package/lib/esm/components/addresses/Address.d.ts +18 -0
- package/lib/esm/components/addresses/Address.js +1 -0
- package/lib/esm/components/addresses/AddressCountrySelector.d.ts +26 -0
- package/lib/esm/components/addresses/AddressCountrySelector.js +1 -0
- package/lib/esm/components/addresses/AddressField.d.ts +43 -0
- package/lib/esm/components/addresses/AddressField.js +1 -0
- package/lib/esm/components/addresses/AddressInput.d.ts +19 -0
- package/lib/esm/components/addresses/AddressInput.js +1 -0
- package/lib/esm/components/addresses/AddressStateSelector.d.ts +27 -0
- package/lib/esm/components/addresses/AddressStateSelector.js +1 -0
- package/lib/esm/components/addresses/AddressesContainer.d.ts +15 -0
- package/lib/esm/components/addresses/AddressesContainer.js +1 -0
- package/lib/esm/components/auth/CommerceLayer.d.ts +15 -0
- package/lib/esm/components/auth/CommerceLayer.js +1 -0
- package/lib/esm/components/customers/CustomerAddressForm.d.ts +13 -0
- package/lib/esm/components/customers/CustomerAddressForm.js +1 -0
- package/lib/esm/components/customers/CustomerContainer.d.ts +17 -0
- package/lib/esm/components/customers/CustomerContainer.js +1 -0
- package/lib/esm/components/customers/CustomerField.d.ts +10 -0
- package/lib/esm/components/customers/CustomerField.js +1 -0
- package/lib/esm/components/customers/CustomerInput.d.ts +23 -0
- package/lib/esm/components/customers/CustomerInput.js +1 -0
- package/lib/esm/components/gateways/AdyenGateway.d.ts +2 -2
- package/lib/esm/components/gateways/AdyenGateway.js +1 -1
- package/lib/esm/components/gateways/BraintreeGateway.d.ts +2 -2
- package/lib/esm/components/gateways/BraintreeGateway.js +1 -1
- package/lib/esm/components/gateways/CheckoutComGateway.d.ts +5 -0
- package/lib/esm/components/gateways/CheckoutComGateway.js +1 -0
- package/lib/esm/components/gateways/KlarnaGateway.d.ts +5 -0
- package/lib/esm/components/gateways/KlarnaGateway.js +1 -0
- package/lib/esm/components/gateways/PaypalGateway.d.ts +3 -3
- package/lib/esm/components/gateways/PaypalGateway.js +1 -1
- package/lib/esm/components/gateways/StripeGateway.d.ts +2 -2
- package/lib/esm/components/gateways/StripeGateway.js +1 -1
- package/lib/esm/components/gateways/WireTransferGateway.d.ts +2 -2
- package/lib/esm/components/gateways/WireTransferGateway.js +1 -1
- package/lib/esm/components/orders/AddToCartButton.d.ts +34 -0
- package/lib/esm/components/orders/AddToCartButton.js +1 -0
- package/lib/esm/components/orders/AdjustmentAmount.d.ts +18 -0
- package/lib/esm/components/orders/AdjustmentAmount.js +1 -0
- package/lib/esm/components/orders/CartLink.d.ts +12 -0
- package/lib/esm/components/orders/CartLink.js +1 -0
- package/lib/esm/components/orders/GiftCardAmount.d.ts +15 -0
- package/lib/esm/components/orders/GiftCardAmount.js +1 -0
- package/lib/esm/components/orders/OrderContainer.d.ts +26 -0
- package/lib/esm/components/orders/OrderContainer.js +1 -0
- package/lib/esm/components/orders/OrderList.d.ts +61 -0
- package/lib/esm/components/orders/OrderList.js +1 -0
- package/lib/esm/components/orders/OrderListRow.d.ts +30 -0
- package/lib/esm/components/orders/OrderListRow.js +1 -0
- package/lib/esm/components/orders/OrderNumber.d.ts +11 -0
- package/lib/esm/components/orders/OrderNumber.js +1 -0
- package/lib/esm/components/orders/OrderStorage.d.ts +16 -0
- package/lib/esm/components/orders/OrderStorage.js +1 -0
- package/lib/esm/components/orders/PlaceOrderButton.d.ts +24 -0
- package/lib/esm/components/orders/PlaceOrderButton.js +1 -0
- package/lib/esm/components/orders/PlaceOrderContainer.d.ts +14 -0
- package/lib/esm/components/orders/PlaceOrderContainer.js +1 -0
- package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +10 -0
- package/lib/esm/components/orders/PrivacyAndTermsCheckbox.js +1 -0
- package/lib/esm/components/orders/SubTotalAmount.d.ts +18 -0
- package/lib/esm/components/orders/SubTotalAmount.js +1 -0
- package/lib/esm/components/orders/TaxesAmount.d.ts +18 -0
- package/lib/esm/components/orders/TaxesAmount.js +1 -0
- package/lib/esm/components/orders/TotalAmount.d.ts +18 -0
- package/lib/esm/components/orders/TotalAmount.js +1 -0
- package/lib/esm/components/shipments/Shipment.d.ts +15 -0
- package/lib/esm/components/shipments/Shipment.js +1 -0
- package/lib/esm/components/shipments/ShipmentField.d.ts +19 -0
- package/lib/esm/components/shipments/ShipmentField.js +1 -0
- package/lib/esm/components/shipments/ShipmentsContainer.d.ts +12 -0
- package/lib/esm/components/shipments/ShipmentsContainer.js +1 -0
- package/lib/esm/components/skus/SkuField.d.ts +14 -0
- package/lib/esm/components/skus/SkuField.js +1 -0
- package/lib/esm/components/skus/SkuList.d.ts +14 -0
- package/lib/esm/components/skus/SkuList.js +1 -0
- package/lib/esm/components/skus/SkuListsContainer.d.ts +12 -0
- package/lib/esm/components/skus/SkuListsContainer.js +1 -0
- package/lib/esm/components/skus/SkuOption.d.ts +14 -0
- package/lib/esm/components/skus/SkuOption.js +1 -0
- package/lib/esm/components/skus/SkuOptionInput.d.ts +15 -0
- package/lib/esm/components/skus/SkuOptionInput.js +1 -0
- package/lib/esm/components/skus/SkuOptionsContainer.d.ts +14 -0
- package/lib/esm/components/skus/SkuOptionsContainer.js +1 -0
- package/lib/esm/components/skus/Skus.d.ts +11 -0
- package/lib/esm/components/skus/Skus.js +1 -0
- package/lib/esm/components/skus/SkusContainer.d.ts +23 -0
- package/lib/esm/components/skus/SkusContainer.js +1 -0
- package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -1
- package/lib/esm/components/utils/AddressCardsTemplate.js +1 -1
- package/lib/esm/components/utils/BaseField.js +1 -1
- package/lib/esm/components/utils/BaseInput.d.ts +1 -1
- package/lib/esm/components/utils/BaseInput.js +1 -1
- package/lib/esm/components/utils/BaseOrderPrice.js +1 -1
- package/lib/esm/components/utils/BaseSelect.js +1 -1
- package/lib/esm/components/utils/GenericFieldComponent.d.ts +42 -0
- package/lib/esm/components/utils/GenericFieldComponent.js +1 -0
- package/lib/esm/components/utils/Parent.d.ts +3 -5
- package/lib/esm/components/utils/Parent.js +1 -1
- package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +2 -2
- package/lib/esm/components/utils/PaymentCardsTemplate.js +1 -1
- package/lib/esm/components/utils/PriceTemplate.d.ts +2 -2
- package/lib/esm/components/utils/PriceTemplate.js +1 -1
- package/lib/esm/components/utils/VariantTemplate.js +1 -1
- package/lib/esm/components/utils/getAllErrors.js +1 -1
- package/lib/esm/config/components.d.ts +78 -36
- package/lib/esm/config/components.js +1 -1
- package/lib/esm/context/AddressChildrenContext.d.ts +1 -1
- package/lib/esm/context/AddressChildrenContext.js +1 -1
- package/lib/esm/context/AddressContext.d.ts +1 -1
- package/lib/esm/context/BillingAddressContext.d.ts +2 -4
- package/lib/esm/context/BillingAddressContext.js +1 -1
- package/lib/esm/context/BillingAddressFormContext.d.ts +18 -11
- package/lib/esm/context/CouponAndGiftCardFormContext.d.ts +4 -2
- package/lib/esm/context/CustomerAddressFormContext.d.ts +20 -0
- package/lib/esm/context/CustomerAddressFormContext.js +1 -0
- package/lib/esm/context/CustomerContext.d.ts +17 -11
- package/lib/esm/context/CustomerContext.js +1 -1
- package/lib/esm/context/OrderContext.d.ts +8 -4
- package/lib/esm/context/OrderContext.js +1 -1
- package/lib/esm/context/OrderListChildrenContext.d.ts +60 -0
- package/lib/esm/context/OrderListChildrenContext.js +1 -0
- package/lib/esm/context/PaymentSourceContext.d.ts +4 -4
- package/lib/esm/context/PlaceOrderContext.d.ts +4 -2
- package/lib/esm/context/ShippingAddressContext.d.ts +1 -1
- package/lib/esm/context/SkuChildrenContext.d.ts +9 -0
- package/lib/esm/context/SkuChildrenContext.js +1 -0
- package/lib/esm/context/SkuContext.d.ts +9 -0
- package/lib/esm/context/SkuContext.js +1 -0
- package/lib/esm/index.d.ts +101 -90
- package/lib/esm/index.js +1 -1
- package/lib/esm/reducers/AddressReducer.d.ts +4 -2
- package/lib/esm/reducers/AddressReducer.js +1 -1
- package/lib/esm/reducers/AvailabilityReducer.d.ts +8 -0
- package/lib/esm/reducers/AvailabilityReducer.js +1 -1
- package/lib/esm/reducers/BillingAddressReducer.js +1 -1
- package/lib/esm/reducers/CustomerReducer.d.ts +98 -17
- package/lib/esm/reducers/CustomerReducer.js +1 -1
- package/lib/esm/reducers/GiftCardReducer.js +1 -1
- package/lib/esm/reducers/LineItemReducer.js +1 -1
- package/lib/esm/reducers/OrderReducer.d.ts +24 -8
- package/lib/esm/reducers/OrderReducer.js +1 -1
- package/lib/esm/reducers/PaymentMethodReducer.d.ts +51 -5
- package/lib/esm/reducers/PaymentMethodReducer.js +1 -1
- package/lib/esm/reducers/PlaceOrderReducer.d.ts +9 -2
- package/lib/esm/reducers/PlaceOrderReducer.js +1 -1
- package/lib/esm/reducers/PriceReducer.js +1 -1
- package/lib/esm/reducers/ShipmentReducer.js +1 -1
- package/lib/esm/reducers/ShippingAddressReducer.js +1 -1
- package/lib/esm/reducers/SkuReducer.d.ts +21 -0
- package/lib/esm/reducers/SkuReducer.js +1 -0
- package/lib/esm/reducers/VariantReducer.d.ts +1 -0
- package/lib/esm/reducers/VariantReducer.js +1 -1
- package/lib/esm/typings/errors.d.ts +13 -4
- package/lib/esm/typings/errors.js +1 -1
- package/lib/esm/typings/index.d.ts +18 -7
- package/lib/esm/typings/index.js +1 -1
- package/lib/esm/utils/addressesManager.d.ts +1 -1
- package/lib/esm/utils/addressesManager.js +1 -1
- package/lib/esm/utils/baseReducer.js +1 -1
- package/lib/esm/utils/checkIncludeResource.d.ts +8 -0
- package/lib/esm/utils/checkIncludeResource.js +1 -0
- package/lib/esm/utils/childrenTypes.d.ts +1 -1
- package/lib/esm/utils/childrenTypes.js +1 -1
- package/lib/esm/utils/compareObjAttribute.d.ts +7 -0
- package/lib/esm/utils/compareObjAttribute.js +1 -0
- package/lib/esm/utils/customMessages.d.ts +1 -7
- package/lib/esm/utils/customMessages.js +1 -1
- package/lib/esm/utils/getCardDetails.d.ts +15 -0
- package/lib/esm/utils/getCardDetails.js +1 -0
- package/lib/esm/utils/getCartLink.d.ts +7 -0
- package/lib/esm/utils/getCartLink.js +1 -0
- package/lib/esm/utils/getCurrentItemKey.js +1 -1
- package/lib/esm/utils/getErrors.d.ts +1 -1
- package/lib/esm/utils/getErrors.js +1 -1
- package/lib/esm/utils/getLineItemsCount.d.ts +8 -10
- package/lib/esm/utils/getLineItemsCount.js +1 -1
- package/lib/esm/utils/getLoaderComponent.js +1 -1
- package/lib/esm/utils/getPrices.js +1 -1
- package/lib/esm/utils/getSdk.js +1 -1
- package/lib/esm/utils/getSkus.js +1 -1
- package/lib/esm/utils/hooks/useExternalScript.d.ts +1 -0
- package/lib/esm/utils/hooks/useExternalScript.js +1 -0
- package/lib/esm/utils/icons.d.ts +3 -0
- package/lib/esm/utils/icons.js +1 -0
- package/lib/esm/utils/isDate.d.ts +1 -0
- package/lib/esm/utils/isDate.js +1 -0
- package/lib/esm/utils/jwt.d.ts +1 -1
- package/lib/esm/utils/placeholderImages.d.ts +2 -0
- package/lib/esm/utils/placeholderImages.js +1 -0
- package/lib/esm/utils/promisify.js +1 -1
- package/lib/esm/utils/scrollbarWidth.d.ts +1 -0
- package/lib/esm/utils/scrollbarWidth.js +1 -0
- package/lib/esm/utils/shipments.d.ts +2 -1
- package/lib/esm/utils/shipments.js +1 -1
- package/lib/esm/utils/validateFormFields.d.ts +2 -0
- package/lib/esm/utils/validateFormFields.js +1 -1
- package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +118 -93
- package/lib/cjs/components/AddToCartButton.d.ts +0 -20
- package/lib/cjs/components/AddToCartButton.js +0 -1
- package/lib/cjs/components/Address.d.ts +0 -13
- package/lib/cjs/components/Address.js +0 -1
- package/lib/cjs/components/AddressCountrySelector.d.ts +0 -9
- package/lib/cjs/components/AddressCountrySelector.js +0 -1
- package/lib/cjs/components/AddressField.d.ts +0 -15
- package/lib/cjs/components/AddressField.js +0 -1
- package/lib/cjs/components/AddressInput.d.ts +0 -7
- package/lib/cjs/components/AddressInput.js +0 -1
- package/lib/cjs/components/AddressStateSelector.d.ts +0 -11
- package/lib/cjs/components/AddressStateSelector.js +0 -1
- package/lib/cjs/components/AddressesContainer.d.ts +0 -7
- package/lib/cjs/components/AddressesContainer.js +0 -1
- package/lib/cjs/components/CommerceLayer.d.ts +0 -8
- package/lib/cjs/components/CommerceLayer.js +0 -1
- package/lib/cjs/components/CustomerContainer.d.ts +0 -7
- package/lib/cjs/components/CustomerContainer.js +0 -1
- package/lib/cjs/components/CustomerInput.d.ts +0 -11
- package/lib/cjs/components/CustomerInput.js +0 -1
- package/lib/cjs/components/GiftCardAmount.d.ts +0 -4
- package/lib/cjs/components/GiftCardAmount.js +0 -1
- package/lib/cjs/components/OrderContainer.d.ts +0 -11
- package/lib/cjs/components/OrderContainer.js +0 -1
- package/lib/cjs/components/OrderNumber.d.ts +0 -5
- package/lib/cjs/components/OrderNumber.js +0 -1
- package/lib/cjs/components/OrderStorage.d.ts +0 -8
- package/lib/cjs/components/OrderStorage.js +0 -1
- package/lib/cjs/components/PlaceOrderButton.d.ts +0 -12
- package/lib/cjs/components/PlaceOrderButton.js +0 -1
- package/lib/cjs/components/PlaceOrderContainer.d.ts +0 -8
- package/lib/cjs/components/PlaceOrderContainer.js +0 -1
- package/lib/cjs/components/PrivacyAndTermsCheckbox.d.ts +0 -4
- package/lib/cjs/components/PrivacyAndTermsCheckbox.js +0 -1
- package/lib/cjs/components/Shipment.d.ts +0 -8
- package/lib/cjs/components/Shipment.js +0 -1
- package/lib/cjs/components/ShipmentField.d.ts +0 -12
- package/lib/cjs/components/ShipmentField.js +0 -1
- package/lib/cjs/components/ShipmentsContainer.d.ts +0 -6
- package/lib/cjs/components/ShipmentsContainer.js +0 -1
- package/lib/cjs/components/SkuList.d.ts +0 -7
- package/lib/cjs/components/SkuList.js +0 -1
- package/lib/cjs/components/SkuListsContainer.d.ts +0 -6
- package/lib/cjs/components/SkuListsContainer.js +0 -1
- package/lib/cjs/components/SkuOption.d.ts +0 -7
- package/lib/cjs/components/SkuOption.js +0 -1
- package/lib/cjs/components/SkuOptionInput.d.ts +0 -5
- package/lib/cjs/components/SkuOptionInput.js +0 -1
- package/lib/cjs/components/SkuOptionsContainer.d.ts +0 -7
- package/lib/cjs/components/SkuOptionsContainer.js +0 -1
- package/lib/cjs/components/SubTotalAmount.d.ts +0 -4
- package/lib/cjs/components/SubTotalAmount.js +0 -1
- package/lib/cjs/components/TaxesAmount.d.ts +0 -4
- package/lib/cjs/components/TaxesAmount.js +0 -1
- package/lib/cjs/components/TotalAmount.d.ts +0 -4
- package/lib/cjs/components/TotalAmount.js +0 -1
- package/lib/esm/components/AddToCartButton.d.ts +0 -20
- package/lib/esm/components/AddToCartButton.js +0 -1
- package/lib/esm/components/Address.d.ts +0 -13
- package/lib/esm/components/Address.js +0 -1
- package/lib/esm/components/AddressCountrySelector.d.ts +0 -9
- package/lib/esm/components/AddressCountrySelector.js +0 -1
- package/lib/esm/components/AddressField.d.ts +0 -15
- package/lib/esm/components/AddressField.js +0 -1
- package/lib/esm/components/AddressInput.d.ts +0 -7
- package/lib/esm/components/AddressInput.js +0 -1
- package/lib/esm/components/AddressStateSelector.d.ts +0 -11
- package/lib/esm/components/AddressStateSelector.js +0 -1
- package/lib/esm/components/AddressesContainer.d.ts +0 -7
- package/lib/esm/components/AddressesContainer.js +0 -1
- package/lib/esm/components/CommerceLayer.d.ts +0 -8
- package/lib/esm/components/CommerceLayer.js +0 -1
- package/lib/esm/components/CustomerContainer.d.ts +0 -7
- package/lib/esm/components/CustomerContainer.js +0 -1
- package/lib/esm/components/CustomerInput.d.ts +0 -11
- package/lib/esm/components/CustomerInput.js +0 -1
- package/lib/esm/components/GiftCardAmount.d.ts +0 -4
- package/lib/esm/components/GiftCardAmount.js +0 -1
- package/lib/esm/components/OrderContainer.d.ts +0 -11
- package/lib/esm/components/OrderContainer.js +0 -1
- package/lib/esm/components/OrderNumber.d.ts +0 -5
- package/lib/esm/components/OrderNumber.js +0 -1
- package/lib/esm/components/OrderStorage.d.ts +0 -8
- package/lib/esm/components/OrderStorage.js +0 -1
- package/lib/esm/components/PlaceOrderButton.d.ts +0 -12
- package/lib/esm/components/PlaceOrderButton.js +0 -1
- package/lib/esm/components/PlaceOrderContainer.d.ts +0 -8
- package/lib/esm/components/PlaceOrderContainer.js +0 -1
- package/lib/esm/components/PrivacyAndTermsCheckbox.d.ts +0 -4
- package/lib/esm/components/PrivacyAndTermsCheckbox.js +0 -1
- package/lib/esm/components/Shipment.d.ts +0 -8
- package/lib/esm/components/Shipment.js +0 -1
- package/lib/esm/components/ShipmentField.d.ts +0 -12
- package/lib/esm/components/ShipmentField.js +0 -1
- package/lib/esm/components/ShipmentsContainer.d.ts +0 -6
- package/lib/esm/components/ShipmentsContainer.js +0 -1
- package/lib/esm/components/SkuList.d.ts +0 -7
- package/lib/esm/components/SkuList.js +0 -1
- package/lib/esm/components/SkuListsContainer.d.ts +0 -6
- package/lib/esm/components/SkuListsContainer.js +0 -1
- package/lib/esm/components/SkuOption.d.ts +0 -7
- package/lib/esm/components/SkuOption.js +0 -1
- package/lib/esm/components/SkuOptionInput.d.ts +0 -5
- package/lib/esm/components/SkuOptionInput.js +0 -1
- package/lib/esm/components/SkuOptionsContainer.d.ts +0 -7
- package/lib/esm/components/SkuOptionsContainer.js +0 -1
- package/lib/esm/components/SubTotalAmount.d.ts +0 -4
- package/lib/esm/components/SubTotalAmount.js +0 -1
- package/lib/esm/components/TaxesAmount.d.ts +0 -4
- package/lib/esm/components/TaxesAmount.js +0 -1
- package/lib/esm/components/TotalAmount.d.ts +0 -4
- package/lib/esm/components/TotalAmount.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import
|
|
1
|
+
import{setCustomerOrderParam}from"../utils/localStorage";import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import size from"lodash/size";import map from"lodash/map";import getSdk from"../utils/getSdk";import getErrors,{setErrors}from"../utils/getErrors";import getOrganizationSlug from"../utils/organization";const actionType=["setLoading","setOrderId","setOrder","setSingleQuantity","setCurrentSkuCodes","setCurrentSkuPrices","setErrors","setCurrentItem","setSaveAddressToCustomerAddressBook","setIncludesResource"];export const createOrder=async params=>{if(params){const{persistKey,state,dispatch,config,orderMetadata:metadata,orderAttributes={},setLocalOrder}=params;if(state?.orderId)return state.orderId;const sdk=getSdk(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=getErrors(error,"orders");console.error("Create order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch})}}return""},getApiOrder=async params=>{const{id,dispatch,config,clearWhenPlaced,persistKey,deleteLocalOrder,state}=params,sdk=getSdk(config);try{const options={};state?.include&&state.include.length>0&&(options.include=state.include);const order=await sdk.orders.retrieve(id,options);return clearWhenPlaced&&order.status==="placed"||order.status==="approved"||order.status==="cancelled"?(persistKey&&deleteLocalOrder&&deleteLocalOrder(persistKey),dispatch&&dispatch({type:"setOrder",payload:{order:void 0,orderId:""}})):dispatch&&dispatch({type:"setOrder",payload:{order,orderId:order.id}}),order}catch(error){const errors=getErrors(error,"orders");console.error("Retrieve order",errors),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors,dispatch});return}};export async function updateOrder({id,attributes,dispatch,config,include,state}){const sdk=getSdk(config);try{const resource={...attributes,id};await sdk.orders.update(resource,{include});const order=await getApiOrder({id,config,dispatch,state});return dispatch&&order&&dispatch({type:"setOrder",payload:{order}}),{success:!0}}catch(error){const errors=getErrors(error,"orders");return dispatch&&(setOrderErrors({errors,dispatch}),dispatch({type:"setErrors",payload:{errors}})),{success:!1,error}}}export const setOrder=(order,dispatch)=>{dispatch&&dispatch({type:"setOrder",payload:{order}})};export function addResourceToInclude({resourcesIncluded=[],dispatch,newResource,newResourceLoaded,resourceIncludedLoaded}){const payload={include:void 0,includeLoaded:void 0};if(newResource){const resources=typeof newResource=="string"?[newResource]:newResource;payload.include=[...resourcesIncluded,...resources],resources.forEach(resource=>{payload.includeLoaded={...payload.includeLoaded,[resource]:!0}})}else delete payload.include;payload.includeLoaded={...resourceIncludedLoaded,...newResourceLoaded,...payload.includeLoaded&&payload.includeLoaded},dispatch&&dispatch({type:"setIncludesResource",payload:{...payload,withoutIncludes:!1}})}export const addToCart=async params=>{const{skuCode,bundleCode,skuId,quantity,option,config,dispatch,lineItem,state,errors=[],buyNowMode,checkoutUrl}=params;try{if(!config)throw{errors:[{code:"INVALID_RESOURCE",resource:"orders",title:"Markup error",message:"You are trying to place an order outside the OrderContainer component"}]};const sdk=getSdk(config),id=await createOrder(params);if(id){const order=sdk.orders.relationship(id),name=lineItem?.name,imageUrl=lineItem?.imageUrl;if(buyNowMode)if(state?.order?.line_items)await Promise.all(state?.order?.line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}));else{const{line_items}=await sdk.orders.retrieve(id,{fields:["line_items"],include:["line_items"]});line_items&&line_items?.length>0&&await Promise.all(line_items.map(async lineItem2=>{await sdk.line_items.delete(lineItem2.id)}))}const attrs={order,sku_code:skuCode,name,image_url:imageUrl,quantity:quantity||1,_update_quantity:!0,bundle_code:bundleCode};skuId&&(attrs.item=sdk.skus.relationship(skuId));const newLineItem=await sdk.line_items.create(attrs);if(isEmpty(option))await getApiOrder({id,...params,state});else{let c=0;map(option,async opt=>{const{options,skuOptionId}=opt,skuOption=sdk.sku_options.relationship(skuOptionId),lineItemRel=sdk.line_items.relationship(newLineItem.id),lineItemOptionsAttributes={quantity:1,options,sku_option:skuOption,line_item:lineItemRel};await sdk.line_item_options.create(lineItemOptionsAttributes),c+=1,c===size(option)&&await getApiOrder({id,...params})})}if(!isEmpty(errors)&&dispatch&&dispatch({type:"setErrors",payload:{errors:[]}}),buyNowMode){const{organization}=getOrganizationSlug(config.endpoint),params2=`${id}?accessToken=${config.accessToken}`,redirectUrl=checkoutUrl?`${checkoutUrl}/${params2}`:`https://${organization}.checkout.commercelayer.app/${params2}`;location.href=redirectUrl}return{success:!0,orderId:id}}return{success:!1,orderId:void 0}}catch(error){const errors2=getErrors(error,"orders");return console.error("Add to cart",errors2),dispatch&&setErrors({currentErrors:state?.errors,newErrors:errors2,dispatch}),{success:!1,orderId:void 0}}},unsetOrderState=dispatch=>{dispatch({type:"setOrderId",payload:{orderId:""}}),dispatch({type:"setOrder",payload:{order:void 0}})};export function setOrderErrors({dispatch,errors=[]}){return dispatch&&dispatch({type:"setErrors",payload:{errors}}),{success:!1}}export const saveAddressToCustomerAddressBook=({type,value,dispatch})=>{const k=`_save_${type}_to_customer_address_book`,v=`${value}`;setCustomerOrderParam(k,v),dispatch&&dispatch({type:"setSaveAddressToCustomerAddressBook",payload:{[k]:v}})},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=getErrors(error,"orders",codeType);return dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}},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=getErrors(error,"orders",codeType);return console.error("Remove gift card o coupon code",errors),dispatch&&setOrderErrors({errors,dispatch}),{success:!1}}},orderInitialState={loading:!0,orderId:"",order:void 0,errors:[],include:void 0,withoutIncludes:!0};const orderReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default orderReducer;
|
|
@@ -6,9 +6,51 @@ import { WireTransferConfig } from '../components/WireTransferPayment';
|
|
|
6
6
|
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
7
7
|
import { getOrderContext, updateOrder } from './OrderReducer';
|
|
8
8
|
import { BaseError } from '../typings/errors';
|
|
9
|
-
import { Order, PaymentMethod, StripePayment, WireTransfer, AdyenPayment, BraintreePayment, CheckoutComPayment, ExternalPayment, PaypalPayment } from '@commercelayer/sdk';
|
|
9
|
+
import { Order, PaymentMethod, StripePayment, WireTransfer, AdyenPayment, BraintreePayment, CheckoutComPayment, ExternalPayment, PaypalPayment, KlarnaPayment } from '@commercelayer/sdk';
|
|
10
10
|
import { Dispatch, MutableRefObject } from 'react';
|
|
11
|
+
import { CheckoutComConfig } from '../components/CheckoutComPayment';
|
|
11
12
|
export declare type PaymentSourceType = AdyenPayment | BraintreePayment | CheckoutComPayment | ExternalPayment | PaypalPayment | StripePayment | WireTransfer;
|
|
13
|
+
declare type Card = {
|
|
14
|
+
brand: string;
|
|
15
|
+
last4: string;
|
|
16
|
+
exp_year: number;
|
|
17
|
+
exp_month: number;
|
|
18
|
+
};
|
|
19
|
+
export declare type PaymentSourceObject = {
|
|
20
|
+
adyen_payments: AdyenPayment & {
|
|
21
|
+
payment_request_data?: {
|
|
22
|
+
payment_method?: Card;
|
|
23
|
+
};
|
|
24
|
+
payment_response?: {
|
|
25
|
+
resultCode?: 'Authorised';
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
braintree_payments: BraintreePayment & {
|
|
29
|
+
options?: {
|
|
30
|
+
card: Card;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
external_payments: ExternalPayment & {
|
|
34
|
+
payment_source_token?: string;
|
|
35
|
+
};
|
|
36
|
+
paypal_payments: PaypalPayment;
|
|
37
|
+
stripe_payments: StripePayment & {
|
|
38
|
+
options?: {
|
|
39
|
+
card: Card;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
wire_transfers: WireTransfer;
|
|
43
|
+
checkout_com_payments: CheckoutComPayment & {
|
|
44
|
+
payment_response: {
|
|
45
|
+
source?: Pick<Card, 'last4'> & {
|
|
46
|
+
scheme: string;
|
|
47
|
+
expiry_year: number;
|
|
48
|
+
expiry_month: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
klarna_payments: KlarnaPayment;
|
|
53
|
+
};
|
|
12
54
|
export declare type PaymentMethodActionType = 'setErrors' | 'setPaymentMethods' | 'setPaymentMethodConfig' | 'setPaymentSource' | 'setPaymentRef' | 'setLoading';
|
|
13
55
|
export declare type PaymentRef = MutableRefObject<null | HTMLFormElement>;
|
|
14
56
|
export interface PaymentMethodActionPayload {
|
|
@@ -45,9 +87,9 @@ declare type GetPaymentMethods = (args: {
|
|
|
45
87
|
dispatch: Dispatch<PaymentMethodAction>;
|
|
46
88
|
}) => Promise<void>;
|
|
47
89
|
export declare const getPaymentMethods: GetPaymentMethods;
|
|
48
|
-
export declare type PaymentResource =
|
|
49
|
-
export declare type PaymentResourceKey = 'braintreePayment' | 'stripePayment' | 'wireTransfer' | 'paypalPayment' | 'adyenPayment';
|
|
50
|
-
export declare type SDKPaymentResource = 'AdyenPayment' | 'BraintreePayment' | 'ExternalPayment' | 'PaypalPayment' | 'StripePayment' | 'WireTransfer';
|
|
90
|
+
export declare type PaymentResource = keyof PaymentSourceObject;
|
|
91
|
+
export declare type PaymentResourceKey = 'braintreePayment' | 'stripePayment' | 'klarnaPayment' | 'wireTransfer' | 'paypalPayment' | 'adyenPayment' | 'checkoutComPayment';
|
|
92
|
+
export declare type SDKPaymentResource = 'AdyenPayment' | 'BraintreePayment' | 'ExternalPayment' | 'PaypalPayment' | 'StripePayment' | 'WireTransfer' | 'CheckoutComPayment';
|
|
51
93
|
export declare type SetPaymentMethod = (args: {
|
|
52
94
|
config?: CommerceLayerConfig;
|
|
53
95
|
dispatch?: Dispatch<PaymentMethodAction>;
|
|
@@ -69,7 +111,7 @@ export declare type SetPaymentSource = (args: {
|
|
|
69
111
|
config?: CommerceLayerConfig;
|
|
70
112
|
dispatch?: Dispatch<PaymentMethodAction>;
|
|
71
113
|
getOrder?: getOrderContext;
|
|
72
|
-
attributes?: Record<string,
|
|
114
|
+
attributes?: Record<string, unknown>;
|
|
73
115
|
order?: Order;
|
|
74
116
|
paymentResource: PaymentResource;
|
|
75
117
|
paymentSourceId?: string;
|
|
@@ -89,6 +131,8 @@ export declare type DestroyPaymentSource = (args: {
|
|
|
89
131
|
paymentSourceId: string;
|
|
90
132
|
paymentResource: PaymentResource;
|
|
91
133
|
dispatch?: Dispatch<PaymentMethodAction>;
|
|
134
|
+
updateOrder?: typeof updateOrder;
|
|
135
|
+
orderId?: string;
|
|
92
136
|
}) => Promise<void>;
|
|
93
137
|
export declare const destroyPaymentSource: DestroyPaymentSource;
|
|
94
138
|
export declare type PaymentMethodConfig = {
|
|
@@ -97,6 +141,8 @@ export declare type PaymentMethodConfig = {
|
|
|
97
141
|
wireTransfer?: Partial<WireTransferConfig>;
|
|
98
142
|
paypalPayment?: PaypalConfig;
|
|
99
143
|
adyenPayment?: AdyenPaymentConfig;
|
|
144
|
+
checkoutComPayment?: CheckoutComConfig;
|
|
145
|
+
klarnaPayment?: Pick<AdyenPaymentConfig, 'placeOrderCallback'> & Pick<StripeConfig, 'containerClassName'>;
|
|
100
146
|
};
|
|
101
147
|
declare type SetPaymentMethodConfig = (config: PaymentMethodConfig, dispatch: Dispatch<PaymentMethodAction>) => void;
|
|
102
148
|
export declare const setPaymentMethodConfig: SetPaymentMethodConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";import has from"lodash/has";import isEmpty from"lodash/isEmpty";export function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}export const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})},paymentMethodInitialState={errors:[]},setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},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
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getErrors,{setErrors}from"../utils/getErrors";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";import has from"lodash/has";import isEmpty from"lodash/isEmpty";export function setLoading({loading,dispatch}){dispatch&&dispatch({type:"setLoading",payload:{loading}})}export const setPaymentRef=({ref,dispatch})=>{ref&&dispatch&&dispatch({type:"setPaymentRef",payload:{currentPaymentMethodRef:ref}})},paymentMethodInitialState={errors:[]},setPaymentMethodErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},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}})},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:getSdk(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=getErrors(error,"orders",paymentResource);console.error("Set payment method",errors)}},setPaymentSource=async({config,dispatch,getOrder,attributes={},order,paymentResource,customerPaymentSourceId,paymentSourceId,updateOrder,errors:currentErrors})=>{try{if(config&&order){let paymentSource;const sdk=getSdk(config);if(customerPaymentSourceId)updateOrder&&await updateOrder({id:order.id,attributes:{_customer_payment_source_id:customerPaymentSourceId}});else{if(paymentSourceId){const attrs={id:paymentSourceId,...attributes};paymentSource=await sdk[paymentResource].update(attrs)}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=getErrors(error,"payment_methods",paymentResource);console.error("Set payment source:",errors),dispatch&&setErrors({currentErrors,newErrors:errors,dispatch})}},updatePaymentSource=async({id,attributes,config,dispatch,paymentResource})=>{if(config)try{const paymentSource=await getSdk(config)[paymentResource].update({id,...attributes});dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource}})}catch(err){console.error("Update payment source:",err)}},destroyPaymentSource=async({paymentSourceId,paymentResource,dispatch})=>{paymentSourceId&&paymentResource&&dispatch&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},setPaymentMethodConfig=(config,dispatch)=>{dispatch({type:"setPaymentMethodConfig",payload:{config}})};export function getPaymentConfig(paymentResource,config){const resource=camelCase(paymentResource).replace("Payments","Payment").replace("Transfers","Transfer");return!isEmpty(config)&&has(config,resource)?config[resource]:void 0}const type=["setErrors","setPaymentMethodConfig","setPaymentMethods","setPaymentSource","setPaymentRef","setLoading"],paymentMethodReducer=(state,reducer)=>baseReducer(state,reducer,type);export default paymentMethodReducer;
|
|
@@ -11,6 +11,9 @@ export declare type PlaceOrderOptions = {
|
|
|
11
11
|
MD: string;
|
|
12
12
|
PaRes: string;
|
|
13
13
|
};
|
|
14
|
+
checkoutCom?: {
|
|
15
|
+
session_id: string;
|
|
16
|
+
};
|
|
14
17
|
};
|
|
15
18
|
export interface PlaceOrderActionPayload {
|
|
16
19
|
errors: BaseError[];
|
|
@@ -42,8 +45,12 @@ export declare type SetPlaceOrder = (args: {
|
|
|
42
45
|
config?: CommerceLayerConfig;
|
|
43
46
|
order?: Order;
|
|
44
47
|
state?: PlaceOrderState;
|
|
45
|
-
setOrderErrors?: (
|
|
46
|
-
paymentSource?:
|
|
48
|
+
setOrderErrors?: (errors: BaseError[]) => void;
|
|
49
|
+
paymentSource?: PaymentSourceType & {
|
|
50
|
+
approval_url?: string;
|
|
51
|
+
};
|
|
52
|
+
include?: string[];
|
|
53
|
+
setOrder?: (order: Order) => void;
|
|
47
54
|
}) => Promise<{
|
|
48
55
|
placed: boolean;
|
|
49
56
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import{shipmentsFilled}from"../utils/shipments";import{saveBillingAddress,saveShippingAddress,saveToWallet}from"../utils/customerOrderOptions";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const placeOrderInitialState={errors:[],isPermitted:!1},setPlaceOrderErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},placeOrderPermitted=async({config,order,dispatch,options})=>{
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import isEmpty from"lodash/isEmpty";import{isDoNotShip,shipmentsFilled}from"../utils/shipments";import{saveBillingAddress,saveShippingAddress,saveToWallet}from"../utils/customerOrderOptions";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const placeOrderInitialState={errors:[],isPermitted:!1},setPlaceOrderErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},placeOrderPermitted=async({config,order,dispatch,options})=>{if(order&&config){let isPermitted=!0;order.privacy_url&&order.terms_url&&(isPermitted=localStorage.getItem("privacy-terms")==="true");const billingAddress=order.billing_address,shippingAddress=order.shipping_address,doNotShip=isDoNotShip(order.line_items),shipments=order.shipments,shipment=shipments&&shipmentsFilled(shipments),paymentMethod=order.payment_method,paymentSource=order.payment_source;order.total_amount_with_taxes_cents!==0&&isEmpty(paymentMethod?.id)&&(isPermitted=!1),isEmpty(billingAddress)&&(isPermitted=!1),isEmpty(shippingAddress)&&!doNotShip&&(isPermitted=!1),!isEmpty(shipments)&&!shipment&&(isPermitted=!1),paymentSource?.mismatched_amounts&&(isPermitted=!1),dispatch({type:"setPlaceOrderPermitted",payload:{isPermitted,paymentType:paymentMethod?.payment_source_type,paymentSecret:paymentSource?.client_secret,paymentId:paymentSource?.options?.id,paymentSource,options}})}},setPlaceOrder=async({state,order,config,setOrderErrors,paymentSource,setOrder,include})=>{const response={placed:!1};if(state&&config&&order){const sdk=getSdk(config),{options,paymentType}=state;try{if(paymentType==="paypal_payments"&&paymentSource){if(!options?.paypalPayerId&&paymentSource?.approval_url)return window.location.href=paymentSource?.approval_url,response;await sdk[paymentType].update({id:paymentSource.id,paypal_payer_id:options?.paypalPayerId})}if(paymentType==="checkout_com_payments"&&paymentSource&&options?.checkoutCom?.session_id){const payment=await sdk[paymentType].update({id:paymentSource.id,_details:!0,session_id:options?.checkoutCom?.session_id});if(payment?.payment_response?.status!=="Authorized"){const[action]=payment?.payment_response?.actions||[""];throw{errors:[{code:"PAYMENT_NOT_APPROVED_FOR_EXECUTION",message:action?.response_summary,resource:"orders",field:"checkout_com_payments"}]}}}const updateAttributes={id:order.id,_place:!0};switch(saveBillingAddress()&&await sdk.orders.update({id:order.id,_save_billing_address_to_customer_address_book:!0}),saveShippingAddress()&&await sdk.orders.update({id:order.id,_save_shipping_address_to_customer_address_book:!0}),paymentType){case"braintree_payments":{saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0});const orderUpdated=await sdk.orders.update(updateAttributes,{include});return setOrder&&setOrder(orderUpdated),setOrderErrors&&setOrderErrors([]),{placed:!0}}default:{const orderUpdated=await sdk.orders.update(updateAttributes,{include});return setOrder&&setOrder(orderUpdated),saveToWallet()&&await sdk.orders.update({id:order.id,_save_payment_source_to_customer_wallet:!0}),setOrderErrors&&setOrderErrors([]),{placed:!0}}}}catch(error){const errors=getErrors(error,"orders",paymentType);return setOrderErrors&&setOrderErrors(errors),{...response,errors}}}return response};const type=["setErrors","setPlaceOrderPermitted"],placeOrderReducer=(state,reducer)=>baseReducer(state,reducer,type);export default placeOrderReducer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import getPrices from"../utils/getPrices";import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]},getSkusPrice=(skuCodes,{config,dispatch,setPrices,prices,perPage,filters})=>{let allPrices={};const sdk=getSdk(config);sdk.prices.list({filters:
|
|
1
|
+
import getPrices from"../utils/getPrices";import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const priceInitialState={loading:!0,prices:{},skuCodes:[],errors:[]},getSkusPrice=(skuCodes,{config,dispatch,setPrices,prices,perPage,filters})=>{let allPrices={};const sdk=getSdk(config);sdk.prices.list({filters:{sku_code_in:skuCodes.join(","),...filters},pageSize:perPage}).then(async response=>{const pricesObj=getPrices(response);allPrices={...allPrices,...prices,...pricesObj},setPrices&&setPrices(allPrices),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=getPrices(pageResponse);allPrices={...allPrices,...pricesObj2},setPrices&&setPrices(allPrices),dispatch({type:"setPrices",payload:{prices:allPrices}})}}).catch(error=>{const errors=getErrors(error,"prices");dispatch({type:"setErrors",payload:{errors}})})},unsetPriceState=dispatch=>{dispatch({type:"setPrices",payload:{prices:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})};const typeAction=["setLoading","setPrices","setSkuCodes","setErrors"],priceReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default priceReducer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]},setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getShipments=async({order,dispatch,config})=>{try{const sdk=getSdk(config),shipments=order.shipments,deliveryLeadTimes=await sdk.delivery_lead_times.list({include:["shipping_method","stock_location"]});dispatch({type:"setShipments",payload:{shipments,deliveryLeadTimes}})}catch(error){console.error(error)}},setShippingMethod=async({config,shipmentId,shippingMethodId,getOrder,order})=>{try{if(shippingMethodId){const sdk=getSdk(config);await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(shippingMethodId)}),getOrder&&order&&getOrder(order.id)}}catch(error){console.error(error)}};const type=["setErrors","setShipments","setShippingMethod"],shipmentReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shipmentReducer;
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]},setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getShipments=async({order,dispatch,config})=>{try{const sdk=getSdk(config),shipments=order.shipments,deliveryLeadTimes=await sdk.delivery_lead_times.list({include:["shipping_method","stock_location"]});dispatch({type:"setShipments",payload:{shipments,deliveryLeadTimes}})}catch(error){console.error(error)}},setShippingMethod=async({config,shipmentId,shippingMethodId,getOrder,order})=>{try{if(shippingMethodId){const sdk=getSdk(config);await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(shippingMethodId)}),getOrder&&order&&await getOrder(order.id)}}catch(error){console.error(error)}};const type=["setErrors","setShipments","setShippingMethod"],shipmentReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shipmentReducer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shippingAddressInitialState={_shipping_address_clone_id:""},setShippingAddress=async(id,options)=>{try{if(options
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shippingAddressInitialState={_shipping_address_clone_id:""},setShippingAddress=async(id,options)=>{try{if(options?.order){if(options.customerAddressId){const sdk=getSdk(options.config),attributes={id,reference:options.customerAddressId};await sdk.addresses.update(attributes)}options.dispatch({type:"setShippingAddress",payload:{_shipping_address_clone_id:id}})}}catch(error){console.error(error)}},setShippingCustomerAddressId=async({dispatch,order,setCloneAddress})=>{const customerAddressId=order?.shipping_address?.reference;try{customerAddressId&&(dispatch({type:"setShippingCustomerAddressId",payload:{shippingCustomerAddressId:customerAddressId}}),setCloneAddress(customerAddressId,"shipping_address"))}catch(error){console.error("error",error)}};const type=["setShippingAddress","setShippingCustomerAddressId","cleanup"],shippingAddressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shippingAddressReducer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
2
|
+
import { BaseAction } from '../typings/index';
|
|
3
|
+
import { QueryParamsList, Sku } from '@commercelayer/sdk';
|
|
4
|
+
import { Dispatch } from 'react';
|
|
5
|
+
declare type SkuActionType = 'getSkus' | 'setLoading';
|
|
6
|
+
declare type SkuAction = BaseAction<SkuActionType, SkuState>;
|
|
7
|
+
export declare type SkuState = Partial<{
|
|
8
|
+
skus: Sku[];
|
|
9
|
+
loading: boolean;
|
|
10
|
+
skuCodes: string[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare const skuInitialState: SkuState;
|
|
13
|
+
declare type GetSku = {
|
|
14
|
+
config: CommerceLayerConfig;
|
|
15
|
+
skus: string[];
|
|
16
|
+
dispatch: Dispatch<SkuAction>;
|
|
17
|
+
queryParams?: QueryParamsList;
|
|
18
|
+
};
|
|
19
|
+
export declare function getSku<T extends GetSku>({ config, skus, dispatch, queryParams, }: T): Promise<void>;
|
|
20
|
+
export default function skuReducer(state: SkuState, reducer: SkuAction): SkuState;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";const actionType=["getSkus"];export const skuInitialState={skus:[],loading:!0,skuCodes:[]};export async function getSku({config,skus,dispatch,queryParams}){if(!config.accessToken||skus.length===0)return;const sdk=getSdk(config);let allSkus=[];const get=await sdk.skus.list({...queryParams,filters:{...queryParams?.filters,code_in:skus.join(",")}});allSkus=[...get];const meta=get.meta;if(meta.pageCount>1)for(let pageNumber=meta.currentPage+1;pageNumber<=meta.pageCount;pageNumber++){const getPage=await sdk.skus.list({...queryParams,filters:{...queryParams?.filters,code_in:skus.join(",")},pageNumber});allSkus=[...allSkus,...getPage]}dispatch({type:"getSkus",payload:{skus:allSkus,loading:!1,skuCodes:skus}})}export default function skuReducer(state,reducer){return baseReducer(state,reducer,actionType)}
|
|
@@ -10,6 +10,7 @@ declare type SetSkuCodeVariantParams = {
|
|
|
10
10
|
config: CommerceLayerConfig;
|
|
11
11
|
dispatch: Dispatch<VariantAction>;
|
|
12
12
|
setItem: ((item: Items) => void) | undefined;
|
|
13
|
+
setItemSkuCode?: ((skuCode: string) => void) | undefined;
|
|
13
14
|
};
|
|
14
15
|
export interface SetSkuCodeVariant {
|
|
15
16
|
(params: SetSkuCodeVariantParams): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import baseReducer from"../utils/baseReducer";import getSkus from"../utils/getSkus";import{isEmpty,has}from"lodash";import getSdk from"../utils/getSdk";export const setVariantSkuCodes=({skuCodes,dispatch,setCustomLineItems})=>{const lineItems={},sCodes=skuCodes.map(s=>(has(s,"lineItem")&&(lineItems[s.code]=s.lineItem),s.code));isEmpty(lineItems)||setCustomLineItems&&setCustomLineItems(lineItems),dispatch({type:"setSkuCodes",payload:{skuCodes:sCodes}})},setSkuCode=params=>{const{id,code,config,setItem,dispatch}=params;id&&getSdk(config).skus.retrieve(id,{include:["sku_options"]}).then(sku=>{setItem&&setItem({[`${code}`]:sku})}).catch(errors=>{dispatch({type:"setErrors",payload:{errors}})})},getVariants=params=>{const{config,state,skuCode,dispatch,setItem,filters}=params;getSdk(config).skus.list({filters:
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getSkus from"../utils/getSkus";import{isEmpty,has}from"lodash";import getSdk from"../utils/getSdk";export const setVariantSkuCodes=({skuCodes,dispatch,setCustomLineItems})=>{const lineItems={},sCodes=skuCodes.map(s=>(has(s,"lineItem")&&(lineItems[s.code]=s.lineItem),s.code));isEmpty(lineItems)||setCustomLineItems&&setCustomLineItems(lineItems),dispatch({type:"setSkuCodes",payload:{skuCodes:sCodes}})},setSkuCode=params=>{const{id,code,config,setItem,dispatch,setItemSkuCode}=params;id&&getSdk(config).skus.retrieve(id,{include:["sku_options"]}).then(sku=>{setItem&&setItem({[`${code}`]:sku}),setItemSkuCode&&setItemSkuCode(code)}).catch(errors=>{dispatch({type:"setErrors",payload:{errors}})})},getVariants=params=>{const{config,state,skuCode,dispatch,setItem,filters}=params;getSdk(config).skus.list({filters:{code_in:state.skuCodes.join(","),...filters}}).then(skus=>{const skusObj=getSkus(skus,state.skuCodes);skuCode&&setSkuCode({code:skusObj[skuCode].code,id:skusObj[skuCode].id,config,dispatch,setItem}),dispatch({type:"setVariants",payload:{variants:skusObj}}),dispatch({type:"setLoading",payload:{loading:!1}})}).catch(errors=>{dispatch({type:"setErrors",payload:{errors}})})},unsetVariantState=dispatch=>{dispatch({type:"setSkuCode",payload:{skuCode:""}}),dispatch({type:"setVariants",payload:{variants:{}}}),dispatch({type:"setLoading",payload:{loading:!1}})},variantInitialState={loading:!1,variants:{},skuCodes:[],skuCode:"",errors:[],currentSkuId:"",currentSkuInventory:{available:!1,quantity:0,levels:[]},currentQuantity:1,currentPrices:[]};const actionType=["setLoading","setVariants","setSkuCodes","setSkuCode","setCurrentSkuId","setCurrentSkuInventory","setCurrentPrices","setErrors"],variantReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default variantReducer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import { FunctionChildren } from './index';
|
|
3
|
-
export declare type CodeErrorType = 'EMPTY_ERROR' | 'FILTER_NOT_ALLOWED' | 'FORBIDDEN' | 'INTERNAL_SERVER_ERROR' | 'INVALID_DATA_FORMAT' | 'INVALID_FIELD' | 'INVALID_FIELD_FORMAT' | 'INVALID_FIELD_VALUE' | 'INVALID_FILTERS_SYNTAX' | 'INVALID_FILTER_VALUE' | 'INVALID_INCLUDE' | 'INVALID_LINKS_OBJECT' | 'INVALID_PAGE_OBJECT' | 'INVALID_PAGE_VALUE' | 'INVALID_RESOURCE' | 'INVALID_RESOURCE_ID' | 'INVALID_SORT_CRITERIA' | 'INVALID_TOKEN' | 'KEY_NOT_INCLUDED_IN_URL' | 'KEY_ORDER_MISMATCH' | 'LOCKED' | 'NOT_ACCEPTABLE' | 'PARAM_MISSING' | 'PARAM_NOT_ALLOWED' | 'PAYMENT_NOT_APPROVED_FOR_EXECUTION' | 'PAYMENT_INTENT_AUTHENTICATION_FAILURE' | 'RECORD_NOT_FOUND' | 'RECORD_NOT_FOUND' | 'RELATION_EXISTS' | 'SAVE_FAILED' | 'TYPE_MISMATCH' | 'UNAUTHORIZED' | 'UNSUPPORTED_MEDIA_TYPE' | 'VALIDATION_ERROR';
|
|
4
|
-
export declare type ResourceErrorType = 'addresses' | 'billing_address' | 'gift_cards' | 'gift_card_or_coupon_code' | 'line_items' | 'orders' | 'payment_methods' | 'prices' | 'shipping_address' | 'sku_options' | 'variant';
|
|
3
|
+
export declare type CodeErrorType = 'EMPTY_ERROR' | 'FILTER_NOT_ALLOWED' | 'FORBIDDEN' | 'INTERNAL_SERVER_ERROR' | 'INVALID_DATA_FORMAT' | 'INVALID_FIELD' | 'INVALID_FIELD_FORMAT' | 'INVALID_FIELD_VALUE' | 'INVALID_FILTERS_SYNTAX' | 'INVALID_FILTER_VALUE' | 'INVALID_INCLUDE' | 'INVALID_LINKS_OBJECT' | 'INVALID_PAGE_OBJECT' | 'INVALID_PAGE_VALUE' | 'INVALID_RESOURCE' | 'INVALID_RESOURCE_ID' | 'INVALID_SORT_CRITERIA' | 'INVALID_TOKEN' | 'KEY_NOT_INCLUDED_IN_URL' | 'KEY_ORDER_MISMATCH' | 'LOCKED' | 'NOT_ACCEPTABLE' | 'OUT_OF_STOCK' | 'PARAM_MISSING' | 'PARAM_NOT_ALLOWED' | 'PAYMENT_NOT_APPROVED_FOR_EXECUTION' | 'PAYMENT_INTENT_AUTHENTICATION_FAILURE' | 'RECORD_NOT_FOUND' | 'RECORD_NOT_FOUND' | 'RELATION_EXISTS' | 'NO_SHIPPING_METHODS' | 'SAVE_FAILED' | 'TYPE_MISMATCH' | 'UNAUTHORIZED' | 'UNSUPPORTED_MEDIA_TYPE' | 'VALIDATION_ERROR';
|
|
4
|
+
export declare type ResourceErrorType = 'addresses' | 'billing_address' | 'gift_cards' | 'gift_card_or_coupon_code' | 'line_items' | 'orders' | 'payment_methods' | 'prices' | 'shipments' | 'shipping_address' | 'customer_address' | 'sku_options' | 'variant';
|
|
5
5
|
export interface BaseError {
|
|
6
6
|
code: CodeErrorType;
|
|
7
7
|
message: string;
|
|
@@ -27,10 +27,19 @@ export declare const ErrorPropTypes: {
|
|
|
27
27
|
declare type ErrorChildrenComponentProps = FunctionChildren<Omit<ErrorComponentProps, 'children'> & {
|
|
28
28
|
errors: string[];
|
|
29
29
|
}>;
|
|
30
|
-
export
|
|
30
|
+
export declare type ErrorComponentProps = {
|
|
31
|
+
/**
|
|
32
|
+
* Resource which caused the error
|
|
33
|
+
*/
|
|
31
34
|
resource: ResourceErrorType;
|
|
32
35
|
children?: ErrorChildrenComponentProps;
|
|
36
|
+
/**
|
|
37
|
+
* Field which caused the error
|
|
38
|
+
*/
|
|
33
39
|
field?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Error message which you can translate
|
|
42
|
+
*/
|
|
34
43
|
messages?: {
|
|
35
44
|
code: CodeErrorType;
|
|
36
45
|
message: string;
|
|
@@ -38,5 +47,5 @@ export interface ErrorComponentProps {
|
|
|
38
47
|
field?: string;
|
|
39
48
|
id?: string;
|
|
40
49
|
}[];
|
|
41
|
-
}
|
|
50
|
+
};
|
|
42
51
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import PropTypes from"prop-types";const CEType=["EMPTY_ERROR","FILTER_NOT_ALLOWED","FORBIDDEN","INTERNAL_SERVER_ERROR","INVALID_DATA_FORMAT","INVALID_FIELD","INVALID_FIELD_FORMAT","INVALID_FIELD_VALUE","INVALID_FILTERS_SYNTAX","INVALID_FILTER_VALUE","INVALID_INCLUDE","INVALID_LINKS_OBJECT","INVALID_PAGE_OBJECT","INVALID_PAGE_VALUE","INVALID_RESOURCE","INVALID_RESOURCE_ID","INVALID_SORT_CRITERIA","INVALID_TOKEN","KEY_NOT_INCLUDED_IN_URL","KEY_ORDER_MISMATCH","LOCKED","NOT_ACCEPTABLE","PARAM_MISSING","PARAM_NOT_ALLOWED","RECORD_NOT_FOUND","RECORD_NOT_FOUND","RELATION_EXISTS","SAVE_FAILED","TYPE_MISMATCH","UNAUTHORIZED","UNSUPPORTED_MEDIA_TYPE","VALIDATION_ERROR"];export const REType=["gift_cards","line_items","orders","prices","sku_options","variant"],BaseErrorObject=PropTypes.shape({code:PropTypes.oneOf(CEType).isRequired,message:PropTypes.string.isRequired,resource:PropTypes.oneOf(REType),field:PropTypes.string,id:PropTypes.string}),ErrorPropTypes={resource:PropTypes.oneOf(["billing_address","gift_cards","line_items","orders","payment_methods","prices","shipping_address","sku_options","variant"]).isRequired,children:PropTypes.func,field:PropTypes.string};
|
|
1
|
+
import PropTypes from"prop-types";const CEType=["EMPTY_ERROR","FILTER_NOT_ALLOWED","FORBIDDEN","INTERNAL_SERVER_ERROR","INVALID_DATA_FORMAT","INVALID_FIELD","INVALID_FIELD_FORMAT","INVALID_FIELD_VALUE","INVALID_FILTERS_SYNTAX","INVALID_FILTER_VALUE","INVALID_INCLUDE","INVALID_LINKS_OBJECT","INVALID_PAGE_OBJECT","INVALID_PAGE_VALUE","INVALID_RESOURCE","INVALID_RESOURCE_ID","INVALID_SORT_CRITERIA","INVALID_TOKEN","KEY_NOT_INCLUDED_IN_URL","KEY_ORDER_MISMATCH","LOCKED","NOT_ACCEPTABLE","PARAM_MISSING","PARAM_NOT_ALLOWED","RECORD_NOT_FOUND","RECORD_NOT_FOUND","RELATION_EXISTS","SAVE_FAILED","TYPE_MISMATCH","UNAUTHORIZED","UNSUPPORTED_MEDIA_TYPE","VALIDATION_ERROR"];export const REType=["gift_cards","line_items","orders","prices","sku_options","variant"],BaseErrorObject=PropTypes.shape({code:PropTypes.oneOf(CEType).isRequired,message:PropTypes.string.isRequired,resource:PropTypes.oneOf(REType),field:PropTypes.string,id:PropTypes.string}),ErrorPropTypes={resource:PropTypes.oneOf(["billing_address","gift_cards","line_items","orders","payment_methods","prices","shipping_address","customer_address","sku_options","variant","shipments"]).isRequired,children:PropTypes.func,field:PropTypes.string};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, ReactNode,
|
|
1
|
+
import { Dispatch, ForwardedRef, ReactNode, Ref } from 'react';
|
|
2
2
|
import PropTypes, { InferProps } from 'prop-types';
|
|
3
3
|
import { BaseError } from './errors';
|
|
4
4
|
export declare const BC: {
|
|
@@ -37,6 +37,7 @@ export interface BaseSelectComponentProps {
|
|
|
37
37
|
className?: string;
|
|
38
38
|
required?: boolean;
|
|
39
39
|
name: string;
|
|
40
|
+
onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
40
41
|
}
|
|
41
42
|
export declare const BaseInputComponentPropTypes: {
|
|
42
43
|
children: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -47,9 +48,10 @@ export declare const BaseInputComponentPropTypes: {
|
|
|
47
48
|
};
|
|
48
49
|
declare type BaseInputChildrenComponentProps = Omit<BaseInputComponentProps, 'children'> & {
|
|
49
50
|
handleChange: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
51
|
+
parentRef: ForwardedRef<any>;
|
|
50
52
|
};
|
|
51
53
|
export interface BaseInputComponentProps {
|
|
52
|
-
ref?:
|
|
54
|
+
ref?: Ref<any>;
|
|
53
55
|
children?: (props: BaseInputChildrenComponentProps) => ReactNode;
|
|
54
56
|
name: string;
|
|
55
57
|
onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
@@ -57,9 +59,9 @@ export interface BaseInputComponentProps {
|
|
|
57
59
|
}
|
|
58
60
|
export declare type LineItemType = 'gift_cards' | 'payment_methods' | 'promotions' | 'shipments' | 'skus' | 'bundles' | 'adjustments';
|
|
59
61
|
export declare type GiftCardInputName = 'balanceCents' | 'balanceMaxCents' | 'singleUse' | 'rechargeable' | 'imageUrl' | 'expiresAt' | 'referenceOrigin' | 'email' | 'firstName' | 'lastName' | 'reference';
|
|
60
|
-
export declare type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
|
|
61
|
-
export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code';
|
|
62
|
-
export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code';
|
|
62
|
+
export declare type AddressInputName = 'billing_address_city' | 'billing_address_company' | 'billing_address_first_name' | 'billing_address_email' | 'billing_address_last_name' | 'billing_address_line_1' | 'billing_address_line_2' | 'billing_address_phone' | 'billing_address_state_code' | 'billing_address_zip_code' | 'billing_address_billing_info' | 'billing_address_save_to_customer_book' | 'customer_address_city' | 'customer_address_company' | 'customer_address_first_name' | 'customer_address_email' | 'customer_address_last_name' | 'customer_address_line_1' | 'customer_address_line_2' | 'customer_address_phone' | 'customer_address_state_code' | 'customer_address_zip_code' | 'customer_address_billing_info' | 'shipping_address_city' | 'shipping_address_company' | 'shipping_address_email' | 'shipping_address_first_name' | 'shipping_address_last_name' | 'shipping_address_line_1' | 'shipping_address_line_2' | 'shipping_address_phone' | 'shipping_address_state_code' | 'shipping_address_zip_code' | 'shipping_address_save_to_customer_book';
|
|
63
|
+
export declare type AddressCountrySelectName = 'billing_address_country_code' | 'shipping_address_country_code' | 'customer_address_country_code';
|
|
64
|
+
export declare type AddressStateSelectName = 'billing_address_state_code' | 'shipping_address_state_code' | 'customer_address_state_code';
|
|
63
65
|
export declare type BaseInputType = 'checkbox' | 'date' | 'email' | 'number' | 'tel' | 'text' | 'textarea';
|
|
64
66
|
export declare type LoaderType = string | ReactNode;
|
|
65
67
|
export declare const BMObject: PropTypes.Requireable<{
|
|
@@ -70,9 +72,9 @@ export declare type BaseMetadataObject = {
|
|
|
70
72
|
};
|
|
71
73
|
export declare type TimeFormat = 'days' | 'hours';
|
|
72
74
|
export declare type BaseComponent = InferProps<typeof BC>;
|
|
73
|
-
export interface BaseAction<A = string
|
|
75
|
+
export interface BaseAction<A = string, P = Record<string, any>> {
|
|
74
76
|
type: A;
|
|
75
|
-
payload:
|
|
77
|
+
payload: P;
|
|
76
78
|
}
|
|
77
79
|
export interface BaseState {
|
|
78
80
|
[key: string]: any;
|
|
@@ -123,4 +125,13 @@ export declare type BaseAmountComponent = {
|
|
|
123
125
|
export interface FunctionChildren<P = Record<string, any>> {
|
|
124
126
|
(props: P): ReactNode;
|
|
125
127
|
}
|
|
128
|
+
export declare type ExcludeTag<T extends keyof JSX.IntrinsicElements> = Exclude<keyof JSX.IntrinsicElements, T>;
|
|
129
|
+
export declare type ExtractTag<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements, T>;
|
|
130
|
+
export declare type ConditionalElement<E> = ({
|
|
131
|
+
attribute: Extract<keyof E, 'image_url'>;
|
|
132
|
+
tagElement: ExtractTag<'img'>;
|
|
133
|
+
} & JSX.IntrinsicElements['img']) | ({
|
|
134
|
+
attribute: Exclude<keyof E, 'image_url'>;
|
|
135
|
+
tagElement: ExcludeTag<'img'>;
|
|
136
|
+
} & JSX.IntrinsicElements[ExcludeTag<'img'>]);
|
|
126
137
|
export {};
|
package/lib/esm/typings/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string},PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]),BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired},BaseInputComponentPropTypes={children:PropTypes.func,name:PropTypes.string.isRequired,type:PropTypes.oneOf(["text","email","number","date","checkbox","textarea"]).isRequired,onChange:PropTypes.func,placeholder:PropTypes.string},BMObject=PropTypes.objectOf(PropTypes.string),baseOrderPricePropTypes=
|
|
1
|
+
import PropTypes from"prop-types";export const BC={id:PropTypes.string,className:PropTypes.string,style:PropTypes.object,name:PropTypes.string},PTLoader=PropTypes.oneOfType([PropTypes.element,PropTypes.string]),BaseSelectComponentPropTypes={children:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired,selected:PropTypes.bool}).isRequired).isRequired,placeholder:PropTypes.shape({label:PropTypes.string.isRequired,value:PropTypes.oneOfType([PropTypes.string,PropTypes.number]).isRequired}),value:PropTypes.string,name:PropTypes.string.isRequired},BaseInputComponentPropTypes={children:PropTypes.func,name:PropTypes.string.isRequired,type:PropTypes.oneOf(["text","email","number","date","checkbox","textarea"]).isRequired,onChange:PropTypes.func,placeholder:PropTypes.string},BMObject=PropTypes.objectOf(PropTypes.string),baseOrderPricePropTypes={base:PropTypes.string.isRequired,type:PropTypes.string.isRequired,children:PropTypes.func,format:PropTypes.oneOf(["formatted","cents","float"]),...BC},baseOrderComponentPricePropTypes={children:baseOrderPricePropTypes.children,format:baseOrderPricePropTypes.format,...BC};
|
|
@@ -8,7 +8,7 @@ declare type BillingAddressController = (params: {
|
|
|
8
8
|
}) => boolean;
|
|
9
9
|
export declare const billingAddressController: BillingAddressController;
|
|
10
10
|
declare type ShippingAddressController = (params: {
|
|
11
|
-
billingDisable
|
|
11
|
+
billingDisable?: boolean;
|
|
12
12
|
errors?: BaseError[];
|
|
13
13
|
shipToDifferentAddress?: boolean;
|
|
14
14
|
shipping_address?: AddressCreate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isEmpty}from"lodash";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address,billingAddressId,errors,requiresBillingInfo})=>{let billingDisable=!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address)){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),billingDisable=!!(billing_address&&fieldsExist(billing_address,billingInfo))}return billingDisable&&!isEmpty(billingAddressId)&&isEmpty(billing_address)&&(billingDisable=!1),billingDisable},shippingAddressController=({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId})=>{let shippingDisable=!!(!billingDisable&&shipToDifferentAddress);return shippingDisable&&isEmpty(errors)&&!isEmpty(shipping_address)&&(shippingDisable=!!(shipping_address&&fieldsExist(shipping_address))),shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable},countryLockController=({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId})=>{if(countryCodeLock&&!isEmpty(addresses)&&billingAddressId&&!shipToDifferentAddress){const addressLocked=addresses
|
|
1
|
+
import{isEmpty}from"lodash";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export const billingAddressController=({billing_address,billingAddressId,errors,requiresBillingInfo=!1})=>{let billingDisable=!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address)){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),billingDisable=!!(billing_address&&fieldsExist(billing_address,billingInfo))}return billingDisable&&!isEmpty(billingAddressId)&&isEmpty(billing_address)&&(billingDisable=!1),billingDisable},shippingAddressController=({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId})=>{let shippingDisable=!!(!billingDisable&&shipToDifferentAddress);return shippingDisable&&isEmpty(errors)&&!isEmpty(shipping_address)&&(shippingDisable=!!(shipping_address&&fieldsExist(shipping_address))),shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable},countryLockController=({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId})=>{if(countryCodeLock&&!isEmpty(addresses)&&billingAddressId&&!shipToDifferentAddress){const addressLocked=addresses?.find(a=>(a?.id===billingAddressId||a?.reference===billingAddressId)&&a?.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}if(countryCodeLock&&!isEmpty(billing_address)&&!shipToDifferentAddress)return billing_address?.country_code!==countryCodeLock;if(countryCodeLock&&!isEmpty(shipping_address)&&shipToDifferentAddress)return shipping_address?.country_code!==countryCodeLock;if(countryCodeLock&&!isEmpty(addresses)&&shippingAddressId&&shipToDifferentAddress){const addressLocked=addresses?.find(a=>(a?.id===shippingAddressId||a?.reference===shippingAddressId)&&a?.country_code!==countryCodeLock);if(!isEmpty(addressLocked))return!0}return!1};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const baseReducer=(state,action,actionTypes)=>{if(actionTypes.indexOf(action.type)!==-1){const data=action.payload;state=
|
|
1
|
+
const baseReducer=(state,action,actionTypes)=>{if(actionTypes.indexOf(action.type)!==-1){const data=action.payload;state={...state,...data}}return state};export default baseReducer;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResourceIncluded } from '../reducers/OrderReducer';
|
|
2
|
+
import type { Order } from '@commercelayer/sdk';
|
|
3
|
+
declare type Params = {
|
|
4
|
+
order: Order;
|
|
5
|
+
resourceInclude: ResourceIncluded[];
|
|
6
|
+
};
|
|
7
|
+
export default function checkIncludeResources({ order, resourceInclude, }: Params): boolean;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function checkIncludeResources({order,resourceInclude}){const checkKeys=[];return resourceInclude.forEach(v=>{if(v.includes(".")){const[first]=v.split(".");order?.[first]===void 0&&checkKeys.push(!1)}else order?.[v]===void 0&&checkKeys.push(!1)}),checkKeys.length===0}
|
|
@@ -5,5 +5,5 @@ export interface CheckChildrenTypes {
|
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}, propName: string, componentName: string, location: string, propFullName: string): Error | null;
|
|
7
7
|
}
|
|
8
|
-
declare const _default: Requireable<ReactNode>;
|
|
8
|
+
declare const _default: Requireable<ReactNode | (() => ReactNode)>;
|
|
9
9
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isValidElement,Children}from"react";import{isEmpty,isFunction,has,get}from"lodash";import components from"../config/components";const checkChildrenTypes=(props,propName,componentName)=>{let error=null;const children=props[propName],cpName=componentName.replace("CL","");return(isEmpty(children)&&typeof children!="function"||typeof children=="function"&&!children)&&props.isRequired&&(error=new Error(`The prop '${propName}' is marked as required in '${cpName}', but its value is '${children}'.`)),Children.map(children,c=>{if(error)return error;const type=c
|
|
1
|
+
import{isValidElement,Children}from"react";import{isEmpty,isFunction,has,get}from"lodash";import components from"../config/components";const checkChildrenTypes=(props,propName,componentName)=>{let error=null;const children=props[propName],cpName=componentName.replace("CL","");return(isEmpty(children)&&typeof children!="function"||typeof children=="function"&&!children)&&props.isRequired&&(error=new Error(`The prop '${propName}' is marked as required in '${cpName}', but its value is '${children}'.`)),Children.map(children,c=>{if(error)return error;const type=c?.type,itemTypes=get(components,`${cpName}.permittedChildren`),errorMsg=`Invalid prop '${propName}' supplied to ${cpName}. Only components ${itemTypes.join(", ")} are allowed.`;if(isFunction(type)&&has(type,"displayName")){const displayName=get(type,"displayName"),childComponentName=type.name;displayName&&displayName===`${childComponentName}`&&(itemTypes.includes(childComponentName)||(error=new Error(errorMsg)))}!isValidElement(c)&&c!==null&&(error=new Error(errorMsg))}),error},childrenTypes=checkChildrenTypes;childrenTypes.isRequired=(props,propName,componentName,location,propFullName)=>checkChildrenTypes({...props,isRequired:!0},propName,componentName,location,propFullName);export default childrenTypes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function sortObj(obj){return Object.keys(obj).sort().reduce((result,key)=>(result[key]=obj[key],result),{})}export default function compareObjAttribute({attributes,object}){const returnObj={};return Object.keys(object).forEach(v=>{const element=attributes[v],compare=object[v];if(typeof element=="object"&&element){const elementSorted=sortObj(element),compareSorted=sortObj(compare);JSON.stringify(elementSorted)!==JSON.stringify(compareSorted)&&(returnObj[v]=element)}typeof element!="object"&&element&&element!==compare&&(returnObj[v]=element)}),returnObj}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import { BaseError } from '../typings/errors';
|
|
2
|
-
export
|
|
3
|
-
(messages: BaseError[], v: BaseError): {
|
|
4
|
-
message?: string;
|
|
5
|
-
} | null;
|
|
6
|
-
}
|
|
7
|
-
declare const customMessages: CustomMessages;
|
|
8
|
-
export default customMessages;
|
|
2
|
+
export default function customMessages(messages: BaseError[] | undefined, v: BaseError): BaseError | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import findIndex from"lodash/findIndex";import pick from"lodash/pick";
|
|
1
|
+
import findIndex from"lodash/findIndex";import pick from"lodash/pick";export default function customMessages(messages=[],v){const i=findIndex(messages,pick(v,["field","code","resource"]));return i!==-1?messages[i]:null}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IconBrand } from '../context/PaymentSourceContext';
|
|
2
|
+
import { PaymentResource } from '../reducers/PaymentMethodReducer';
|
|
3
|
+
import { CustomerPaymentSource } from '@commercelayer/sdk';
|
|
4
|
+
declare type CardDetails = {
|
|
5
|
+
brand: IconBrand | string;
|
|
6
|
+
last4: string;
|
|
7
|
+
exp_month: number | string;
|
|
8
|
+
exp_year: number | string;
|
|
9
|
+
};
|
|
10
|
+
declare type Args = {
|
|
11
|
+
paymentType: PaymentResource;
|
|
12
|
+
customerPayment: Partial<CustomerPaymentSource>;
|
|
13
|
+
};
|
|
14
|
+
export default function getCardDetails({ paymentType, customerPayment, }: Args): CardDetails;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCardDetails({paymentType,customerPayment}){switch(paymentType){case"checkout_com_payments":{const source=customerPayment.payment_source?.payment_response?.source;if(source)return{brand:source.scheme.toLowerCase(),exp_month:source.expiry_month,exp_year:source.expiry_year,last4:source.last4};break}case"stripe_payments":case"braintree_payments":{const source=customerPayment.payment_source?.options?.card;if(source)return{...source};break}case"adyen_payments":{const ps=customerPayment.payment_source,source=ps?.payment_request_data?.payment_method,authorized=ps?.payment_response?.resultCode==="Authorised";if(source&&authorized)return{...source,brand:source?.brand?source.brand:"credit-card"};break}default:{const source=customerPayment.payment_source?.metadata?.card;if(source)return{...source};break}}return{brand:"",exp_month:"**",exp_year:"**",last4:"****"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCartLink({orderId,accessToken,slug}){const env=process.env.NODE_ENV==="production"?"":"stg.";return`${slug}.${env}commercelayer.app/cart/${orderId}?accessToken=${accessToken}`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import first from"lodash/first";import keys from"lodash/keys";const getCurrentItemKey=item=>first(keys(item))||"";export default getCurrentItemKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseError, ResourceErrorType } from '../typings/errors';
|
|
2
2
|
import { Dispatch } from 'react';
|
|
3
|
-
export default function getErrors(error: any, resource: ResourceErrorType): BaseError[];
|
|
3
|
+
export default function getErrors(error: any, resource: ResourceErrorType, field?: string): BaseError[];
|
|
4
4
|
declare type SetErrorsArgs<D> = {
|
|
5
5
|
currentErrors?: BaseError[];
|
|
6
6
|
newErrors?: BaseError[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import differenceBy from"lodash/differenceBy";export default function getErrors(error,resource){
|
|
1
|
+
import differenceBy from"lodash/differenceBy";export default function getErrors(error,resource,field){return error?.errors?.map(e=>({...e,resource,...field&&{field}}))}export function setErrors({currentErrors=[],newErrors=[],dispatch,filterBy="code"}){const errorsDifference=differenceBy(currentErrors,newErrors,filterBy),mergeErrors=currentErrors?.length===0?newErrors:errorsDifference,errors=[...currentErrors||[],...mergeErrors];if(!dispatch)return errors;dispatch({type:"setErrors",payload:{errors}})}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { LineItem } from '@commercelayer/sdk';
|
|
1
|
+
import type { LineItem } from '@commercelayer/sdk';
|
|
2
2
|
import { LineItemType } from '../typings/index';
|
|
3
|
-
export interface GetLineItemsCountInterface {
|
|
4
|
-
(args: {
|
|
5
|
-
lineItems: LineItem[];
|
|
6
|
-
quantity?: number;
|
|
7
|
-
typeAccepted?: TypeAccepted[];
|
|
8
|
-
}): number;
|
|
9
|
-
}
|
|
10
3
|
export declare type TypeAccepted = Extract<LineItemType, 'skus' | 'gift_cards' | 'bundles' | 'adjustments'>;
|
|
11
|
-
declare
|
|
12
|
-
|
|
4
|
+
declare type Args = {
|
|
5
|
+
lineItems: LineItem[];
|
|
6
|
+
quantity?: number;
|
|
7
|
+
typeAccepted?: TypeAccepted[];
|
|
8
|
+
};
|
|
9
|
+
export default function getLineItemsCount({ lineItems, quantity, typeAccepted, }: Args): number;
|
|
10
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export default function getLineItemsCount({lineItems,quantity=0,typeAccepted=["skus","gift_cards","bundles","adjustments"]}){return lineItems.filter(l=>typeAccepted.includes(l.item_type)&&l?.total_amount_cents!==void 0&&l.total_amount_cents>=0).forEach(l=>{l.quantity&&(quantity+=l.quantity)}),quantity}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export default function getLoaderComponent(Loader){return typeof Loader=="function"?_jsx(Loader,{}
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export default function getLoaderComponent(Loader){return typeof Loader=="function"?_jsx(Loader,{}):_jsx(_Fragment,{children:Loader})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export const getPriceByCode=(skuPrices,code="")=>code?first(skuPrices.filter(p=>p.currency_code===code)):first(skuPrices),getPricesComponent=(skuPrices,props)=>isEmpty(skuPrices)?_jsx(PriceTemplate,
|
|
1
|
+
import{createElement as _createElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{isEmpty,first,isArray,has}from"lodash";import PriceTemplate from"../components/utils/PriceTemplate";export const getPriceByCode=(skuPrices,code="")=>code?first(skuPrices.filter(p=>p.currency_code===code)):first(skuPrices),getPricesComponent=(skuPrices,props)=>isEmpty(skuPrices)?_jsx(PriceTemplate,{...props}):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare>"u"&&p?.compare_at_amount_cents>p?.amount_cents||props.showCompare;return _createElement(PriceTemplate,{...props,key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount})});export default function getPrices(prices){const obj={};return isArray(prices)&&prices.forEach(p=>{const sku=p.sku_code;has(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}
|
package/lib/esm/utils/getSdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import getOrganizationSlug from"./organization";import Sdk from"@commercelayer/sdk";export default function getSdk({endpoint,accessToken}){const org=getOrganizationSlug(endpoint);return Sdk(
|
|
1
|
+
import getOrganizationSlug from"./organization";import Sdk from"@commercelayer/sdk";export default function getSdk({endpoint,accessToken}){const org=getOrganizationSlug(endpoint);return Sdk({accessToken,...org})}
|