@commercelayer/react-components 3.0.0-beta.8 → 3.1.0
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/README.md +1 -1
- package/{dist → lib}/components/AddToCartButton.d.ts +20 -17
- package/lib/components/AddToCartButton.js +1 -0
- package/{dist → lib}/components/Address.d.ts +13 -12
- package/lib/components/Address.js +1 -0
- package/{dist → lib}/components/AddressCountrySelector.d.ts +9 -9
- package/lib/components/AddressCountrySelector.js +1 -0
- package/{dist → lib}/components/AddressField.d.ts +15 -15
- package/lib/components/AddressField.js +1 -0
- package/{dist → lib}/components/AddressInput.d.ts +7 -7
- package/lib/components/AddressInput.js +1 -0
- package/{dist → lib}/components/AddressStateSelector.d.ts +11 -9
- package/lib/components/AddressStateSelector.js +1 -0
- package/{dist → lib}/components/AddressesContainer.d.ts +8 -7
- package/lib/components/AddressesContainer.js +1 -0
- package/lib/components/AdjustmentAmount.d.ts +4 -0
- package/lib/components/AdjustmentAmount.js +1 -0
- package/lib/components/AdyenPayment.d.ts +25 -0
- package/lib/components/AdyenPayment.js +1 -0
- package/{dist → lib}/components/AvailabilityContainer.d.ts +7 -7
- package/lib/components/AvailabilityContainer.js +1 -0
- package/{dist → lib}/components/AvailabilityTemplate.d.ts +15 -16
- package/lib/components/AvailabilityTemplate.js +1 -0
- package/{dist → lib}/components/BillingAddressContainer.d.ts +6 -6
- package/lib/components/BillingAddressContainer.js +1 -0
- package/{dist → lib}/components/BillingAddressForm.d.ts +8 -8
- package/lib/components/BillingAddressForm.js +1 -0
- package/{dist → lib}/components/BraintreePayment.d.ts +30 -30
- package/lib/components/BraintreePayment.js +1 -0
- package/{dist → lib}/components/CheckoutLink.d.ts +11 -11
- package/lib/components/CheckoutLink.js +1 -0
- package/{dist → lib}/components/CommerceLayer.d.ts +8 -9
- package/lib/components/CommerceLayer.js +1 -0
- package/{dist → lib}/components/CustomerContainer.d.ts +7 -7
- package/lib/components/CustomerContainer.js +1 -0
- package/{dist → lib}/components/CustomerInput.d.ts +11 -11
- package/lib/components/CustomerInput.js +1 -0
- package/{dist → lib}/components/DeliveryLeadTime.d.ts +10 -10
- package/lib/components/DeliveryLeadTime.js +1 -0
- package/{dist → lib}/components/DiscountAmount.d.ts +4 -4
- package/lib/components/DiscountAmount.js +1 -0
- package/{dist → lib}/components/Errors.d.ts +5 -5
- package/lib/components/Errors.js +1 -0
- package/{dist → lib}/components/ExternalFunction.d.ts +7 -7
- package/lib/components/ExternalFunction.js +1 -0
- package/{dist → lib}/components/GiftCard.d.ts +8 -8
- package/lib/components/GiftCard.js +1 -0
- package/{dist → lib}/components/GiftCardAmount.d.ts +4 -4
- package/lib/components/GiftCardAmount.js +1 -0
- package/{dist → lib}/components/GiftCardContainer.d.ts +6 -6
- package/lib/components/GiftCardContainer.js +1 -0
- package/{dist → lib}/components/GiftCardCurrencySelector.d.ts +7 -7
- package/lib/components/GiftCardCurrencySelector.js +1 -0
- package/{dist → lib}/components/GiftCardInput.d.ts +7 -7
- package/lib/components/GiftCardInput.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponCode.d.ts +13 -13
- package/lib/components/GiftCardOrCouponCode.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponForm.d.ts +10 -10
- package/lib/components/GiftCardOrCouponForm.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponInput.d.ts +8 -8
- package/lib/components/GiftCardOrCouponInput.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponRemoveButton.d.ts +16 -16
- package/lib/components/GiftCardOrCouponRemoveButton.js +1 -0
- package/{dist → lib}/components/GiftCardOrCouponSubmit.d.ts +9 -9
- package/lib/components/GiftCardOrCouponSubmit.js +1 -0
- package/{dist → lib}/components/GiftCardRecipient.d.ts +0 -0
- package/lib/components/GiftCardRecipient.js +1 -0
- package/{dist → lib}/components/GiftCardRecipientInput.d.ts +0 -0
- package/lib/components/GiftCardRecipientInput.js +1 -0
- package/{dist → lib}/components/ItemContainer.d.ts +11 -11
- package/lib/components/ItemContainer.js +1 -0
- package/{dist → lib}/components/LineItem.d.ts +8 -8
- package/lib/components/LineItem.js +1 -0
- package/{dist → lib}/components/LineItemAmount.d.ts +7 -7
- package/lib/components/LineItemAmount.js +1 -0
- package/lib/components/LineItemCode.d.ts +12 -0
- package/lib/components/LineItemCode.js +1 -0
- package/lib/components/LineItemImage.d.ts +16 -0
- package/lib/components/LineItemImage.js +1 -0
- package/lib/components/LineItemName.d.ts +11 -0
- package/lib/components/LineItemName.js +1 -0
- package/{dist → lib}/components/LineItemOption.d.ts +19 -19
- package/lib/components/LineItemOption.js +1 -0
- package/{dist → lib}/components/LineItemOptions.d.ts +14 -14
- package/lib/components/LineItemOptions.js +1 -0
- package/{dist → lib}/components/LineItemQuantity.d.ts +14 -14
- package/lib/components/LineItemQuantity.js +1 -0
- package/{dist → lib}/components/LineItemRemoveLink.d.ts +12 -12
- package/lib/components/LineItemRemoveLink.js +1 -0
- package/{dist → lib}/components/LineItemsContainer.d.ts +8 -8
- package/lib/components/LineItemsContainer.js +1 -0
- package/{dist → lib}/components/LineItemsCount.d.ts +12 -10
- package/lib/components/LineItemsCount.js +1 -0
- package/lib/components/LineItemsEmpty.d.ts +12 -0
- package/lib/components/LineItemsEmpty.js +1 -0
- package/{dist → lib}/components/MetadataInput.d.ts +5 -5
- package/lib/components/MetadataInput.js +1 -0
- package/{dist → lib}/components/OrderContainer.d.ts +11 -10
- package/lib/components/OrderContainer.js +1 -0
- package/{dist → lib}/components/OrderNumber.d.ts +5 -5
- package/lib/components/OrderNumber.js +1 -0
- package/{dist → lib}/components/OrderStorage.d.ts +8 -8
- package/lib/components/OrderStorage.js +1 -0
- package/lib/components/PaymentGateway.d.ts +16 -0
- package/lib/components/PaymentGateway.js +1 -0
- package/{dist → lib}/components/PaymentMethod.d.ts +16 -16
- package/lib/components/PaymentMethod.js +1 -0
- package/{dist → lib}/components/PaymentMethodAmount.d.ts +4 -4
- package/lib/components/PaymentMethodAmount.js +1 -0
- package/{dist → lib}/components/PaymentMethodName.d.ts +9 -9
- package/lib/components/PaymentMethodName.js +1 -0
- package/{dist → lib}/components/PaymentMethodPrice.d.ts +9 -9
- package/lib/components/PaymentMethodPrice.js +1 -0
- package/{dist → lib}/components/PaymentMethodRadioButton.d.ts +11 -11
- package/lib/components/PaymentMethodRadioButton.js +1 -0
- package/{dist → lib}/components/PaymentMethodsContainer.d.ts +8 -8
- package/lib/components/PaymentMethodsContainer.js +1 -0
- package/{dist → lib}/components/PaymentSource.d.ts +19 -18
- package/lib/components/PaymentSource.js +1 -0
- package/{dist → lib}/components/PaymentSourceBrandIcon.d.ts +15 -15
- package/lib/components/PaymentSourceBrandIcon.js +1 -0
- package/{dist → lib}/components/PaymentSourceBrandName.d.ts +12 -12
- package/lib/components/PaymentSourceBrandName.js +1 -0
- package/{dist → lib}/components/PaymentSourceDetail.d.ts +12 -12
- package/lib/components/PaymentSourceDetail.js +1 -0
- package/{dist → lib}/components/PaymentSourceEditButton.d.ts +9 -9
- package/lib/components/PaymentSourceEditButton.js +1 -0
- package/{dist → lib}/components/PaypalPayment.d.ts +12 -12
- package/lib/components/PaypalPayment.js +1 -0
- package/{dist → lib}/components/PlaceOrderButton.d.ts +12 -12
- package/lib/components/PlaceOrderButton.js +1 -0
- package/{dist → lib}/components/PlaceOrderContainer.d.ts +8 -8
- package/lib/components/PlaceOrderContainer.js +1 -0
- package/{dist → lib}/components/Price.d.ts +16 -14
- package/lib/components/Price.js +1 -0
- package/{dist → lib}/components/PricesContainer.d.ts +11 -11
- package/lib/components/PricesContainer.js +1 -0
- package/{dist → lib}/components/PrivacyAndTermsCheckbox.d.ts +4 -4
- package/lib/components/PrivacyAndTermsCheckbox.js +1 -0
- package/{dist → lib}/components/QuantitySelector.d.ts +17 -17
- package/lib/components/QuantitySelector.js +1 -0
- package/{dist → lib}/components/SaveAddressesButton.d.ts +10 -10
- package/lib/components/SaveAddressesButton.js +1 -0
- package/{dist → lib}/components/SaveCustomerButton.d.ts +13 -13
- package/lib/components/SaveCustomerButton.js +1 -0
- package/{dist → lib}/components/Shipment.d.ts +8 -8
- package/lib/components/Shipment.js +1 -0
- package/{dist → lib}/components/ShipmentField.d.ts +12 -12
- package/lib/components/ShipmentField.js +1 -0
- package/{dist → lib}/components/ShipmentsContainer.d.ts +6 -6
- package/lib/components/ShipmentsContainer.js +1 -0
- package/{dist → lib}/components/ShippingAddressContainer.d.ts +6 -6
- package/lib/components/ShippingAddressContainer.js +1 -0
- package/{dist → lib}/components/ShippingAddressForm.d.ts +8 -8
- package/lib/components/ShippingAddressForm.js +1 -0
- package/{dist → lib}/components/ShippingAmount.d.ts +4 -4
- package/lib/components/ShippingAmount.js +1 -0
- package/{dist → lib}/components/ShippingMethod.d.ts +8 -8
- package/lib/components/ShippingMethod.js +1 -0
- package/{dist → lib}/components/ShippingMethodName.d.ts +11 -7
- package/lib/components/ShippingMethodName.js +1 -0
- package/{dist → lib}/components/ShippingMethodPrice.d.ts +13 -13
- package/lib/components/ShippingMethodPrice.js +1 -0
- package/lib/components/ShippingMethodRadioButton.d.ts +13 -0
- package/lib/components/ShippingMethodRadioButton.js +1 -0
- package/{dist → lib}/components/SkuList.d.ts +7 -7
- package/lib/components/SkuList.js +1 -0
- package/{dist → lib}/components/SkuListsContainer.d.ts +6 -6
- package/lib/components/SkuListsContainer.js +1 -0
- package/{dist → lib}/components/SkuOption.d.ts +7 -7
- package/lib/components/SkuOption.js +1 -0
- package/{dist → lib}/components/SkuOptionInput.d.ts +5 -5
- package/lib/components/SkuOptionInput.js +1 -0
- package/{dist → lib}/components/SkuOptionsContainer.d.ts +7 -7
- package/lib/components/SkuOptionsContainer.js +1 -0
- package/{dist → lib}/components/StockTransfer.d.ts +6 -6
- package/lib/components/StockTransfer.js +1 -0
- package/{dist → lib}/components/StockTransferField.d.ts +9 -9
- package/lib/components/StockTransferField.js +1 -0
- package/{dist → lib}/components/StripePayment.d.ts +18 -18
- package/lib/components/StripePayment.js +1 -0
- package/{dist → lib}/components/SubTotalAmount.d.ts +4 -4
- package/lib/components/SubTotalAmount.js +1 -0
- package/{dist → lib}/components/SubmitButton.d.ts +9 -9
- package/lib/components/SubmitButton.js +1 -0
- package/{dist → lib}/components/TaxesAmount.d.ts +4 -4
- package/lib/components/TaxesAmount.js +1 -0
- package/{dist → lib}/components/TotalAmount.d.ts +4 -4
- package/lib/components/TotalAmount.js +1 -0
- package/{dist → lib}/components/VariantSelector.d.ts +29 -27
- package/lib/components/VariantSelector.js +1 -0
- package/{dist → lib}/components/VariantsContainer.d.ts +8 -8
- package/lib/components/VariantsContainer.js +1 -0
- package/{dist → lib}/components/WireTransferPayment.d.ts +10 -10
- package/lib/components/WireTransferPayment.js +1 -0
- package/lib/components/gateways/AdyenGateway.d.ts +5 -0
- package/lib/components/gateways/AdyenGateway.js +1 -0
- package/lib/components/gateways/BraintreeGateway.d.ts +5 -0
- package/lib/components/gateways/BraintreeGateway.js +1 -0
- package/lib/components/gateways/PaypalGateway.d.ts +5 -0
- package/lib/components/gateways/PaypalGateway.js +1 -0
- package/lib/components/gateways/StripeGateway.d.ts +5 -0
- package/lib/components/gateways/StripeGateway.js +1 -0
- package/lib/components/gateways/WireTransferGateway.d.ts +5 -0
- package/lib/components/gateways/WireTransferGateway.js +1 -0
- package/lib/components/utils/AddressCardsTemplate.d.ts +27 -0
- package/lib/components/utils/AddressCardsTemplate.js +1 -0
- package/{dist → lib}/components/utils/BaseField.d.ts +8 -8
- package/lib/components/utils/BaseField.js +1 -0
- package/lib/components/utils/BaseInput.d.ts +5 -0
- package/lib/components/utils/BaseInput.js +1 -0
- package/{dist → lib}/components/utils/BaseOrderPrice.d.ts +6 -6
- package/lib/components/utils/BaseOrderPrice.js +1 -0
- package/{dist → lib}/components/utils/BaseSelect.d.ts +5 -5
- package/lib/components/utils/BaseSelect.js +1 -0
- package/{dist → lib}/components/utils/Parent.d.ts +8 -8
- package/lib/components/utils/Parent.js +1 -0
- package/lib/components/utils/PaymentCardsTemplate.d.ts +23 -0
- package/lib/components/utils/PaymentCardsTemplate.js +1 -0
- package/{dist → lib}/components/utils/PriceTemplate.d.ts +8 -8
- package/lib/components/utils/PriceTemplate.js +1 -0
- package/{dist → lib}/components/utils/VariantTemplate.d.ts +36 -34
- package/lib/components/utils/VariantTemplate.js +1 -0
- package/{dist → lib}/components/utils/getAllErrors.d.ts +17 -17
- package/lib/components/utils/getAllErrors.js +1 -0
- package/{dist → lib}/config/components.d.ts +892 -881
- package/lib/config/components.js +1 -0
- package/lib/config/currency.d.ts +5 -0
- package/lib/config/currency.js +1 -0
- package/{dist → lib}/context/AddressChildrenContext.d.ts +7 -7
- package/lib/context/AddressChildrenContext.js +1 -0
- package/{dist → lib}/context/AddressContext.d.ts +17 -17
- package/lib/context/AddressContext.js +1 -0
- package/{dist → lib}/context/AvailabilityContext.d.ts +3 -3
- package/lib/context/AvailabilityContext.js +1 -0
- package/{dist → lib}/context/BillingAddressContext.d.ts +12 -12
- package/lib/context/BillingAddressContext.js +1 -0
- package/{dist → lib}/context/BillingAddressFormContext.d.ts +19 -18
- package/lib/context/BillingAddressFormContext.js +1 -0
- package/{dist → lib}/context/CommerceLayerContext.d.ts +7 -8
- package/lib/context/CommerceLayerContext.js +1 -0
- package/{dist → lib}/context/CouponAndGiftCardFormContext.d.ts +7 -7
- package/lib/context/CouponAndGiftCardFormContext.js +1 -0
- package/{dist → lib}/context/CustomerContext.d.ts +16 -14
- package/lib/context/CustomerContext.js +1 -0
- package/{dist → lib}/context/ExternalFunctionContext.d.ts +12 -12
- package/lib/context/ExternalFunctionContext.js +1 -0
- package/{dist → lib}/context/GiftCardContext.d.ts +11 -11
- package/lib/context/GiftCardContext.js +1 -0
- package/{dist → lib}/context/ItemContext.d.ts +13 -13
- package/lib/context/ItemContext.js +1 -0
- package/lib/context/LineItemChildrenContext.d.ts +9 -0
- package/lib/context/LineItemChildrenContext.js +1 -0
- package/{dist → lib}/context/LineItemContext.d.ts +8 -8
- package/lib/context/LineItemContext.js +1 -0
- package/{dist → lib}/context/LineItemOptionChildrenContext.d.ts +8 -8
- package/lib/context/LineItemOptionChildrenContext.js +1 -0
- package/lib/context/OrderContext.d.ts +26 -0
- package/lib/context/OrderContext.js +1 -0
- package/{dist → lib}/context/OrderStorageContext.d.ts +11 -11
- package/lib/context/OrderStorageContext.js +1 -0
- package/{dist → lib}/context/PaymentMethodChildrenContext.d.ts +10 -10
- package/lib/context/PaymentMethodChildrenContext.js +1 -0
- package/{dist → lib}/context/PaymentMethodContext.d.ts +23 -20
- package/lib/context/PaymentMethodContext.js +1 -0
- package/{dist → lib}/context/PaymentSourceContext.d.ts +14 -14
- package/lib/context/PaymentSourceContext.js +1 -0
- package/{dist → lib}/context/PlaceOrderContext.d.ts +16 -16
- package/lib/context/PlaceOrderContext.js +1 -0
- package/{dist → lib}/context/PricesContext.d.ts +7 -7
- package/lib/context/PricesContext.js +1 -0
- package/lib/context/ShipmentChildrenContext.d.ts +13 -0
- package/lib/context/ShipmentChildrenContext.js +1 -0
- package/{dist → lib}/context/ShipmentContext.d.ts +12 -12
- package/lib/context/ShipmentContext.js +1 -0
- package/{dist → lib}/context/ShippingAddressContext.d.ts +10 -10
- package/lib/context/ShippingAddressContext.js +1 -0
- package/{dist → lib}/context/ShippingAddressFormContext.d.ts +4 -4
- package/lib/context/ShippingAddressFormContext.js +1 -0
- package/lib/context/ShippingMethodChildrenContext.d.ts +10 -0
- package/lib/context/ShippingMethodChildrenContext.js +1 -0
- package/lib/context/SkuListsContext.d.ts +6 -0
- package/lib/context/SkuListsContext.js +1 -0
- package/{dist → lib}/context/SkuOptionChildrenContext.d.ts +8 -8
- package/lib/context/SkuOptionChildrenContext.js +1 -0
- package/{dist → lib}/context/SkuOptionsContext.d.ts +3 -3
- package/lib/context/SkuOptionsContext.js +1 -0
- package/{dist → lib}/context/StockTransferChildrenContext.d.ts +7 -7
- package/lib/context/StockTransferChildrenContext.js +1 -0
- package/{dist → lib}/context/VariantsContext.d.ts +3 -3
- package/lib/context/VariantsContext.js +1 -0
- package/lib/index.d.ts +99 -0
- package/lib/index.js +1 -0
- package/{dist → lib}/reducers/AddressReducer.d.ts +59 -57
- package/lib/reducers/AddressReducer.js +1 -0
- package/lib/reducers/AvailabilityReducer.d.ts +53 -0
- package/lib/reducers/AvailabilityReducer.js +1 -0
- package/{dist → lib}/reducers/BillingAddressReducer.d.ts +31 -32
- package/lib/reducers/BillingAddressReducer.js +1 -0
- package/{dist → lib}/reducers/CustomerReducer.d.ts +50 -60
- package/lib/reducers/CustomerReducer.js +1 -0
- package/{dist → lib}/reducers/GiftCardReducer.d.ts +76 -75
- package/lib/reducers/GiftCardReducer.js +1 -0
- package/{dist → lib}/reducers/ItemReducer.d.ts +69 -68
- package/lib/reducers/ItemReducer.js +1 -0
- package/{dist → lib}/reducers/LineItemReducer.d.ts +52 -52
- package/lib/reducers/LineItemReducer.js +1 -0
- package/lib/reducers/OrderReducer.d.ts +133 -0
- package/lib/reducers/OrderReducer.js +1 -0
- package/{dist → lib}/reducers/PaymentMethodReducer.d.ts +105 -95
- package/lib/reducers/PaymentMethodReducer.js +1 -0
- package/{dist → lib}/reducers/PlaceOrderReducer.d.ts +52 -50
- package/lib/reducers/PlaceOrderReducer.js +1 -0
- package/{dist → lib}/reducers/PriceReducer.d.ts +44 -45
- package/lib/reducers/PriceReducer.js +1 -0
- package/{dist → lib}/reducers/ShipmentReducer.d.ts +40 -37
- package/lib/reducers/ShipmentReducer.js +1 -0
- package/{dist → lib}/reducers/ShippingAddressReducer.d.ts +32 -31
- package/lib/reducers/ShippingAddressReducer.js +1 -0
- package/{dist → lib}/reducers/SkuListsReducer.d.ts +21 -22
- package/lib/reducers/SkuListsReducer.js +1 -0
- package/{dist → lib}/reducers/SkuOptionsReducer.d.ts +26 -26
- package/lib/reducers/SkuOptionsReducer.js +1 -0
- package/{dist → lib}/reducers/VariantReducer.d.ts +71 -71
- package/lib/reducers/VariantReducer.js +1 -0
- package/{dist → lib}/typings/errors.d.ts +42 -40
- package/lib/typings/errors.js +1 -0
- package/{dist → lib}/typings/index.d.ts +126 -151
- package/lib/typings/index.js +1 -0
- package/{dist → lib}/utils/PropsType.d.ts +33 -33
- package/lib/utils/PropsType.js +1 -0
- package/{dist → lib}/utils/addressesManager.d.ts +28 -27
- package/lib/utils/addressesManager.js +1 -0
- package/{dist → lib}/utils/baseReducer.d.ts +3 -3
- package/lib/utils/baseReducer.js +1 -0
- package/lib/utils/browserInfo.d.ts +9 -0
- package/lib/utils/browserInfo.js +1 -0
- package/{dist → lib}/utils/childrenTypes.d.ts +9 -9
- package/lib/utils/childrenTypes.js +1 -0
- package/lib/utils/countryStateCity.d.ts +9 -0
- package/lib/utils/countryStateCity.js +1 -0
- package/{dist → lib}/utils/customMessages.d.ts +8 -8
- package/lib/utils/customMessages.js +1 -0
- package/lib/utils/customerOrderOptions.d.ts +3 -0
- package/lib/utils/customerOrderOptions.js +1 -0
- package/{dist → lib}/utils/getAmount.d.ts +9 -9
- package/lib/utils/getAmount.js +1 -0
- package/{dist → lib}/utils/getCurrentItemKey.d.ts +6 -6
- package/lib/utils/getCurrentItemKey.js +1 -0
- package/lib/utils/getErrors.d.ts +11 -0
- package/lib/utils/getErrors.js +1 -0
- package/lib/utils/getLineItemsCount.d.ts +12 -0
- package/lib/utils/getLineItemsCount.js +1 -0
- package/{dist → lib}/utils/getLoaderComponent.d.ts +3 -3
- package/lib/utils/getLoaderComponent.js +1 -0
- package/lib/utils/getPrices.d.ts +17 -0
- package/lib/utils/getPrices.js +1 -0
- package/lib/utils/getSdk.d.ts +3 -0
- package/lib/utils/getSdk.js +1 -0
- package/lib/utils/getSkus.d.ts +3 -0
- package/lib/utils/getSkus.js +1 -0
- package/{dist → lib}/utils/isEmptyStates.d.ts +1 -1
- package/lib/utils/isEmptyStates.js +1 -0
- package/{dist → lib}/utils/isJSON.d.ts +1 -1
- package/lib/utils/isJSON.js +1 -0
- package/lib/utils/jwt.d.ts +27 -0
- package/lib/utils/jwt.js +1 -0
- package/{dist → lib}/utils/localStorage.d.ts +17 -18
- package/lib/utils/localStorage.js +1 -0
- package/lib/utils/organization.d.ts +6 -0
- package/lib/utils/organization.js +1 -0
- package/lib/utils/paypalPayment.d.ts +3 -0
- package/lib/utils/paypalPayment.js +1 -0
- package/{dist → lib}/utils/promisify.d.ts +1 -1
- package/lib/utils/promisify.js +1 -0
- package/lib/utils/shipments.d.ts +2 -0
- package/lib/utils/shipments.js +1 -0
- package/{dist → lib}/utils/validateFormFields.d.ts +22 -19
- package/lib/utils/validateFormFields.js +1 -0
- package/package.json +98 -84
- package/dist/components/CustomerField.d.ts +0 -10
- package/dist/components/LineItemImage.d.ts +0 -10
- package/dist/components/LineItemName.d.ts +0 -7
- package/dist/components/LineItemSkuCode.d.ts +0 -7
- package/dist/components/OrderList.d.ts +0 -28
- package/dist/components/OrderListRow.d.ts +0 -14
- package/dist/components/PaymentGateway.d.ts +0 -11
- package/dist/components/ShippingMethodRadioButton.d.ts +0 -9
- package/dist/components/utils/BaseInput.d.ts +0 -5
- package/dist/context/LineItemChildrenContext.d.ts +0 -7
- package/dist/context/OrderContext.d.ts +0 -4
- package/dist/context/OrderListChildrenContext.d.ts +0 -14
- package/dist/context/ShipmentChildrenContext.d.ts +0 -13
- package/dist/context/ShippingMethodChildrenContext.d.ts +0 -9
- package/dist/context/SkuListsContext.d.ts +0 -3
- package/dist/index.d.ts +0 -90
- package/dist/index.js +0 -8
- package/dist/react-components.cjs.development.js +0 -12429
- package/dist/react-components.cjs.development.js.map +0 -1
- package/dist/react-components.cjs.production.min.js +0 -2
- package/dist/react-components.cjs.production.min.js.map +0 -1
- package/dist/react-components.esm.js +0 -12332
- package/dist/react-components.esm.js.map +0 -1
- package/dist/reducers/AvailabilityReducer.d.ts +0 -40
- package/dist/reducers/OrderReducer.d.ts +0 -131
- package/dist/typings/order.d.ts +0 -120
- package/dist/utils/countryStateCity.d.ts +0 -9
- package/dist/utils/customerOrderOptions.d.ts +0 -4
- package/dist/utils/dynamicNaming.d.ts +0 -5
- package/dist/utils/getErrorsByCollection.d.ts +0 -11
- package/dist/utils/getLineItemsCount.d.ts +0 -6
- package/dist/utils/getPrices.d.ts +0 -18
- package/dist/utils/getSkus.d.ts +0 -3
- package/dist/utils/icons.d.ts +0 -3
- package/dist/utils/isDate.d.ts +0 -1
- package/dist/utils/paypalPayment.d.ts +0 -3
- package/dist/utils/scrollbarWidth.d.ts +0 -1
- package/dist/utils/shipments.d.ts +0 -5
|
@@ -1,60 +1,50 @@
|
|
|
1
|
-
import { Dispatch } from 'react';
|
|
2
|
-
import { BaseError } from
|
|
3
|
-
import {
|
|
4
|
-
import { CommerceLayerConfig } from
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
export declare type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
export declare const
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export declare
|
|
43
|
-
|
|
44
|
-
dispatch: Dispatch<CustomerAction>;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export declare
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}) => Promise<void>;
|
|
52
|
-
export declare const getCustomerPaymentSources: GetCustomerPaymentSources;
|
|
53
|
-
export declare type GetCustomerOrders = (params: {
|
|
54
|
-
config: CommerceLayerConfig;
|
|
55
|
-
dispatch: Dispatch<CustomerAction>;
|
|
56
|
-
}) => Promise<void>;
|
|
57
|
-
export declare const getCustomerOrders: GetCustomerOrders;
|
|
58
|
-
export declare const customerInitialState: CustomerState;
|
|
59
|
-
declare const customerReducer: (state: CustomerState, reducer: CustomerAction) => CustomerState;
|
|
60
|
-
export default customerReducer;
|
|
1
|
+
import { Dispatch } from 'react';
|
|
2
|
+
import { BaseError } from '../typings/errors';
|
|
3
|
+
import { Address, CustomerPaymentSource, Order } from '@commercelayer/sdk';
|
|
4
|
+
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
5
|
+
import { updateOrder } from './OrderReducer';
|
|
6
|
+
export declare type CustomerActionType = 'setErrors' | 'setCustomerEmail' | 'setAddresses' | 'setPayments';
|
|
7
|
+
export interface CustomerActionPayload {
|
|
8
|
+
addresses: Address[];
|
|
9
|
+
payments: CustomerPaymentSource[];
|
|
10
|
+
customerEmail: string;
|
|
11
|
+
errors: BaseError[];
|
|
12
|
+
isGuest: boolean;
|
|
13
|
+
getCustomerPaymentSources: () => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare type CustomerState = Partial<CustomerActionPayload>;
|
|
16
|
+
export interface CustomerAction {
|
|
17
|
+
type: CustomerActionType;
|
|
18
|
+
payload: Partial<CustomerActionPayload>;
|
|
19
|
+
}
|
|
20
|
+
export declare type SetSaveOnBlur = (args: {
|
|
21
|
+
saveOnBlur: boolean;
|
|
22
|
+
dispatch: Dispatch<CustomerAction>;
|
|
23
|
+
}) => void;
|
|
24
|
+
export declare type SaveCustomerUser = (args: {
|
|
25
|
+
config: CommerceLayerConfig;
|
|
26
|
+
customerEmail: string;
|
|
27
|
+
dispatch: Dispatch<CustomerAction>;
|
|
28
|
+
order?: Order;
|
|
29
|
+
updateOrder: typeof updateOrder;
|
|
30
|
+
}) => void;
|
|
31
|
+
export declare const saveCustomerUser: SaveCustomerUser;
|
|
32
|
+
export interface SetCustomerErrors {
|
|
33
|
+
<V extends BaseError[]>(errors: V, dispatch?: Dispatch<CustomerAction>): void;
|
|
34
|
+
}
|
|
35
|
+
export declare const setCustomerErrors: SetCustomerErrors;
|
|
36
|
+
export declare type SetCustomerEmail = (customerEmail: string, dispatch?: Dispatch<CustomerAction>) => void;
|
|
37
|
+
export declare const setCustomerEmail: SetCustomerEmail;
|
|
38
|
+
export declare type GetCustomerAddresses = (params: {
|
|
39
|
+
config: CommerceLayerConfig;
|
|
40
|
+
dispatch: Dispatch<CustomerAction>;
|
|
41
|
+
}) => Promise<void>;
|
|
42
|
+
export declare const getCustomerAddresses: GetCustomerAddresses;
|
|
43
|
+
export declare type GetCustomerPaymentSources = (params: {
|
|
44
|
+
dispatch: Dispatch<CustomerAction>;
|
|
45
|
+
order?: Order;
|
|
46
|
+
}) => Promise<void>;
|
|
47
|
+
export declare const getCustomerPaymentSources: GetCustomerPaymentSources;
|
|
48
|
+
export declare const customerInitialState: CustomerState;
|
|
49
|
+
declare const customerReducer: (state: CustomerState, reducer: CustomerAction) => CustomerState;
|
|
50
|
+
export default customerReducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";import getErrors from"../utils/getErrors";export const saveCustomerUser=async({customerEmail,order,updateOrder})=>{if(order){const attributes={customer_email:customerEmail,id:order.id};await updateOrder({id:order.id,attributes})}},setCustomerErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},setCustomerEmail=(customerEmail,dispatch)=>{dispatch&&dispatch({type:"setCustomerEmail",payload:{customerEmail}})},getCustomerAddresses=async({config,dispatch})=>{try{const addresses=[];(await getSdk(config).customer_addresses.list({include:["address"]})).forEach(customerAddress=>{customerAddress.address&&addresses.push(customerAddress.address)}),dispatch({type:"setAddresses",payload:{addresses}})}catch(error){const errors=getErrors(error,"addresses");dispatch({type:"setErrors",payload:{errors}})}},getCustomerPaymentSources=async({dispatch,order})=>{(order==null?void 0:order.available_customer_payment_sources)&&dispatch({type:"setPayments",payload:{payments:order.available_customer_payment_sources}})},customerInitialState={errors:[],addresses:[],payments:[]};const type=["setErrors","setCustomerEmail","setAddresses","setPayments"],customerReducer=(state,reducer)=>baseReducer(state,reducer,type);export default customerReducer;
|
|
@@ -1,75 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseMetadata } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export declare type GiftCardActionType = 'setAvailability' | 'setGiftCardRecipient' | 'setGiftCardErrors' | 'setGiftCardLoading';
|
|
8
|
-
export interface GiftCardRecipientI {
|
|
9
|
-
email: string;
|
|
10
|
-
firstName?: string;
|
|
11
|
-
lastName?: string;
|
|
12
|
-
referenceOrigin?: string;
|
|
13
|
-
reference?: string;
|
|
14
|
-
metadata?: BaseMetadata;
|
|
15
|
-
customer?:
|
|
16
|
-
}
|
|
17
|
-
export interface GiftCardI {
|
|
18
|
-
currencyCode?: string;
|
|
19
|
-
balanceCent?: number;
|
|
20
|
-
balanceMaxCents?: number;
|
|
21
|
-
singleUse?: boolean;
|
|
22
|
-
rechargeable?: boolean;
|
|
23
|
-
imageUrl?: string;
|
|
24
|
-
expiresAt?: null | Date;
|
|
25
|
-
firstName?: string;
|
|
26
|
-
lastName?: string;
|
|
27
|
-
email?: string;
|
|
28
|
-
referenceOrigin?: string;
|
|
29
|
-
recipientEmail?: string;
|
|
30
|
-
reference?: string;
|
|
31
|
-
metadata?: BaseMetadata;
|
|
32
|
-
orderId?: string;
|
|
33
|
-
}
|
|
34
|
-
export interface GiftCardActionPayload extends GiftCardI {
|
|
35
|
-
market?:
|
|
36
|
-
giftCardRecipient?:
|
|
37
|
-
errors?: BaseError[];
|
|
38
|
-
loading?: boolean;
|
|
39
|
-
}
|
|
40
|
-
export interface GiftCardState extends GiftCardActionPayload {
|
|
41
|
-
currencyCode: string;
|
|
42
|
-
balanceCent: number;
|
|
43
|
-
addGiftCardRecipient?: (values: GiftCardRecipientI & Record<string, any>) => void;
|
|
44
|
-
addGiftCard?: (values: GiftCardI & Record<string, any>) => void;
|
|
45
|
-
addGiftCardError?: (errors: BaseError[]) => void;
|
|
46
|
-
addGiftCardLoading?: (loading: boolean) => void;
|
|
47
|
-
}
|
|
48
|
-
export interface GiftCardAction {
|
|
49
|
-
type: GiftCardActionType;
|
|
50
|
-
payload: GiftCardActionPayload;
|
|
51
|
-
}
|
|
52
|
-
export declare const giftCardInitialState: GiftCardState;
|
|
53
|
-
export interface AddGiftCardRecipient {
|
|
54
|
-
<V extends
|
|
55
|
-
}
|
|
56
|
-
export interface AddGiftCard {
|
|
57
|
-
<V extends GiftCardI>(values: V, configParameters: {
|
|
58
|
-
getOrder?: (id: string) => void;
|
|
59
|
-
createOrder?:
|
|
60
|
-
config: CommerceLayerConfig;
|
|
61
|
-
dispatch: Dispatch<GiftCardAction>;
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export declare const
|
|
72
|
-
export declare const
|
|
73
|
-
export declare const
|
|
74
|
-
declare const
|
|
75
|
-
|
|
1
|
+
import { Customer, Market, GiftCardRecipient, GiftCardRecipientCreate, Order } from '@commercelayer/sdk';
|
|
2
|
+
import { BaseMetadata } from '../typings/index';
|
|
3
|
+
import { Dispatch } from 'react';
|
|
4
|
+
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
5
|
+
import { BaseError } from '../typings/errors';
|
|
6
|
+
import { CreateOrder } from './OrderReducer';
|
|
7
|
+
export declare type GiftCardActionType = 'setAvailability' | 'setGiftCardRecipient' | 'setGiftCardErrors' | 'setGiftCardLoading';
|
|
8
|
+
export interface GiftCardRecipientI {
|
|
9
|
+
email: string;
|
|
10
|
+
firstName?: string;
|
|
11
|
+
lastName?: string;
|
|
12
|
+
referenceOrigin?: string;
|
|
13
|
+
reference?: string;
|
|
14
|
+
metadata?: BaseMetadata;
|
|
15
|
+
customer?: Customer;
|
|
16
|
+
}
|
|
17
|
+
export interface GiftCardI {
|
|
18
|
+
currencyCode?: string;
|
|
19
|
+
balanceCent?: number;
|
|
20
|
+
balanceMaxCents?: number;
|
|
21
|
+
singleUse?: boolean;
|
|
22
|
+
rechargeable?: boolean;
|
|
23
|
+
imageUrl?: string;
|
|
24
|
+
expiresAt?: null | Date;
|
|
25
|
+
firstName?: string;
|
|
26
|
+
lastName?: string;
|
|
27
|
+
email?: string;
|
|
28
|
+
referenceOrigin?: string;
|
|
29
|
+
recipientEmail?: string;
|
|
30
|
+
reference?: string;
|
|
31
|
+
metadata?: BaseMetadata;
|
|
32
|
+
orderId?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface GiftCardActionPayload extends GiftCardI {
|
|
35
|
+
market?: Market;
|
|
36
|
+
giftCardRecipient?: GiftCardRecipient;
|
|
37
|
+
errors?: BaseError[];
|
|
38
|
+
loading?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface GiftCardState extends GiftCardActionPayload {
|
|
41
|
+
currencyCode: string;
|
|
42
|
+
balanceCent: number;
|
|
43
|
+
addGiftCardRecipient?: (values: GiftCardRecipientI & Record<string, any>) => void;
|
|
44
|
+
addGiftCard?: (values: GiftCardI & Record<string, any>) => void;
|
|
45
|
+
addGiftCardError?: (errors: BaseError[]) => void;
|
|
46
|
+
addGiftCardLoading?: (loading: boolean) => void;
|
|
47
|
+
}
|
|
48
|
+
export interface GiftCardAction {
|
|
49
|
+
type: GiftCardActionType;
|
|
50
|
+
payload: GiftCardActionPayload;
|
|
51
|
+
}
|
|
52
|
+
export declare const giftCardInitialState: GiftCardState;
|
|
53
|
+
export interface AddGiftCardRecipient {
|
|
54
|
+
<V extends GiftCardRecipientCreate>(values: V, config: CommerceLayerConfig, dispatch: Dispatch<GiftCardAction>): void;
|
|
55
|
+
}
|
|
56
|
+
export interface AddGiftCard {
|
|
57
|
+
<V extends GiftCardI>(values: V, configParameters: {
|
|
58
|
+
getOrder?: (id: string) => void;
|
|
59
|
+
createOrder?: CreateOrder;
|
|
60
|
+
config: CommerceLayerConfig;
|
|
61
|
+
dispatch: Dispatch<GiftCardAction>;
|
|
62
|
+
order?: Order;
|
|
63
|
+
}): void;
|
|
64
|
+
}
|
|
65
|
+
export interface AddGiftCardError {
|
|
66
|
+
<V extends BaseError[]>(errors: V, dispatch: Dispatch<GiftCardAction>): void;
|
|
67
|
+
}
|
|
68
|
+
export interface AddGiftCardLoading {
|
|
69
|
+
<V extends boolean>(loading: V, dispatch: Dispatch<GiftCardAction>): void;
|
|
70
|
+
}
|
|
71
|
+
export declare const addGiftCardRecipient: AddGiftCardRecipient;
|
|
72
|
+
export declare const addGiftCardLoading: AddGiftCardLoading;
|
|
73
|
+
export declare const addGiftCard: AddGiftCard;
|
|
74
|
+
export declare const addGiftCardError: AddGiftCardError;
|
|
75
|
+
declare const giftCardReducer: (state: GiftCardState, reducer: GiftCardAction) => GiftCardState;
|
|
76
|
+
export default giftCardReducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest}from"tslib";import baseReducer from"../utils/baseReducer";import{isEmpty}from"lodash";import getErrors from"../utils/getErrors";import getSdk from"../utils/getSdk";export const giftCardInitialState={currencyCode:"",balanceCent:0,singleUse:!1,rechargeable:!0,loading:!1,expiresAt:null,errors:[]},addGiftCardRecipient=async(values,config,dispatch)=>{try{const recipient=await getSdk(config).gift_card_recipients.create(values);dispatch({type:"setGiftCardRecipient",payload:{giftCardRecipient:recipient}})}catch(error){console.error(error)}},addGiftCardLoading=(loading,dispatch)=>{dispatch({type:"setGiftCardLoading",payload:{loading}})},addGiftCard=async(values,{config,dispatch,getOrder,createOrder,order})=>{var _a;try{const sdk=getSdk(config);addGiftCardLoading(!0,dispatch);const{firstName,lastName,email}=values,val=__rest(values,["firstName","lastName","email"]),giftCardValue=Object.assign({recipient_email:email},val),giftCard=await sdk.gift_cards.create(giftCardValue,{include:["gift_card_recipient"]}),recipientValues={id:(_a=giftCard.gift_card_recipient)===null||_a===void 0?void 0:_a.id};if(firstName&&(recipientValues.first_name=firstName),lastName&&(recipientValues.last_name=lastName),isEmpty(recipientValues)||await sdk.gift_card_recipients.update(recipientValues),createOrder&&getOrder){const id=order?order.id:await createOrder();if(id){const order2=sdk.orders.relationship(id),item=sdk.gift_cards.relationship(giftCard.id);await sdk.line_items.create({quantity:1,order:order2,item}),getOrder&&getOrder(id)}}dispatch({type:"setGiftCardRecipient",payload:Object.assign({},giftCardValue)}),addGiftCardLoading(!1,dispatch)}catch(error){const errors=getErrors(error,"gift_cards");dispatch({type:"setGiftCardErrors",payload:{errors}}),addGiftCardLoading(!1,dispatch)}},addGiftCardError=(errors,dispatch)=>{dispatch({type:"setGiftCardErrors",payload:{errors}})};const type=["setAvailability","setGiftCardRecipient","setGiftCardErrors","setGiftCardLoading"],giftCardReducer=(state,reducer)=>baseReducer(state,reducer,type);export default giftCardReducer;
|
|
@@ -1,68 +1,69 @@
|
|
|
1
|
-
import { BaseUnsetState } from
|
|
2
|
-
import {
|
|
3
|
-
import { Dispatch } from 'react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export declare const
|
|
41
|
-
export declare
|
|
42
|
-
export declare type
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
declare const
|
|
68
|
-
|
|
1
|
+
import { BaseUnsetState } from '../typings/index';
|
|
2
|
+
import { Price } from '@commercelayer/sdk';
|
|
3
|
+
import { Dispatch } from 'react';
|
|
4
|
+
import { SkuInventory } from './AvailabilityReducer';
|
|
5
|
+
export interface Items {
|
|
6
|
+
[skuCode: string]: SkuInventory;
|
|
7
|
+
}
|
|
8
|
+
export interface ItemPrices {
|
|
9
|
+
[skuCode: string]: Price;
|
|
10
|
+
}
|
|
11
|
+
export interface ItemQuantity {
|
|
12
|
+
[skuCode: string]: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ItemOption {
|
|
15
|
+
[key: string]: {
|
|
16
|
+
skuOptionId: string;
|
|
17
|
+
options: {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface ItemOptions {
|
|
23
|
+
[skuCode: string]: ItemOption;
|
|
24
|
+
}
|
|
25
|
+
export declare type CustomLineItem = {
|
|
26
|
+
name?: string;
|
|
27
|
+
imageUrl?: string | null;
|
|
28
|
+
};
|
|
29
|
+
export interface CustomLineItems {
|
|
30
|
+
[skuCode: string]: CustomLineItem;
|
|
31
|
+
}
|
|
32
|
+
declare type ItemParams = {
|
|
33
|
+
type: ItemActionType;
|
|
34
|
+
key: 'items' | 'item' | 'quantity' | 'option' | 'prices' | 'lineItem' | 'lineItems' | 'skuCode';
|
|
35
|
+
};
|
|
36
|
+
declare type DataType = Items | ItemQuantity | ItemOptions | ItemPrices | CustomLineItems | CustomLineItem | string;
|
|
37
|
+
export interface SetItemState {
|
|
38
|
+
(data: DataType, params: ItemParams, dispatch: Dispatch<ItemAction>): void;
|
|
39
|
+
}
|
|
40
|
+
export declare const setItemState: SetItemState;
|
|
41
|
+
export declare const unsetItemState: BaseUnsetState<ItemAction>;
|
|
42
|
+
export declare type SetCustomLineItems = (lineItems: CustomLineItems) => void;
|
|
43
|
+
export declare type SetCustomLineItem = (lineItem: CustomLineItem) => void;
|
|
44
|
+
export interface ItemState {
|
|
45
|
+
skuCode?: string;
|
|
46
|
+
items?: Items;
|
|
47
|
+
item?: Items;
|
|
48
|
+
lineItems?: CustomLineItems;
|
|
49
|
+
lineItem?: CustomLineItem;
|
|
50
|
+
quantity?: ItemQuantity;
|
|
51
|
+
option?: ItemOptions;
|
|
52
|
+
prices?: ItemPrices;
|
|
53
|
+
setItems?: (items: Items) => void;
|
|
54
|
+
setItem?: (item: Items) => void;
|
|
55
|
+
setQuantity?: (quantity: ItemQuantity) => void;
|
|
56
|
+
setOption?: (option: ItemOptions) => void;
|
|
57
|
+
setPrices?: (prices: ItemPrices) => void;
|
|
58
|
+
setSkuCode?: (skuCode: string) => void;
|
|
59
|
+
setCustomLineItems: SetCustomLineItems;
|
|
60
|
+
setCustomLineItem?: SetCustomLineItem;
|
|
61
|
+
}
|
|
62
|
+
declare type ItemActionType = 'setItem' | 'setItems' | 'setQuantity' | 'setOption' | 'setPrices' | 'setCustomLineItems' | 'setCustomLineItem' | 'setSkuCode';
|
|
63
|
+
export interface ItemAction {
|
|
64
|
+
type: ItemActionType;
|
|
65
|
+
payload: Partial<ItemState>;
|
|
66
|
+
}
|
|
67
|
+
export declare const itemInitialState: Partial<ItemState>;
|
|
68
|
+
declare const itemReducer: (state: Partial<ItemState>, reducer: ItemAction) => Partial<ItemState>;
|
|
69
|
+
export default itemReducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import baseReducer from"../utils/baseReducer";export const setItemState=(data,params,dispatch)=>{dispatch({type:params.type,payload:{[`${params.key}`]:data}})},unsetItemState=dispatch=>{dispatch({type:"setItem",payload:{item:{}}}),dispatch({type:"setItems",payload:{items:{}}}),dispatch({type:"setQuantity",payload:{quantity:{}}}),dispatch({type:"setOption",payload:{option:{}}}),dispatch({type:"setCustomLineItems",payload:{lineItems:{}}}),dispatch({type:"setCustomLineItem",payload:{lineItem:{}}})};const actionType=["setItem","setItems","setQuantity","setOption","setPrices","setCustomLineItems","setCustomLineItem","setSkuCode"];export const itemInitialState={items:{},item:{},quantity:{},option:{},prices:{},lineItems:{},lineItem:{},skuCode:""};const itemReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default itemReducer;
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export declare type UpdateLineItemParams = {
|
|
8
|
-
lineItemId: string;
|
|
9
|
-
quantity?: number;
|
|
10
|
-
dispatch: Dispatch<LineItemAction>;
|
|
11
|
-
config: CommerceLayerConfig;
|
|
12
|
-
getOrder: getOrderContext | undefined;
|
|
13
|
-
orderId: string;
|
|
14
|
-
errors: BaseError[] | undefined;
|
|
15
|
-
};
|
|
16
|
-
export interface UpdateLineItem {
|
|
17
|
-
(params: UpdateLineItemParams): void;
|
|
18
|
-
}
|
|
19
|
-
export declare type DeleteLineItemParam = Record<string, any> & UpdateLineItemParams;
|
|
20
|
-
export interface DeleteLineItem {
|
|
21
|
-
(params: DeleteLineItemParam): void;
|
|
22
|
-
}
|
|
23
|
-
export declare type GetLineItemsParams = {
|
|
24
|
-
dispatch: Dispatch<LineItemAction>;
|
|
25
|
-
config: CommerceLayerConfig;
|
|
26
|
-
order:
|
|
27
|
-
filters: Record<string, any>;
|
|
28
|
-
};
|
|
29
|
-
export interface GetLineItems {
|
|
30
|
-
(params: GetLineItemsParams): void;
|
|
31
|
-
}
|
|
32
|
-
export interface LineItemPayload {
|
|
33
|
-
loading?: boolean;
|
|
34
|
-
loader?: LoaderType;
|
|
35
|
-
lineItems?:
|
|
36
|
-
errors?: BaseError[];
|
|
37
|
-
}
|
|
38
|
-
export interface LineItemState extends LineItemPayload {
|
|
39
|
-
updateLineItem?: (lineItemId: string, quantity?: number) => void;
|
|
40
|
-
deleteLineItem?: (lineItemId: string) => void;
|
|
41
|
-
}
|
|
42
|
-
export interface LineItemAction {
|
|
43
|
-
type: LineItemActionType;
|
|
44
|
-
payload: LineItemPayload;
|
|
45
|
-
}
|
|
46
|
-
export declare const getLineItems: GetLineItems;
|
|
47
|
-
export declare const updateLineItem: UpdateLineItem;
|
|
48
|
-
export declare const deleteLineItem: DeleteLineItem;
|
|
49
|
-
export declare const lineItemInitialState: LineItemState;
|
|
50
|
-
export declare type LineItemActionType = 'setLineItems' | 'setErrors' | 'setLoading';
|
|
51
|
-
declare const lineItemReducer: (state: LineItemState, reducer: LineItemAction) => LineItemState;
|
|
52
|
-
export default lineItemReducer;
|
|
1
|
+
import { Dispatch } from 'react';
|
|
2
|
+
import { CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
3
|
+
import { getOrderContext } from './OrderReducer';
|
|
4
|
+
import { LoaderType } from '../typings/index';
|
|
5
|
+
import { BaseError } from '../typings/errors';
|
|
6
|
+
import { Order, LineItem } from '@commercelayer/sdk';
|
|
7
|
+
export declare type UpdateLineItemParams = {
|
|
8
|
+
lineItemId: string;
|
|
9
|
+
quantity?: number;
|
|
10
|
+
dispatch: Dispatch<LineItemAction>;
|
|
11
|
+
config: CommerceLayerConfig;
|
|
12
|
+
getOrder: getOrderContext | undefined;
|
|
13
|
+
orderId: string;
|
|
14
|
+
errors: BaseError[] | undefined;
|
|
15
|
+
};
|
|
16
|
+
export interface UpdateLineItem {
|
|
17
|
+
(params: UpdateLineItemParams): void;
|
|
18
|
+
}
|
|
19
|
+
export declare type DeleteLineItemParam = Record<string, any> & UpdateLineItemParams;
|
|
20
|
+
export interface DeleteLineItem {
|
|
21
|
+
(params: DeleteLineItemParam): void;
|
|
22
|
+
}
|
|
23
|
+
export declare type GetLineItemsParams = {
|
|
24
|
+
dispatch: Dispatch<LineItemAction>;
|
|
25
|
+
config: CommerceLayerConfig;
|
|
26
|
+
order: Order | null;
|
|
27
|
+
filters: Record<string, any>;
|
|
28
|
+
};
|
|
29
|
+
export interface GetLineItems {
|
|
30
|
+
(params: GetLineItemsParams): void;
|
|
31
|
+
}
|
|
32
|
+
export interface LineItemPayload {
|
|
33
|
+
loading?: boolean;
|
|
34
|
+
loader?: LoaderType;
|
|
35
|
+
lineItems?: LineItem[];
|
|
36
|
+
errors?: BaseError[];
|
|
37
|
+
}
|
|
38
|
+
export interface LineItemState extends LineItemPayload {
|
|
39
|
+
updateLineItem?: (lineItemId: string, quantity?: number) => void;
|
|
40
|
+
deleteLineItem?: (lineItemId: string) => void;
|
|
41
|
+
}
|
|
42
|
+
export interface LineItemAction {
|
|
43
|
+
type: LineItemActionType;
|
|
44
|
+
payload: LineItemPayload;
|
|
45
|
+
}
|
|
46
|
+
export declare const getLineItems: GetLineItems;
|
|
47
|
+
export declare const updateLineItem: UpdateLineItem;
|
|
48
|
+
export declare const deleteLineItem: DeleteLineItem;
|
|
49
|
+
export declare const lineItemInitialState: LineItemState;
|
|
50
|
+
export declare type LineItemActionType = 'setLineItems' | 'setErrors' | 'setLoading';
|
|
51
|
+
declare const lineItemReducer: (state: LineItemState, reducer: LineItemAction) => LineItemState;
|
|
52
|
+
export default lineItemReducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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==null?void 0: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,"line_items");dispatch({type:"setErrors",payload:{errors}})})},updateLineItem=async 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,"line_items");dispatch({type:"setErrors",payload:{errors}})}},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,"line_items");dispatch({type:"setErrors",payload:{errors}})}},lineItemInitialState={loading:!1,lineItems:[],errors:[]};const actionType=["setLineItems","setErrors","setLoading"],lineItemReducer=(state,reducer)=>baseReducer(state,reducer,actionType);export default lineItemReducer;
|