@commercelayer/react-components 4.8.0-beta.2 → 4.8.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/MetadataInput.d.ts +1 -0
- package/lib/cjs/components/addresses/Address.d.ts +18 -0
- package/lib/cjs/components/addresses/AddressCountrySelector.d.ts +24 -0
- package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -1
- package/lib/cjs/components/addresses/AddressField.d.ts +22 -0
- package/lib/cjs/components/addresses/AddressInput.d.ts +19 -0
- package/lib/cjs/components/addresses/AddressInput.js +1 -1
- package/lib/cjs/components/addresses/AddressStateSelector.d.ts +26 -0
- package/lib/cjs/components/addresses/AddressStateSelector.js +1 -1
- package/lib/cjs/components/addresses/AddressesContainer.d.ts +22 -0
- package/lib/cjs/components/addresses/AddressesEmpty.d.ts +13 -0
- package/lib/cjs/components/addresses/BillingAddressForm.d.ts +20 -0
- package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -1
- package/lib/cjs/components/addresses/ShippingAddressContainer.d.ts +1 -0
- package/lib/cjs/components/addresses/ShippingAddressForm.d.ts +17 -0
- package/lib/cjs/components/auth/CommerceLayer.d.ts +1 -0
- package/lib/cjs/components/customers/CustomerAddressForm.d.ts +5 -0
- package/lib/cjs/components/customers/CustomerAddressForm.js +1 -1
- package/lib/cjs/components/customers/CustomerContainer.d.ts +20 -1
- package/lib/cjs/components/customers/CustomerField.d.ts +16 -0
- package/lib/cjs/components/customers/CustomerInput.d.ts +1 -0
- package/lib/cjs/components/customers/CustomerInput.js +1 -1
- package/lib/cjs/components/customers/CustomerPaymentSource.d.ts +1 -0
- package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
- package/lib/cjs/components/customers/MyAccountLink.d.ts +11 -0
- package/lib/cjs/components/customers/MyIdentityLink.d.ts +16 -0
- package/lib/cjs/components/customers/MyIdentityLink.js +1 -1
- package/lib/cjs/components/errors/Errors.d.ts +1 -0
- package/lib/cjs/components/errors/Errors.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCard.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardInput.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
- package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
- package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
- package/lib/cjs/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItem.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItem.js +1 -1
- package/lib/cjs/components/line_items/LineItemAmount.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemAmount.js +1 -1
- package/lib/cjs/components/line_items/LineItemBundleSkuField.d.ts +24 -0
- package/lib/cjs/components/line_items/LineItemBundleSkuField.js +2 -0
- package/lib/cjs/components/line_items/LineItemBundleSkus.d.ts +6 -0
- package/lib/cjs/components/line_items/LineItemBundleSkus.js +2 -0
- package/lib/cjs/components/line_items/LineItemCode.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemCode.js +1 -1
- package/lib/cjs/components/line_items/LineItemField.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemImage.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemImage.js +1 -1
- package/lib/cjs/components/line_items/LineItemName.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemName.js +1 -1
- package/lib/cjs/components/line_items/LineItemQuantity.d.ts +5 -0
- package/lib/cjs/components/line_items/LineItemQuantity.js +1 -1
- package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
- package/lib/cjs/components/line_items/LineItemsContainer.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
- package/lib/cjs/components/line_items/LineItemsCount.d.ts +1 -0
- package/lib/cjs/components/line_items/LineItemsCount.js +1 -1
- package/lib/cjs/components/line_items/LineItemsEmpty.d.ts +1 -0
- package/lib/cjs/components/orders/AddToCartButton.d.ts +32 -0
- package/lib/cjs/components/orders/AdjustmentAmount.d.ts +1 -0
- package/lib/cjs/components/orders/CartLink.d.ts +8 -0
- package/lib/cjs/components/orders/CartLink.js +1 -1
- package/lib/cjs/components/orders/CheckoutLink.d.ts +16 -0
- package/lib/cjs/components/orders/DiscountAmount.d.ts +1 -0
- package/lib/cjs/components/orders/GiftCardAmount.d.ts +1 -0
- package/lib/cjs/components/orders/HostedCart.d.ts +30 -8
- package/lib/cjs/components/orders/HostedCart.js +1 -1
- package/lib/cjs/components/orders/OrderContainer.d.ts +34 -0
- package/lib/cjs/components/orders/OrderContainer.js +1 -1
- package/lib/cjs/components/orders/OrderList.d.ts +1 -0
- package/lib/cjs/components/orders/OrderList.js +1 -1
- package/lib/cjs/components/orders/OrderListEmpty.d.ts +1 -0
- package/lib/cjs/components/orders/OrderListPaginationButtons.d.ts +1 -0
- package/lib/cjs/components/orders/OrderListPaginationInfo.d.ts +1 -0
- package/lib/cjs/components/orders/OrderListRow.d.ts +1 -0
- package/lib/cjs/components/orders/OrderNumber.d.ts +1 -0
- package/lib/cjs/components/orders/OrderStorage.d.ts +23 -0
- package/lib/cjs/components/orders/PaymentMethodAmount.d.ts +1 -0
- package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
- package/lib/cjs/components/orders/ShippingAmount.d.ts +1 -0
- package/lib/cjs/components/orders/SubTotalAmount.d.ts +1 -0
- package/lib/cjs/components/orders/TaxesAmount.d.ts +1 -0
- package/lib/cjs/components/orders/TotalAmount.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelField.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelLineItem.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelLineItemField.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelLineItemsCount.d.ts +1 -0
- package/lib/cjs/components/parcels/Parcels.d.ts +1 -0
- package/lib/cjs/components/parcels/ParcelsCount.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/AdyenGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/BraintreeGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/ExternalGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/KlarnaGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/PaymentGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/PaypalGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/StripeGateway.d.ts +1 -0
- package/lib/cjs/components/payment_gateways/WireTransferGateway.d.ts +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodName.d.ts +1 -0
- package/lib/cjs/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
- package/lib/cjs/components/payment_source/BraintreePayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/CheckoutComPayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/ExternalPayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/ExternalPayment.js +1 -1
- package/lib/cjs/components/payment_source/KlarnaPayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -1
- package/lib/cjs/components/payment_source/PaymentSource.d.ts +1 -0
- package/lib/cjs/components/payment_source/PaymentSource.js +1 -1
- package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
- package/lib/cjs/components/payment_source/PaymentSourceDetail.d.ts +1 -0
- package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/StripePayment.d.ts +1 -0
- package/lib/cjs/components/payment_source/WireTransferPayment.d.ts +1 -0
- package/lib/cjs/components/prices/Price.d.ts +1 -0
- package/lib/cjs/components/prices/PricesContainer.d.ts +1 -0
- package/lib/cjs/components/shipments/ShipmentField.d.ts +1 -0
- package/lib/cjs/components/shipments/ShipmentsCount.d.ts +1 -0
- package/lib/cjs/components/shipping_methods/ShippingMethodName.d.ts +1 -0
- package/lib/cjs/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
- package/lib/cjs/components/skus/AvailabilityContainer.d.ts +27 -1
- package/lib/cjs/components/skus/AvailabilityContainer.js +1 -1
- package/lib/cjs/components/skus/AvailabilityTemplate.d.ts +17 -3
- package/lib/cjs/components/skus/DeliveryLeadTime.d.ts +1 -0
- package/lib/cjs/components/skus/SkuField.d.ts +14 -2
- package/lib/cjs/components/skus/Skus.d.ts +12 -0
- package/lib/cjs/components/skus/SkusContainer.d.ts +14 -1
- package/lib/cjs/components/stock_transfers/StockTransfer.d.ts +1 -0
- package/lib/cjs/components/stock_transfers/StockTransferField.d.ts +1 -0
- package/lib/cjs/components/utils/AddressCardsTemplate.d.ts +1 -0
- package/lib/cjs/components/utils/BaseOrderPrice.d.ts +1 -0
- package/lib/cjs/components/utils/GenericFieldComponent.d.ts +6 -0
- package/lib/cjs/components/utils/PaymentCardsTemplate.d.ts +1 -0
- package/lib/cjs/components/utils/PriceTemplate.d.ts +1 -0
- package/lib/cjs/components/utils/getAllErrors.d.ts +1 -0
- package/lib/cjs/context/LineItemBundleChildrenContext.d.ts +11 -0
- package/lib/cjs/context/LineItemBundleChildrenContext.js +2 -0
- package/lib/cjs/context/LineItemBundleSkuChildrenContext.d.ts +9 -0
- package/lib/cjs/context/LineItemBundleSkuChildrenContext.js +2 -0
- package/lib/cjs/reducers/AddressReducer.js +1 -1
- package/lib/cjs/reducers/AvailabilityReducer.d.ts +3 -2
- package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
- package/lib/cjs/reducers/CustomerReducer.d.ts +1 -1
- package/lib/cjs/reducers/CustomerReducer.js +1 -1
- package/lib/cjs/reducers/LineItemReducer.d.ts +2 -1
- package/lib/cjs/reducers/LineItemReducer.js +1 -1
- package/lib/cjs/reducers/OrderReducer.d.ts +1 -1
- package/lib/cjs/typings/globals.d.ts +1 -0
- package/lib/cjs/utils/addressesManager.d.ts +5 -4
- package/lib/cjs/utils/addressesManager.js +1 -1
- package/lib/cjs/utils/countryStateCity.d.ts +798 -5
- package/lib/cjs/utils/countryStateCity.js +1 -1
- package/lib/cjs/utils/filterChildren.d.ts +1 -0
- package/lib/cjs/utils/getLoaderComponent.d.ts +1 -0
- package/lib/cjs/utils/getPrices.d.ts +1 -0
- package/lib/cjs/utils/validateFormFields.d.ts +1 -1
- package/lib/cjs/utils/validateFormFields.js +1 -1
- package/lib/esm/components/MetadataInput.d.ts +1 -0
- package/lib/esm/components/addresses/Address.d.ts +18 -0
- package/lib/esm/components/addresses/AddressCountrySelector.d.ts +24 -0
- package/lib/esm/components/addresses/AddressCountrySelector.js +1 -1
- package/lib/esm/components/addresses/AddressField.d.ts +22 -0
- package/lib/esm/components/addresses/AddressInput.d.ts +19 -0
- package/lib/esm/components/addresses/AddressInput.js +1 -1
- package/lib/esm/components/addresses/AddressStateSelector.d.ts +26 -0
- package/lib/esm/components/addresses/AddressStateSelector.js +1 -1
- package/lib/esm/components/addresses/AddressesContainer.d.ts +22 -0
- package/lib/esm/components/addresses/AddressesEmpty.d.ts +13 -0
- package/lib/esm/components/addresses/BillingAddressForm.d.ts +20 -0
- package/lib/esm/components/addresses/SaveAddressesButton.js +1 -1
- package/lib/esm/components/addresses/ShippingAddressContainer.d.ts +1 -0
- package/lib/esm/components/addresses/ShippingAddressForm.d.ts +17 -0
- package/lib/esm/components/auth/CommerceLayer.d.ts +1 -0
- package/lib/esm/components/customers/CustomerAddressForm.d.ts +5 -0
- package/lib/esm/components/customers/CustomerAddressForm.js +1 -1
- package/lib/esm/components/customers/CustomerContainer.d.ts +20 -1
- package/lib/esm/components/customers/CustomerField.d.ts +16 -0
- package/lib/esm/components/customers/CustomerInput.d.ts +1 -0
- package/lib/esm/components/customers/CustomerInput.js +1 -1
- package/lib/esm/components/customers/CustomerPaymentSource.d.ts +1 -0
- package/lib/esm/components/customers/CustomerPaymentSourceEmpty.d.ts +1 -0
- package/lib/esm/components/customers/MyAccountLink.d.ts +11 -0
- package/lib/esm/components/customers/MyIdentityLink.d.ts +16 -0
- package/lib/esm/components/customers/MyIdentityLink.js +1 -1
- package/lib/esm/components/errors/Errors.d.ts +1 -0
- package/lib/esm/components/errors/Errors.js +1 -1
- package/lib/esm/components/gift_cards/GiftCard.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardCurrencySelector.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardInput.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponCode.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponForm.d.ts +1 -0
- package/lib/esm/components/gift_cards/GiftCardOrCouponInput.d.ts +1 -0
- package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionButton.d.ts +1 -0
- package/lib/esm/components/in_stock_subscriptions/InStockSubscriptionsContainer.d.ts +1 -0
- package/lib/esm/components/line_items/LineItem.d.ts +1 -0
- package/lib/esm/components/line_items/LineItem.js +1 -1
- package/lib/esm/components/line_items/LineItemAmount.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemAmount.js +1 -1
- package/lib/esm/components/line_items/LineItemBundleSkuField.d.ts +24 -0
- package/lib/esm/components/line_items/LineItemBundleSkuField.js +2 -0
- package/lib/esm/components/line_items/LineItemBundleSkus.d.ts +6 -0
- package/lib/esm/components/line_items/LineItemBundleSkus.js +2 -0
- package/lib/esm/components/line_items/LineItemCode.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemCode.js +1 -1
- package/lib/esm/components/line_items/LineItemField.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemImage.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemImage.js +1 -1
- package/lib/esm/components/line_items/LineItemName.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemName.js +1 -1
- package/lib/esm/components/line_items/LineItemQuantity.d.ts +5 -0
- package/lib/esm/components/line_items/LineItemQuantity.js +1 -1
- package/lib/esm/components/line_items/LineItemRemoveLink.js +1 -1
- package/lib/esm/components/line_items/LineItemsContainer.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemsContainer.js +1 -1
- package/lib/esm/components/line_items/LineItemsCount.d.ts +1 -0
- package/lib/esm/components/line_items/LineItemsCount.js +1 -1
- package/lib/esm/components/line_items/LineItemsEmpty.d.ts +1 -0
- package/lib/esm/components/orders/AddToCartButton.d.ts +32 -0
- package/lib/esm/components/orders/AdjustmentAmount.d.ts +1 -0
- package/lib/esm/components/orders/CartLink.d.ts +8 -0
- package/lib/esm/components/orders/CartLink.js +1 -1
- package/lib/esm/components/orders/CheckoutLink.d.ts +16 -0
- package/lib/esm/components/orders/DiscountAmount.d.ts +1 -0
- package/lib/esm/components/orders/GiftCardAmount.d.ts +1 -0
- package/lib/esm/components/orders/HostedCart.d.ts +30 -8
- package/lib/esm/components/orders/HostedCart.js +1 -1
- package/lib/esm/components/orders/OrderContainer.d.ts +34 -0
- package/lib/esm/components/orders/OrderContainer.js +1 -1
- package/lib/esm/components/orders/OrderList.d.ts +1 -0
- package/lib/esm/components/orders/OrderList.js +1 -1
- package/lib/esm/components/orders/OrderListEmpty.d.ts +1 -0
- package/lib/esm/components/orders/OrderListPaginationButtons.d.ts +1 -0
- package/lib/esm/components/orders/OrderListPaginationInfo.d.ts +1 -0
- package/lib/esm/components/orders/OrderListRow.d.ts +1 -0
- package/lib/esm/components/orders/OrderNumber.d.ts +1 -0
- package/lib/esm/components/orders/OrderStorage.d.ts +23 -0
- package/lib/esm/components/orders/PaymentMethodAmount.d.ts +1 -0
- package/lib/esm/components/orders/PrivacyAndTermsCheckbox.d.ts +1 -0
- package/lib/esm/components/orders/ShippingAmount.d.ts +1 -0
- package/lib/esm/components/orders/SubTotalAmount.d.ts +1 -0
- package/lib/esm/components/orders/TaxesAmount.d.ts +1 -0
- package/lib/esm/components/orders/TotalAmount.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelField.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelLineItem.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelLineItemField.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelLineItemsCount.d.ts +1 -0
- package/lib/esm/components/parcels/Parcels.d.ts +1 -0
- package/lib/esm/components/parcels/ParcelsCount.d.ts +1 -0
- package/lib/esm/components/payment_gateways/AdyenGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/BraintreeGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/CheckoutComGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/ExternalGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/KlarnaGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/PaymentGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
- package/lib/esm/components/payment_gateways/PaypalGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/StripeGateway.d.ts +1 -0
- package/lib/esm/components/payment_gateways/WireTransferGateway.d.ts +1 -0
- package/lib/esm/components/payment_methods/PaymentMethod.d.ts +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodName.d.ts +1 -0
- package/lib/esm/components/payment_methods/PaymentMethodPrice.d.ts +1 -0
- package/lib/esm/components/payment_source/BraintreePayment.d.ts +1 -0
- package/lib/esm/components/payment_source/CheckoutComPayment.d.ts +1 -0
- package/lib/esm/components/payment_source/ExternalPayment.d.ts +1 -0
- package/lib/esm/components/payment_source/ExternalPayment.js +1 -1
- package/lib/esm/components/payment_source/KlarnaPayment.d.ts +1 -0
- package/lib/esm/components/payment_source/KlarnaPayment.js +1 -1
- package/lib/esm/components/payment_source/PaymentSource.d.ts +1 -0
- package/lib/esm/components/payment_source/PaymentSource.js +1 -1
- package/lib/esm/components/payment_source/PaymentSourceBrandIcon.d.ts +1 -0
- package/lib/esm/components/payment_source/PaymentSourceBrandName.d.ts +1 -0
- package/lib/esm/components/payment_source/PaymentSourceDetail.d.ts +1 -0
- package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +1 -0
- package/lib/esm/components/payment_source/StripePayment.d.ts +1 -0
- package/lib/esm/components/payment_source/WireTransferPayment.d.ts +1 -0
- package/lib/esm/components/prices/Price.d.ts +1 -0
- package/lib/esm/components/prices/PricesContainer.d.ts +1 -0
- package/lib/esm/components/shipments/ShipmentField.d.ts +1 -0
- package/lib/esm/components/shipments/ShipmentsCount.d.ts +1 -0
- package/lib/esm/components/shipping_methods/ShippingMethodName.d.ts +1 -0
- package/lib/esm/components/shipping_methods/ShippingMethodPrice.d.ts +1 -0
- package/lib/esm/components/shipping_methods/ShippingMethodRadioButton.d.ts +1 -0
- package/lib/esm/components/skus/AvailabilityContainer.d.ts +27 -1
- package/lib/esm/components/skus/AvailabilityContainer.js +1 -1
- package/lib/esm/components/skus/AvailabilityTemplate.d.ts +17 -3
- package/lib/esm/components/skus/DeliveryLeadTime.d.ts +1 -0
- package/lib/esm/components/skus/SkuField.d.ts +14 -2
- package/lib/esm/components/skus/Skus.d.ts +12 -0
- package/lib/esm/components/skus/SkusContainer.d.ts +14 -1
- package/lib/esm/components/stock_transfers/StockTransfer.d.ts +1 -0
- package/lib/esm/components/stock_transfers/StockTransferField.d.ts +1 -0
- package/lib/esm/components/utils/AddressCardsTemplate.d.ts +1 -0
- package/lib/esm/components/utils/BaseOrderPrice.d.ts +1 -0
- package/lib/esm/components/utils/GenericFieldComponent.d.ts +6 -0
- package/lib/esm/components/utils/PaymentCardsTemplate.d.ts +1 -0
- package/lib/esm/components/utils/PriceTemplate.d.ts +1 -0
- package/lib/esm/components/utils/getAllErrors.d.ts +1 -0
- package/lib/esm/context/LineItemBundleChildrenContext.d.ts +11 -0
- package/lib/esm/context/LineItemBundleChildrenContext.js +2 -0
- package/lib/esm/context/LineItemBundleSkuChildrenContext.d.ts +9 -0
- package/lib/esm/context/LineItemBundleSkuChildrenContext.js +2 -0
- package/lib/esm/reducers/AddressReducer.js +1 -1
- package/lib/esm/reducers/AvailabilityReducer.d.ts +3 -2
- package/lib/esm/reducers/AvailabilityReducer.js +1 -1
- package/lib/esm/reducers/CustomerReducer.d.ts +1 -1
- package/lib/esm/reducers/CustomerReducer.js +1 -1
- package/lib/esm/reducers/LineItemReducer.d.ts +2 -1
- package/lib/esm/reducers/LineItemReducer.js +1 -1
- package/lib/esm/reducers/OrderReducer.d.ts +1 -1
- package/lib/esm/typings/globals.d.ts +1 -0
- package/lib/esm/utils/addressesManager.d.ts +5 -4
- package/lib/esm/utils/addressesManager.js +1 -1
- package/lib/esm/utils/countryStateCity.d.ts +798 -5
- package/lib/esm/utils/countryStateCity.js +1 -1
- package/lib/esm/utils/filterChildren.d.ts +1 -0
- package/lib/esm/utils/getLoaderComponent.d.ts +1 -0
- package/lib/esm/utils/getPrices.d.ts +1 -0
- package/lib/esm/utils/validateFormFields.d.ts +1 -1
- package/lib/esm/utils/validateFormFields.js +1 -1
- package/package.json +2 -4
- package/lib/cjs/utils/isEmptyStates.d.ts +0 -1
- package/lib/cjs/utils/isEmptyStates.js +0 -2
- package/lib/esm/utils/isEmptyStates.d.ts +0 -1
- package/lib/esm/utils/isEmptyStates.js +0 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { type ConditionalElement } from '../../typings/index';
|
|
2
3
|
import { type TGenericChildrenProps, type TResources } from '../utils/GenericFieldComponent';
|
|
3
4
|
type StockTransferFieldChildrenProps = TGenericChildrenProps<TResources['StockTransfer']>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { type PropsType } from '../../utils/PropsType';
|
|
2
3
|
import { type baseOrderPricePropTypes } from '../../typings/index';
|
|
3
4
|
export type BaseOrderPriceProps = PropsType<typeof baseOrderPricePropTypes, unknown> & Omit<JSX.IntrinsicElements['span'], 'children'>;
|
|
@@ -44,7 +44,13 @@ type GenericContext<K extends keyof ResourceContext> = Context<ResourceContext[K
|
|
|
44
44
|
interface Props<E extends TResources[keyof TResources]> {
|
|
45
45
|
children?: (props: TGenericChildrenProps<E>) => JSX.Element;
|
|
46
46
|
resource: E['resource'];
|
|
47
|
+
/**
|
|
48
|
+
* Resource attribute to display.
|
|
49
|
+
*/
|
|
47
50
|
attribute: keyof E;
|
|
51
|
+
/**
|
|
52
|
+
* Html tag to render. When tag is `img` the value will be used to fill the `src` attribute.
|
|
53
|
+
*/
|
|
48
54
|
tagElement: keyof JSX.IntrinsicElements;
|
|
49
55
|
context: GenericContext<E['resource']>;
|
|
50
56
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type LineItem, type SkuList } from '@commercelayer/sdk';
|
|
3
|
+
export type InitialLineItemBundleChildrenContext = Partial<{
|
|
4
|
+
skuListItems: SkuList['sku_list_items'] | null | undefined;
|
|
5
|
+
lineItem: LineItem | null | undefined;
|
|
6
|
+
}>;
|
|
7
|
+
declare const LineItemBundleChildrenContext: import("react").Context<Partial<{
|
|
8
|
+
skuListItems: SkuList['sku_list_items'] | null | undefined;
|
|
9
|
+
lineItem: LineItem | null | undefined;
|
|
10
|
+
}>>;
|
|
11
|
+
export default LineItemBundleChildrenContext;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type SkuListItem } from '@commercelayer/sdk';
|
|
3
|
+
export type InitialLineItemBundleSkuChildrenContext = Partial<{
|
|
4
|
+
skuListItem: SkuListItem | null | undefined;
|
|
5
|
+
}>;
|
|
6
|
+
declare const LineItemBundleChildrenContext: import("react").Context<Partial<{
|
|
7
|
+
skuListItem: SkuListItem | null | undefined;
|
|
8
|
+
}>>;
|
|
9
|
+
export default LineItemBundleChildrenContext;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";import{invertedAddressesHandler}from"../utils/addressesManager";export const addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],addressInitialState={errors:[]},setAddressErrors=({errors,dispatch,currentErrors=[],resource})=>{const billingErrors=resource==="billing_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="billing_address"),shippingErrors=resource==="shipping_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="shipping_address"),finalErrors=[...billingErrors,...shippingErrors];dispatch&&dispatch({type:"setErrors",payload:{errors:finalErrors}})},setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})},setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${camelCase(resource)}Id`]:id}})};export async function saveAddresses({config,updateOrder,order,state,customerEmail}){const{shipToDifferentAddress,invertAddresses,billing_address:billingAddress,shipping_address:shippingAddress,billingAddressId,shippingAddressId}=state;try{const sdk=getSdk(config);if(order){let orderAttributes=null;if(invertAddresses)orderAttributes=await invertedAddressesHandler({billingAddress,billingAddressId,customerEmail,order,shipToDifferentAddress,shippingAddress,shippingAddressId,sdk});else{const currentBillingAddressRef=order?.billing_address?.reference;if(orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId,customer_email:customerEmail},currentBillingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),billingAddress!=null&&Object.keys(billingAddress).length>0){delete orderAttributes._billing_address_clone_id,delete orderAttributes._shipping_address_clone_id,orderAttributes._shipping_address_same_as_billing=!0;const hasMetadata=Object.keys(billingAddress).filter(key=>!!key.startsWith("metadata_"));hasMetadata?.length>0&&hasMetadata.forEach(key=>{const metadataKey=key.replace("metadata_","");billingAddress.metadata={...billingAddress.metadata||{},[metadataKey]:billingAddress[key]},delete billingAddress[key]});const address=await sdk.addresses.create(billingAddress);orderAttributes.billing_address=sdk.addresses.relationship(address.id)}if(shipToDifferentAddress&&(delete orderAttributes._shipping_address_same_as_billing,shippingAddressId&&(orderAttributes._shipping_address_clone_id=shippingAddressId),shippingAddress!=null&&Object.keys(shippingAddress).length>0)){delete orderAttributes._shipping_address_clone_id;const hasMetadata=Object.keys(shippingAddress).filter(key=>!!key.startsWith("metadata_"));hasMetadata?.length>0&&hasMetadata.forEach(key=>{const metadataKey=key.replace("metadata_","");shippingAddress.metadata={...shippingAddress.metadata||{},[metadataKey]:shippingAddress[key]},delete shippingAddress[key]});const address=await sdk.addresses.create(shippingAddress);orderAttributes.shipping_address=sdk.addresses.relationship(address.id)}}if(orderAttributes!=null&&updateOrder)return{success:!0,order:(await updateOrder({id:order.id,attributes:orderAttributes}))?.order}}return{success:!1}}catch(error){return console.error(error),{success:!1,error}}}const type=["setErrors","setAddress","setShipToDifferentAddress","setCloneAddress","cleanup"],addressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default addressReducer;
|
|
2
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import camelCase from"lodash/camelCase";import{invertedAddressesHandler}from"../utils/addressesManager";export const addressFields=["city","company","country_code","first_name","last_name","line_1","line_2","phone","state_code","zip_code"],addressInitialState={errors:[]},setAddressErrors=({errors,dispatch,currentErrors=[],resource})=>{const billingErrors=resource==="billing_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="billing_address"),shippingErrors=resource==="shipping_address"?errors.filter(e=>e.resource===resource):currentErrors.filter(e=>e.resource==="shipping_address"),finalErrors=[...billingErrors,...shippingErrors];dispatch&&dispatch({type:"setErrors",payload:{errors:finalErrors}})},setAddress=({values,resource,dispatch})=>{dispatch&&dispatch({type:"setAddress",payload:{[`${resource}`]:values}})},setCloneAddress=(id,resource,dispatch)=>{dispatch({type:"setCloneAddress",payload:{[`${camelCase(resource)}Id`]:id}})};export async function saveAddresses({config,updateOrder,order,state,customerEmail}){const{shipToDifferentAddress,invertAddresses,billing_address:billingAddress,shipping_address:shippingAddress,billingAddressId,shippingAddressId}=state;try{const sdk=getSdk(config);if(order){let orderAttributes=null;if(invertAddresses)orderAttributes=await invertedAddressesHandler({billingAddress,billingAddressId,customerEmail,order,shipToDifferentAddress,shippingAddress,shippingAddressId,sdk});else{const doNotShipItems=order?.line_items?.every(lineItem=>lineItem?.item?.do_not_ship===!0),currentBillingAddressRef=order?.billing_address?.reference;if(orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId,customer_email:customerEmail},currentBillingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),billingAddress!=null&&Object.keys(billingAddress).length>0)delete orderAttributes._billing_address_clone_id,delete orderAttributes._shipping_address_clone_id,doNotShipItems||(orderAttributes._shipping_address_same_as_billing=!0);else{const currentBillingAddressRef2=order?.billing_address?.reference;if(orderAttributes={id:order?.id,_billing_address_clone_id:billingAddressId,_shipping_address_clone_id:billingAddressId,customer_email:customerEmail},currentBillingAddressRef2===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),billingAddress!=null&&Object.keys(billingAddress).length>0){delete orderAttributes._billing_address_clone_id,delete orderAttributes._shipping_address_clone_id,orderAttributes._shipping_address_same_as_billing=!0;const hasMetadata=Object.keys(billingAddress).filter(key=>!!key.startsWith("metadata_"));hasMetadata?.length>0&&hasMetadata.forEach(key=>{const metadataKey=key.replace("metadata_","");billingAddress.metadata={...billingAddress.metadata||{},[metadataKey]:billingAddress[key]},delete billingAddress[key]});const address=await sdk.addresses.create(billingAddress);orderAttributes.billing_address=sdk.addresses.relationship(address.id)}if(shipToDifferentAddress&&(delete orderAttributes._shipping_address_same_as_billing,shippingAddressId&&(orderAttributes._shipping_address_clone_id=shippingAddressId),shippingAddress!=null&&Object.keys(shippingAddress).length>0)){delete orderAttributes._shipping_address_clone_id;const hasMetadata=Object.keys(shippingAddress).filter(key=>!!key.startsWith("metadata_"));hasMetadata?.length>0&&hasMetadata.forEach(key=>{const metadataKey=key.replace("metadata_","");shippingAddress.metadata={...shippingAddress.metadata||{},[metadataKey]:shippingAddress[key]},delete shippingAddress[key]});const address=await sdk.addresses.create(shippingAddress);orderAttributes.shipping_address=sdk.addresses.relationship(address.id)}}}if(orderAttributes!=null&&updateOrder)return{success:!0,order:(await updateOrder({id:order.id,attributes:orderAttributes}))?.order}}return{success:!1}}catch(error){return console.error(error),{success:!1,error}}}const type=["setErrors","setAddress","setShipToDifferentAddress","setCloneAddress","cleanup"],addressReducer=(state,reducer)=>baseReducer(state,reducer,type);export default addressReducer;
|
|
@@ -42,8 +42,9 @@ export interface AvailabilityAction {
|
|
|
42
42
|
payload: AvailabilityPayload;
|
|
43
43
|
}
|
|
44
44
|
export declare const availabilityInitialState: AvailabilityState;
|
|
45
|
-
export declare function getAvailability({ skuCode, dispatch, config }: {
|
|
46
|
-
skuCode
|
|
45
|
+
export declare function getAvailability({ skuCode, skuId, dispatch, config }: {
|
|
46
|
+
skuCode?: string;
|
|
47
|
+
skuId?: string;
|
|
47
48
|
dispatch: Dispatch<AvailabilityAction>;
|
|
48
49
|
config: CommerceLayerConfig;
|
|
49
50
|
}): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const availabilityInitialState={};export async function getAvailability({skuCode,dispatch,config}){const sdk=getSdk(config);try{const[sku]=await sdk.skus.list({fields:{skus:["id"]},filters:{code_in:skuCode}});if(sku){const skuInventory=await sdk.skus.retrieve(sku.id,{fields:{skus:["inventory"]}}),[level]=skuInventory.inventory?.levels||[],[delivery]=level?.delivery_lead_times||[];dispatch({type:"setAvailability",payload:{...delivery,quantity:skuInventory.inventory.quantity,skuCode}})}}catch(error){console.error("Get SKU availability",error)}}const typeAction=["setAvailability","setErrors"],availabilityReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default availabilityReducer;
|
|
2
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const availabilityInitialState={};export async function getAvailability({skuCode,skuId,dispatch,config}){const sdk=getSdk(config);try{const[sku]=skuId!=null?[{id:skuId}]:skuCode!=null?await sdk.skus.list({fields:{skus:["id"]},filters:{code_in:skuCode}}):[];if(sku){const skuInventory=await sdk.skus.retrieve(sku.id,{fields:{skus:["inventory"]}}),[level]=skuInventory.inventory?.levels||[],[delivery]=level?.delivery_lead_times||[];dispatch({type:"setAvailability",payload:{...delivery,quantity:skuInventory.inventory.quantity,skuCode}})}}catch(error){console.error("Get SKU availability",error)}}const typeAction=["setAvailability","setErrors"],availabilityReducer=(state,reducer)=>baseReducer(state,reducer,typeAction);export default availabilityReducer;
|
|
@@ -141,7 +141,7 @@ interface TCreateCustomerAddress {
|
|
|
141
141
|
export declare function createCustomerAddress({ address, config, dispatch, state }: TCreateCustomerAddress): Promise<void>;
|
|
142
142
|
interface GetCustomerPaymentsParams extends GetCustomerOrdersProps {
|
|
143
143
|
}
|
|
144
|
-
export declare function getCustomerPayments({ config, dispatch }: GetCustomerPaymentsParams): Promise<void>;
|
|
144
|
+
export declare function getCustomerPayments({ config, dispatch, pageSize, pageNumber }: GetCustomerPaymentsParams): Promise<void>;
|
|
145
145
|
export declare function getCustomerInfo({ config, dispatch }: GetCustomerPaymentsParams): Promise<void>;
|
|
146
146
|
export declare const customerInitialState: CustomerState;
|
|
147
147
|
declare const customerReducer: (state: CustomerState, reducer: CustomerAction) => CustomerState;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";import jwtDecode from"../utils/jwt";import{getCustomerIdByToken}from"../utils/getCustomerIdByToken";export async function saveCustomerUser({customerEmail,order,updateOrder}){if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}}export function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}export function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}export async function getCustomerAddresses({config,dispatch,isOrderAvailable}){try{const addresses=[];(await getSdk(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&(customerAddress.id!==customerAddress.address.reference&&!isOrderAvailable&&(customerAddress.address.reference=customerAddress.id),addresses.push(customerAddress.address))}),addresses.sort((a,b)=>a.full_name&&b.full_name?a.full_name.localeCompare(b.full_name):0),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=getErrors({error,resource:"addresses"});dispatch({type:"setErrors",payload:{errors}})}}export async function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){if(config&&addresses&&dispatch&&config)try{await getSdk(config).customer_addresses.delete(customerAddressId);const newAddresses=addresses.filter(({reference})=>reference!==customerAddressId);dispatch({type:"setAddresses",payload:{addresses:newAddresses}})}catch{throw new Error("Couldn't delete address")}}export function getCustomerPaymentSources(params){if(params){const{order,dispatch}=params;order?.available_customer_payment_sources&&dispatch&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})}}export async function getCustomerOrders({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const orders=await getSdk(config).customers.orders(owner.id,{filters:{status_not_in:"draft,pending"},pageSize,pageNumber});dispatch({type:"setOrders",payload:{orders}})}}}export async function getCustomerSubscriptions({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const subscriptions=await getSdk(config).customers.order_subscriptions(owner.id,{pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}}}export async function createCustomerAddress({address,config,dispatch,state}){if(config&&address){const sdk=getSdk(config),{id}=address;try{if(id){const upAddress=await sdk.addresses.update(address),updatedAddresses=state?.addresses?.map(a=>a.id===upAddress.id?upAddress:a);dispatch&&dispatch({type:"setAddresses",payload:{addresses:updatedAddresses}})}else{const newAddress=await sdk.addresses.create(address);if(state?.customers?.id&&newAddress?.id){const newCustomerAddress=await sdk.customer_addresses.create({customer:sdk.customers.relationship(state?.customers?.id),address:sdk.addresses.relationship(newAddress.id)});await sdk.addresses.update({id:newAddress.id,reference:newCustomerAddress.id}),dispatch&&state?.addresses&&(newAddress.reference=newCustomerAddress.id,dispatch({type:"setAddresses",payload:{addresses:[...state.addresses,newAddress]}}))}}}catch{throw new Error("Couldn't create customer address")}}}export async function getCustomerPayments({config,dispatch}){if(config!=null&&dispatch!=null){const
|
|
2
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";import jwtDecode from"../utils/jwt";import{getCustomerIdByToken}from"../utils/getCustomerIdByToken";export async function saveCustomerUser({customerEmail,order,updateOrder}){if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}}export function setCustomerErrors(errors,dispatch){dispatch&&dispatch({type:"setErrors",payload:{errors}})}export function setCustomerEmail(customerEmail,dispatch){dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})}export async function getCustomerAddresses({config,dispatch,isOrderAvailable}){try{const addresses=[];(await getSdk(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&(customerAddress.id!==customerAddress.address.reference&&!isOrderAvailable&&(customerAddress.address.reference=customerAddress.id),addresses.push(customerAddress.address))}),addresses.sort((a,b)=>a.full_name&&b.full_name?a.full_name.localeCompare(b.full_name):0),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=getErrors({error,resource:"addresses"});dispatch({type:"setErrors",payload:{errors}})}}export async function deleteCustomerAddress({config,dispatch,customerAddressId,addresses}){if(config&&addresses&&dispatch&&config)try{await getSdk(config).customer_addresses.delete(customerAddressId);const newAddresses=addresses.filter(({reference})=>reference!==customerAddressId);dispatch({type:"setAddresses",payload:{addresses:newAddresses}})}catch{throw new Error("Couldn't delete address")}}export function getCustomerPaymentSources(params){if(params){const{order,dispatch}=params;order?.available_customer_payment_sources&&dispatch&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})}}export async function getCustomerOrders({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const orders=await getSdk(config).customers.orders(owner.id,{filters:{status_not_in:"draft,pending"},pageSize,pageNumber});dispatch({type:"setOrders",payload:{orders}})}}}export async function getCustomerSubscriptions({config,dispatch,pageSize=10,pageNumber=1}){if(config.accessToken){const{owner}=jwtDecode(config.accessToken);if(owner?.id){const subscriptions=await getSdk(config).customers.order_subscriptions(owner.id,{pageSize,pageNumber});dispatch({type:"setSubscriptions",payload:{subscriptions}})}}}export async function createCustomerAddress({address,config,dispatch,state}){if(config&&address){const sdk=getSdk(config),{id}=address;try{if(id){const upAddress=await sdk.addresses.update(address),updatedAddresses=state?.addresses?.map(a=>a.id===upAddress.id?upAddress:a);dispatch&&dispatch({type:"setAddresses",payload:{addresses:updatedAddresses}})}else{const newAddress=await sdk.addresses.create(address);if(state?.customers?.id&&newAddress?.id){const newCustomerAddress=await sdk.customer_addresses.create({customer:sdk.customers.relationship(state?.customers?.id),address:sdk.addresses.relationship(newAddress.id)});await sdk.addresses.update({id:newAddress.id,reference:newCustomerAddress.id}),dispatch&&state?.addresses&&(newAddress.reference=newCustomerAddress.id,dispatch({type:"setAddresses",payload:{addresses:[...state.addresses,newAddress]}}))}}}catch{throw new Error("Couldn't create customer address")}}}export async function getCustomerPayments({config,dispatch,pageSize=10,pageNumber=1}){if(config?.accessToken!=null&&dispatch!=null){const sdk=getSdk(config),{owner}=jwtDecode(config.accessToken);if(owner?.id){const payments=await sdk.customer_payment_sources.list({include:["payment_source"],pageNumber,pageSize});dispatch({type:"setPayments",payload:{payments}})}}}export async function getCustomerInfo({config,dispatch}){if(config.accessToken&&dispatch!=null){const sdk=getSdk(config),customerId=getCustomerIdByToken(config.accessToken);if(customerId){const customers=await sdk.customers.retrieve(customerId),customerEmail=customers.email;dispatch({type:"setCustomers",payload:{customers,customerEmail}})}}}export const customerInitialState={errors:[],addresses:null,payments:null};const type=["setErrors","setCustomerEmail","setAddresses","setPayments","setOrders","setSubscriptions","setCustomers"],customerReducer=(state,reducer)=>baseReducer(state,reducer,type);export default customerReducer;
|
|
@@ -7,6 +7,7 @@ import { type Order, type LineItem } from '@commercelayer/sdk';
|
|
|
7
7
|
export interface UpdateLineItemParams {
|
|
8
8
|
lineItemId: string;
|
|
9
9
|
quantity?: number;
|
|
10
|
+
hasExternalPrice?: boolean;
|
|
10
11
|
dispatch: Dispatch<LineItemAction>;
|
|
11
12
|
config: CommerceLayerConfig;
|
|
12
13
|
getOrder: getOrderContext | undefined;
|
|
@@ -30,7 +31,7 @@ export interface LineItemPayload {
|
|
|
30
31
|
errors?: BaseError[];
|
|
31
32
|
}
|
|
32
33
|
export interface LineItemState extends LineItemPayload {
|
|
33
|
-
updateLineItem?: (lineItemId: string, quantity?: number) => Promise<void>;
|
|
34
|
+
updateLineItem?: (lineItemId: string, quantity?: number, hasExternalPrice?: boolean) => Promise<void>;
|
|
34
35
|
deleteLineItem?: (lineItemId: string) => Promise<void>;
|
|
35
36
|
}
|
|
36
37
|
export interface LineItemAction {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const getLineItems=params=>{const{order,dispatch,config}=params,sdk=getSdk(config);let allLineItems=[];order&&sdk.orders.retrieve(order?.id,{include:["line_items","line_items.line_item_options.sku_option"],fields:{orders:["line_items"]}}).then(response=>{dispatch({type:"setLoading",payload:{loading:!1}});const items=response.line_items||[];allLineItems=[...allLineItems,...items],dispatch({type:"setLineItems",payload:{lineItems:allLineItems}})}).catch(error=>{const errors=getErrors({error,resource:"line_items"});dispatch({type:"setErrors",payload:{errors}})})};export async function updateLineItem(params){const{config,lineItemId,quantity,getOrder,orderId,dispatch}=params,sdk=getSdk(config);try{await sdk.line_items.update({id:lineItemId,quantity}),getOrder&&await getOrder(orderId),dispatch({type:"setErrors",payload:{errors:[]}})}catch(error){const errors=getErrors({error,resource:"line_items",attributes:{id:lineItemId}});dispatch({type:"setErrors",payload:{errors}})}}export const deleteLineItem=async params=>{const{config,lineItemId,getOrder,orderId,dispatch}=params,sdk=getSdk(config);try{await sdk.line_items.delete(lineItemId),getOrder&&await getOrder(orderId),dispatch({type:"setErrors",payload:{errors:[]}})}catch(error){const errors=getErrors({error,resource:"line_items"});dispatch({type:"setErrors",payload:{errors}})}},lineItemInitialState={loading:!1,errors:[]};const actionType=["setLineItems","setErrors","setLoading"],lineItemReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default lineItemReducer;
|
|
2
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const getLineItems=params=>{const{order,dispatch,config}=params,sdk=getSdk(config);let allLineItems=[];order&&sdk.orders.retrieve(order?.id,{include:["line_items","line_items.line_item_options.sku_option"],fields:{orders:["line_items"]}}).then(response=>{dispatch({type:"setLoading",payload:{loading:!1}});const items=response.line_items||[];allLineItems=[...allLineItems,...items],dispatch({type:"setLineItems",payload:{lineItems:allLineItems}})}).catch(error=>{const errors=getErrors({error,resource:"line_items"});dispatch({type:"setErrors",payload:{errors}})})};export async function updateLineItem(params){const{config,lineItemId,quantity,hasExternalPrice,getOrder,orderId,dispatch}=params,sdk=getSdk(config);try{await sdk.line_items.update({id:lineItemId,quantity,_external_price:hasExternalPrice}),getOrder&&await getOrder(orderId),dispatch({type:"setErrors",payload:{errors:[]}})}catch(error){const errors=getErrors({error,resource:"line_items",attributes:{id:lineItemId}});dispatch({type:"setErrors",payload:{errors}})}}export const deleteLineItem=async params=>{const{config,lineItemId,getOrder,orderId,dispatch}=params,sdk=getSdk(config);try{await sdk.line_items.delete(lineItemId),getOrder&&await getOrder(orderId),dispatch({type:"setErrors",payload:{errors:[]}})}catch(error){const errors=getErrors({error,resource:"line_items"});dispatch({type:"setErrors",payload:{errors}})}},lineItemInitialState={loading:!1,errors:[],lineItems:[]};const actionType=["setLineItems","setErrors","setLoading"],lineItemReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default lineItemReducer;
|
|
@@ -26,7 +26,7 @@ export type AddToCartReturn = Promise<{
|
|
|
26
26
|
}>;
|
|
27
27
|
export type AddToCartImport = (params: AddToCartImportParams) => AddToCartReturn;
|
|
28
28
|
export type UnsetOrderState = (dispatch: Dispatch<OrderActions>) => void;
|
|
29
|
-
export type ResourceIncluded = 'billing_address' | 'shipping_address' | 'line_items.line_item_options.sku_option' | 'line_items.item' | 'available_customer_payment_sources.payment_source' | 'shipments.available_shipping_methods' | 'shipments.stock_transfers' | 'shipments.stock_transfers.line_item' | 'shipments.stock_line_items.line_item' | 'shipments.shipping_method' | 'shipments.stock_location' | 'shipments.parcels' | 'shipments.parcels.parcel_line_items' | 'payment_source' | 'available_payment_methods' | 'payment_method';
|
|
29
|
+
export type ResourceIncluded = 'billing_address' | 'shipping_address' | 'line_items.line_item_options.sku_option' | 'line_items.item' | 'line_items.bundle.sku_list.sku_list_items' | 'line_items.bundle.sku_list.sku_list_items.sku' | 'available_customer_payment_sources.payment_source' | 'shipments.available_shipping_methods' | 'shipments.stock_transfers' | 'shipments.stock_transfers.line_item' | 'shipments.stock_line_items.line_item' | 'shipments.shipping_method' | 'shipments.stock_location' | 'shipments.parcels' | 'shipments.parcels.parcel_line_items' | 'payment_source' | 'available_payment_methods' | 'payment_method';
|
|
30
30
|
type ResourceIncludedLoaded = Partial<Record<ResourceIncluded, boolean>>;
|
|
31
31
|
export interface OrderPayload {
|
|
32
32
|
loading?: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export type DefaultChildrenType = JSX.Element[] | JSX.Element | null;
|
|
2
3
|
type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
|
|
3
4
|
export type TRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BaseError } from '../typings/errors';
|
|
2
|
-
import { type OrderUpdate, type
|
|
2
|
+
import { type OrderUpdate, type Order, type CommerceLayerClient, type LineItem, type Address, type AddressCreate } from '@commercelayer/sdk';
|
|
3
3
|
import { type TCustomerAddress } from '../reducers/CustomerReducer';
|
|
4
4
|
interface BillingAddressControllerProps {
|
|
5
5
|
billing_address?: AddressCreate;
|
|
@@ -21,7 +21,7 @@ interface ShippingAddressControllerProps {
|
|
|
21
21
|
invertAddresses?: boolean;
|
|
22
22
|
}
|
|
23
23
|
export declare function shippingAddressController({ billingDisable, errors, shipToDifferentAddress, shipping_address, shippingAddressId, invertAddresses, requiresBillingInfo }: ShippingAddressControllerProps): boolean;
|
|
24
|
-
|
|
24
|
+
interface CountryLockControllerProps {
|
|
25
25
|
addresses?: Address[] | null;
|
|
26
26
|
billing_address?: TCustomerAddress;
|
|
27
27
|
billingAddressId?: string;
|
|
@@ -29,8 +29,9 @@ type CountryLockController = (params: {
|
|
|
29
29
|
shipToDifferentAddress?: boolean;
|
|
30
30
|
shipping_address?: AddressCreate;
|
|
31
31
|
shippingAddressId?: string;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
lineItems?: LineItem[] | null;
|
|
33
|
+
}
|
|
34
|
+
export declare function countryLockController({ addresses, billing_address, billingAddressId, countryCodeLock, shipToDifferentAddress, shipping_address, shippingAddressId, lineItems }: CountryLockControllerProps): boolean;
|
|
34
35
|
interface InvertedAddressesHandlerParams {
|
|
35
36
|
billingAddress?: AddressCreate;
|
|
36
37
|
billingAddressId?: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import isEmpty from"lodash/isEmpty";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export function billingAddressController({billing_address,billingAddressId,errors,requiresBillingInfo=!1,invertAddresses=!1,shipToDifferentAddress,shippingDisable}){let billingDisable=invertAddresses?!!(!shippingDisable&&shipToDifferentAddress):!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address))if(invertAddresses)billingDisable=!!(billing_address&&fieldsExist(billing_address));else{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}export function shippingAddressController({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId,invertAddresses=!1,requiresBillingInfo=!1}){let shippingDisable=invertAddresses?!isEmpty(errors)||isEmpty(shipping_address):!!(!billingDisable&&shipToDifferentAddress);if(isEmpty(errors)&&!isEmpty(shipping_address))if(invertAddresses){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),shippingDisable=!!(shipping_address&&fieldsExist(shipping_address,billingInfo))}else shippingDisable=!!(shipping_address&&fieldsExist(shipping_address));return shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable}export
|
|
2
|
+
import isEmpty from"lodash/isEmpty";import{fieldsExist}from"./validateFormFields";import{addressFields}from"../reducers/AddressReducer";export function billingAddressController({billing_address,billingAddressId,errors,requiresBillingInfo=!1,invertAddresses=!1,shipToDifferentAddress,shippingDisable}){let billingDisable=invertAddresses?!!(!shippingDisable&&shipToDifferentAddress):!isEmpty(errors)||isEmpty(billing_address);if(isEmpty(errors)&&!isEmpty(billing_address))if(invertAddresses)billingDisable=!!(billing_address&&fieldsExist(billing_address));else{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}export function shippingAddressController({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId,invertAddresses=!1,requiresBillingInfo=!1}){let shippingDisable=invertAddresses?!isEmpty(errors)||isEmpty(shipping_address):!!(!billingDisable&&shipToDifferentAddress);if(isEmpty(errors)&&!isEmpty(shipping_address))if(invertAddresses){let billingInfo=[...addressFields];requiresBillingInfo&&(billingInfo=[...billingInfo,"billing_info"]),shippingDisable=!!(shipping_address&&fieldsExist(shipping_address,billingInfo))}else shippingDisable=!!(shipping_address&&fieldsExist(shipping_address));return shippingDisable&&!isEmpty(shippingAddressId)&&isEmpty(shipping_address)&&(shippingDisable=!1),shippingDisable}export function countryLockController({addresses,billing_address,billingAddressId,countryCodeLock,shipToDifferentAddress,shipping_address,shippingAddressId,lineItems}){if(lineItems?.filter(lineItem=>lineItem?.item?.type!=null&&["skus","bundles"].includes(lineItem?.item?.type))?.every(lineItem=>lineItem?.item?.do_not_ship===!0))return!1;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}export async function invertedAddressesHandler({order,billingAddress,billingAddressId,customerEmail,shipToDifferentAddress,shippingAddress,shippingAddressId,sdk}){const currentShippingAddressRef=order?.shipping_address?.reference,orderAttributes={id:order?.id,_billing_address_clone_id:shippingAddressId,_shipping_address_clone_id:shippingAddressId,customer_email:customerEmail};if(currentShippingAddressRef===billingAddressId&&(orderAttributes._billing_address_clone_id=order?.billing_address?.id,orderAttributes._shipping_address_clone_id=order?.shipping_address?.id),shippingAddress!=null&&Object.keys(shippingAddress).length>0){delete orderAttributes._billing_address_clone_id,delete orderAttributes._shipping_address_clone_id,orderAttributes._billing_address_same_as_shipping=!0;const hasMetadata=Object.keys(shippingAddress).filter(key=>!!key.startsWith("metadata_"));hasMetadata?.length>0&&hasMetadata.forEach(key=>{const metadataKey=key.replace("metadata_","");shippingAddress.metadata={...shippingAddress.metadata||{},[metadataKey]:shippingAddress[key]},delete shippingAddress[key]});const address=await sdk.addresses.create(shippingAddress);orderAttributes.shipping_address=sdk.addresses.relationship(address.id)}if(shipToDifferentAddress&&(delete orderAttributes._billing_address_same_as_shipping,billingAddressId&&(orderAttributes._billing_address_clone_id=billingAddressId),billingAddress!=null&&Object.keys(billingAddress).length>0)){delete orderAttributes._billing_address_clone_id;const hasMetadata=Object.keys(billingAddress).filter(key=>!!key.startsWith("metadata_"));hasMetadata?.length>0&&hasMetadata.forEach(key=>{const metadataKey=key.replace("metadata_","");billingAddress.metadata={...billingAddress.metadata||{},[metadataKey]:billingAddress[key]},delete billingAddress[key]});const address=await sdk.addresses.create(billingAddress);orderAttributes.billing_address=sdk.addresses.relationship(address.id)}return orderAttributes}export function addressesController({billing_address,billingAddressId,shipToDifferentAddress,shipping_address,shippingAddressId,errors,requiresBillingInfo,invertAddresses}){if(invertAddresses){const shippingDisable2=shippingAddressController({errors,shipToDifferentAddress,shipping_address,shippingAddressId,invertAddresses}),billingDisable2=billingAddressController({shippingDisable:shippingDisable2,billing_address,billingAddressId,errors,requiresBillingInfo,invertAddresses});return{shippingDisable:shippingDisable2,billingDisable:billingDisable2}}const billingDisable=billingAddressController({billing_address,billingAddressId,errors,requiresBillingInfo}),shippingDisable=shippingAddressController({billingDisable,errors,shipToDifferentAddress,shipping_address,shippingAddressId});return{billingDisable,shippingDisable}}
|