@commercelayer/react-components 3.4.4 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/AddToCartButton.d.ts +1 -20
- package/lib/components/AddToCartButton.js +1 -1
- package/lib/components/Address.d.ts +1 -13
- package/lib/components/Address.js +1 -1
- package/lib/components/AddressCountrySelector.d.ts +1 -9
- package/lib/components/AddressCountrySelector.js +1 -1
- package/lib/components/AddressField.d.ts +1 -15
- package/lib/components/AddressField.js +1 -1
- package/lib/components/AddressInput.d.ts +1 -7
- package/lib/components/AddressInput.js +1 -1
- package/lib/components/AddressStateSelector.d.ts +1 -11
- package/lib/components/AddressStateSelector.js +1 -1
- package/lib/components/AddressesContainer.d.ts +1 -8
- package/lib/components/AddressesContainer.js +1 -1
- package/lib/components/AdjustmentAmount.d.ts +1 -4
- package/lib/components/AdjustmentAmount.js +1 -1
- package/lib/components/AdyenPayment.d.ts +1 -25
- package/lib/components/AdyenPayment.js +1 -1
- package/lib/components/AvailabilityContainer.d.ts +1 -7
- package/lib/components/AvailabilityContainer.js +1 -1
- package/lib/components/AvailabilityTemplate.d.ts +1 -15
- package/lib/components/AvailabilityTemplate.js +1 -1
- package/lib/components/BillingAddressContainer.d.ts +1 -6
- package/lib/components/BillingAddressContainer.js +1 -1
- package/lib/components/BillingAddressForm.d.ts +1 -8
- package/lib/components/BillingAddressForm.js +1 -1
- package/lib/components/BraintreePayment.d.ts +1 -30
- package/lib/components/BraintreePayment.js +1 -1
- package/lib/components/CheckoutComPayment.d.ts +1 -23
- package/lib/components/CheckoutComPayment.js +1 -1
- package/lib/components/CheckoutLink.d.ts +1 -13
- package/lib/components/CheckoutLink.js +1 -1
- package/lib/components/CommerceLayer.d.ts +1 -8
- package/lib/components/CommerceLayer.js +1 -1
- package/lib/components/CustomerContainer.d.ts +1 -7
- package/lib/components/CustomerContainer.js +1 -1
- package/lib/components/CustomerInput.d.ts +1 -11
- package/lib/components/CustomerInput.js +1 -1
- package/lib/components/DeliveryLeadTime.d.ts +1 -10
- package/lib/components/DeliveryLeadTime.js +1 -1
- package/lib/components/DiscountAmount.d.ts +1 -4
- package/lib/components/DiscountAmount.js +1 -1
- package/lib/components/Errors.d.ts +1 -5
- package/lib/components/Errors.js +1 -1
- package/lib/components/ExternalFunction.d.ts +1 -7
- package/lib/components/ExternalFunction.js +1 -1
- package/lib/components/GiftCard.d.ts +1 -8
- package/lib/components/GiftCard.js +1 -1
- package/lib/components/GiftCardAmount.d.ts +1 -4
- package/lib/components/GiftCardAmount.js +1 -1
- package/lib/components/GiftCardContainer.d.ts +1 -6
- package/lib/components/GiftCardContainer.js +1 -1
- package/lib/components/GiftCardCurrencySelector.d.ts +1 -7
- package/lib/components/GiftCardCurrencySelector.js +1 -1
- package/lib/components/GiftCardInput.d.ts +1 -7
- package/lib/components/GiftCardInput.js +1 -1
- package/lib/components/GiftCardOrCouponCode.d.ts +1 -13
- package/lib/components/GiftCardOrCouponCode.js +1 -1
- package/lib/components/GiftCardOrCouponForm.d.ts +1 -10
- package/lib/components/GiftCardOrCouponForm.js +1 -1
- package/lib/components/GiftCardOrCouponInput.d.ts +1 -8
- package/lib/components/GiftCardOrCouponInput.js +1 -1
- package/lib/components/GiftCardOrCouponRemoveButton.d.ts +1 -16
- package/lib/components/GiftCardOrCouponRemoveButton.js +1 -1
- package/lib/components/GiftCardOrCouponSubmit.d.ts +1 -9
- package/lib/components/GiftCardOrCouponSubmit.js +1 -1
- package/lib/components/ItemContainer.d.ts +1 -11
- package/lib/components/ItemContainer.js +1 -1
- package/lib/components/LineItem.d.ts +1 -8
- package/lib/components/LineItem.js +1 -1
- package/lib/components/LineItemAmount.d.ts +1 -7
- package/lib/components/LineItemAmount.js +1 -1
- package/lib/components/LineItemCode.d.ts +1 -12
- package/lib/components/LineItemCode.js +1 -1
- package/lib/components/LineItemImage.d.ts +1 -16
- package/lib/components/LineItemImage.js +1 -1
- package/lib/components/LineItemName.d.ts +1 -11
- package/lib/components/LineItemName.js +1 -1
- package/lib/components/LineItemOption.d.ts +1 -19
- package/lib/components/LineItemOption.js +1 -1
- package/lib/components/LineItemOptions.d.ts +1 -14
- package/lib/components/LineItemOptions.js +1 -1
- package/lib/components/LineItemQuantity.d.ts +1 -14
- package/lib/components/LineItemQuantity.js +1 -1
- package/lib/components/LineItemRemoveLink.d.ts +1 -12
- package/lib/components/LineItemRemoveLink.js +1 -1
- package/lib/components/LineItemsContainer.d.ts +1 -8
- package/lib/components/LineItemsContainer.js +1 -1
- package/lib/components/LineItemsCount.d.ts +1 -12
- package/lib/components/LineItemsCount.js +1 -1
- package/lib/components/LineItemsEmpty.d.ts +1 -12
- package/lib/components/LineItemsEmpty.js +1 -1
- package/lib/components/MetadataInput.d.ts +1 -5
- package/lib/components/MetadataInput.js +1 -1
- package/lib/components/OrderContainer.d.ts +1 -11
- package/lib/components/OrderContainer.js +1 -1
- package/lib/components/OrderNumber.d.ts +1 -5
- package/lib/components/OrderNumber.js +1 -1
- package/lib/components/OrderStorage.d.ts +1 -8
- package/lib/components/OrderStorage.js +1 -1
- package/lib/components/PaymentGateway.d.ts +1 -16
- package/lib/components/PaymentGateway.js +1 -1
- package/lib/components/PaymentMethod.d.ts +1 -16
- package/lib/components/PaymentMethod.js +1 -1
- package/lib/components/PaymentMethodAmount.d.ts +1 -4
- package/lib/components/PaymentMethodAmount.js +1 -1
- package/lib/components/PaymentMethodName.d.ts +1 -9
- package/lib/components/PaymentMethodName.js +1 -1
- package/lib/components/PaymentMethodPrice.d.ts +1 -9
- package/lib/components/PaymentMethodPrice.js +1 -1
- package/lib/components/PaymentMethodRadioButton.d.ts +1 -11
- package/lib/components/PaymentMethodRadioButton.js +1 -1
- package/lib/components/PaymentMethodsContainer.d.ts +1 -8
- package/lib/components/PaymentMethodsContainer.js +1 -1
- package/lib/components/PaymentSource.d.ts +1 -19
- package/lib/components/PaymentSource.js +1 -1
- package/lib/components/PaymentSourceBrandIcon.d.ts +1 -15
- package/lib/components/PaymentSourceBrandIcon.js +1 -1
- package/lib/components/PaymentSourceBrandName.d.ts +1 -12
- package/lib/components/PaymentSourceBrandName.js +1 -1
- package/lib/components/PaymentSourceDetail.d.ts +1 -12
- package/lib/components/PaymentSourceDetail.js +1 -1
- package/lib/components/PaymentSourceEditButton.d.ts +1 -9
- package/lib/components/PaymentSourceEditButton.js +1 -1
- package/lib/components/PaypalPayment.d.ts +1 -12
- package/lib/components/PaypalPayment.js +1 -1
- package/lib/components/PlaceOrderButton.d.ts +1 -12
- package/lib/components/PlaceOrderButton.js +1 -1
- package/lib/components/PlaceOrderContainer.d.ts +1 -8
- package/lib/components/PlaceOrderContainer.js +1 -1
- package/lib/components/Price.d.ts +1 -16
- package/lib/components/Price.js +1 -1
- package/lib/components/PricesContainer.d.ts +1 -11
- package/lib/components/PricesContainer.js +1 -1
- package/lib/components/PrivacyAndTermsCheckbox.d.ts +1 -4
- package/lib/components/PrivacyAndTermsCheckbox.js +1 -1
- package/lib/components/QuantitySelector.d.ts +1 -17
- package/lib/components/QuantitySelector.js +1 -1
- package/lib/components/SaveAddressesButton.d.ts +1 -10
- package/lib/components/SaveAddressesButton.js +1 -1
- package/lib/components/SaveCustomerButton.d.ts +1 -13
- package/lib/components/SaveCustomerButton.js +1 -1
- package/lib/components/Shipment.d.ts +1 -8
- package/lib/components/Shipment.js +1 -1
- package/lib/components/ShipmentField.d.ts +1 -12
- package/lib/components/ShipmentField.js +1 -1
- package/lib/components/ShipmentsContainer.d.ts +1 -6
- package/lib/components/ShipmentsContainer.js +1 -1
- package/lib/components/ShippingAddressContainer.d.ts +1 -6
- package/lib/components/ShippingAddressContainer.js +1 -1
- package/lib/components/ShippingAddressForm.d.ts +1 -8
- package/lib/components/ShippingAddressForm.js +1 -1
- package/lib/components/ShippingAmount.d.ts +1 -4
- package/lib/components/ShippingAmount.js +1 -1
- package/lib/components/ShippingMethod.d.ts +1 -8
- package/lib/components/ShippingMethod.js +1 -1
- package/lib/components/ShippingMethodName.d.ts +1 -11
- package/lib/components/ShippingMethodName.js +1 -1
- package/lib/components/ShippingMethodPrice.d.ts +1 -13
- package/lib/components/ShippingMethodPrice.js +1 -1
- package/lib/components/ShippingMethodRadioButton.d.ts +1 -13
- package/lib/components/ShippingMethodRadioButton.js +1 -1
- package/lib/components/SkuList.d.ts +1 -7
- package/lib/components/SkuList.js +1 -1
- package/lib/components/SkuListsContainer.d.ts +1 -6
- package/lib/components/SkuListsContainer.js +1 -1
- package/lib/components/SkuOption.d.ts +1 -7
- package/lib/components/SkuOption.js +1 -1
- package/lib/components/SkuOptionInput.d.ts +1 -5
- package/lib/components/SkuOptionInput.js +1 -1
- package/lib/components/SkuOptionsContainer.d.ts +1 -7
- package/lib/components/SkuOptionsContainer.js +1 -1
- package/lib/components/StockTransfer.d.ts +1 -6
- package/lib/components/StockTransfer.js +1 -1
- package/lib/components/StockTransferField.d.ts +1 -9
- package/lib/components/StockTransferField.js +1 -1
- package/lib/components/StripePayment.d.ts +1 -18
- package/lib/components/StripePayment.js +1 -1
- package/lib/components/SubTotalAmount.d.ts +1 -4
- package/lib/components/SubTotalAmount.js +1 -1
- package/lib/components/SubmitButton.d.ts +1 -9
- package/lib/components/SubmitButton.js +1 -1
- package/lib/components/TaxesAmount.d.ts +1 -4
- package/lib/components/TaxesAmount.js +1 -1
- package/lib/components/TotalAmount.d.ts +1 -4
- package/lib/components/TotalAmount.js +1 -1
- package/lib/components/VariantSelector.d.ts +1 -29
- package/lib/components/VariantSelector.js +1 -1
- package/lib/components/VariantsContainer.d.ts +1 -8
- package/lib/components/VariantsContainer.js +1 -1
- package/lib/components/WireTransferPayment.d.ts +1 -10
- package/lib/components/WireTransferPayment.js +1 -1
- package/lib/components/gateways/AdyenGateway.d.ts +1 -4
- package/lib/components/gateways/AdyenGateway.js +1 -1
- package/lib/components/gateways/BraintreeGateway.d.ts +1 -4
- package/lib/components/gateways/BraintreeGateway.js +1 -1
- package/lib/components/gateways/CheckoutComGateway.d.ts +1 -4
- package/lib/components/gateways/CheckoutComGateway.js +1 -1
- package/lib/components/gateways/PaypalGateway.d.ts +1 -4
- package/lib/components/gateways/PaypalGateway.js +1 -1
- package/lib/components/gateways/StripeGateway.d.ts +1 -4
- package/lib/components/gateways/StripeGateway.js +1 -1
- package/lib/components/gateways/WireTransferGateway.d.ts +1 -4
- package/lib/components/gateways/WireTransferGateway.js +1 -1
- package/lib/components/utils/AddressCardsTemplate.d.ts +1 -26
- package/lib/components/utils/AddressCardsTemplate.js +1 -1
- package/lib/components/utils/BaseField.d.ts +1 -8
- package/lib/components/utils/BaseField.js +1 -1
- package/lib/components/utils/BaseInput.d.ts +1 -5
- package/lib/components/utils/BaseInput.js +1 -1
- package/lib/components/utils/BaseOrderPrice.d.ts +1 -6
- package/lib/components/utils/BaseOrderPrice.js +1 -1
- package/lib/components/utils/BaseSelect.d.ts +1 -5
- package/lib/components/utils/BaseSelect.js +1 -1
- package/lib/components/utils/Parent.d.ts +1 -8
- package/lib/components/utils/Parent.js +1 -1
- package/lib/components/utils/PaymentCardsTemplate.d.ts +1 -22
- package/lib/components/utils/PaymentCardsTemplate.js +1 -1
- package/lib/components/utils/PriceTemplate.d.ts +1 -8
- package/lib/components/utils/PriceTemplate.js +1 -1
- package/lib/components/utils/VariantTemplate.d.ts +1 -36
- package/lib/components/utils/VariantTemplate.js +1 -1
- package/lib/components/utils/getAllErrors.d.ts +1 -17
- package/lib/config/components.d.ts +1 -891
- package/lib/config/currency.d.ts +1 -5
- package/lib/context/AddressChildrenContext.d.ts +1 -6
- package/lib/context/AddressContext.d.ts +1 -16
- package/lib/context/AvailabilityContext.d.ts +1 -2
- package/lib/context/BillingAddressContext.d.ts +1 -11
- package/lib/context/BillingAddressFormContext.d.ts +1 -19
- package/lib/context/CommerceLayerContext.d.ts +1 -6
- package/lib/context/CouponAndGiftCardFormContext.d.ts +1 -7
- package/lib/context/CustomerContext.d.ts +1 -15
- package/lib/context/ExternalFunctionContext.d.ts +1 -11
- package/lib/context/GiftCardContext.d.ts +1 -10
- package/lib/context/ItemContext.d.ts +1 -12
- package/lib/context/LineItemChildrenContext.d.ts +1 -8
- package/lib/context/LineItemContext.d.ts +1 -7
- package/lib/context/LineItemOptionChildrenContext.d.ts +1 -7
- package/lib/context/OrderContext.d.ts +1 -25
- package/lib/context/OrderStorageContext.d.ts +1 -10
- package/lib/context/PaymentMethodChildrenContext.d.ts +1 -9
- package/lib/context/PaymentMethodContext.d.ts +1 -22
- package/lib/context/PaymentSourceContext.d.ts +1 -13
- package/lib/context/PlaceOrderContext.d.ts +1 -17
- package/lib/context/PricesContext.d.ts +1 -6
- package/lib/context/ShipmentChildrenContext.d.ts +1 -12
- package/lib/context/ShipmentContext.d.ts +1 -11
- package/lib/context/ShippingAddressContext.d.ts +1 -9
- package/lib/context/ShippingAddressFormContext.d.ts +1 -3
- package/lib/context/ShippingMethodChildrenContext.d.ts +1 -9
- package/lib/context/SkuListsContext.d.ts +1 -5
- package/lib/context/SkuOptionChildrenContext.d.ts +1 -7
- package/lib/context/SkuOptionsContext.d.ts +1 -2
- package/lib/context/StockTransferChildrenContext.d.ts +1 -6
- package/lib/context/VariantsContext.d.ts +1 -2
- package/lib/index.d.ts +1 -99
- package/lib/reducers/AddressReducer.d.ts +1 -59
- package/lib/reducers/AvailabilityReducer.d.ts +1 -53
- package/lib/reducers/BillingAddressReducer.d.ts +1 -31
- package/lib/reducers/CustomerReducer.d.ts +1 -50
- package/lib/reducers/GiftCardReducer.d.ts +1 -76
- package/lib/reducers/ItemReducer.d.ts +1 -69
- package/lib/reducers/LineItemReducer.d.ts +1 -52
- package/lib/reducers/OrderReducer.d.ts +2 -121
- package/lib/reducers/PaymentMethodReducer.d.ts +1 -145
- package/lib/reducers/PlaceOrderReducer.d.ts +1 -57
- package/lib/reducers/PriceReducer.d.ts +1 -44
- package/lib/reducers/ShipmentReducer.d.ts +1 -40
- package/lib/reducers/ShippingAddressReducer.d.ts +1 -32
- package/lib/reducers/SkuListsReducer.d.ts +1 -21
- package/lib/reducers/SkuOptionsReducer.d.ts +1 -26
- package/lib/reducers/VariantReducer.d.ts +1 -71
- package/lib/typings/errors.d.ts +1 -42
- package/lib/typings/index.d.ts +1 -127
- package/lib/utils/PropsType.d.ts +1 -33
- package/lib/utils/addressesManager.d.ts +1 -28
- package/lib/utils/baseReducer.d.ts +1 -3
- package/lib/utils/browserInfo.d.ts +1 -9
- package/lib/utils/childrenTypes.d.ts +1 -9
- package/lib/utils/countryStateCity.d.ts +1 -9
- package/lib/utils/customMessages.d.ts +1 -8
- package/lib/utils/customerOrderOptions.d.ts +1 -3
- package/lib/utils/getAmount.d.ts +1 -9
- package/lib/utils/getCardDetails.d.ts +1 -15
- package/lib/utils/getCurrentItemKey.d.ts +1 -6
- package/lib/utils/getErrors.d.ts +1 -11
- package/lib/utils/getLineItemsCount.d.ts +1 -12
- package/lib/utils/getLoaderComponent.d.ts +1 -2
- package/lib/utils/getLoaderComponent.js +1 -1
- package/lib/utils/getPrices.d.ts +1 -17
- package/lib/utils/getPrices.js +1 -1
- package/lib/utils/getSdk.d.ts +1 -3
- package/lib/utils/getSkus.d.ts +1 -3
- package/lib/utils/hooks/useExternalScript.d.ts +1 -1
- package/lib/utils/isEmptyStates.d.ts +1 -1
- package/lib/utils/isJSON.d.ts +1 -1
- package/lib/utils/jwt.d.ts +1 -27
- package/lib/utils/localStorage.d.ts +1 -17
- package/lib/utils/organization.d.ts +1 -6
- package/lib/utils/paypalPayment.d.ts +1 -3
- package/lib/utils/promisify.d.ts +1 -1
- package/lib/utils/shipments.d.ts +1 -2
- package/lib/utils/validateFormFields.d.ts +1 -22
- package/package.json +21 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../context/LineItemChildrenContext";import LineItemContext from"../context/LineItemContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.LineItemRemoveLink.propTypes,defaultProps=components.LineItemRemoveLink.defaultProps,displayName=components.LineItemRemoveLink.displayName,LineItemRemoveLink=props=>{const{label="Remove"}=props,{lineItem}=useContext(LineItemChildrenContext),{deleteLineItem}=useContext(LineItemContext),handleRemove=e=>{e.preventDefault(),deleteLineItem&&lineItem&&deleteLineItem(lineItem.id)},parentProps=Object.assign({handleRemove},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import LineItemChildrenContext from"../context/LineItemChildrenContext";import LineItemContext from"../context/LineItemContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.LineItemRemoveLink.propTypes,defaultProps=components.LineItemRemoveLink.defaultProps,displayName=components.LineItemRemoveLink.displayName,LineItemRemoveLink=props=>{const{label="Remove"}=props,{lineItem}=useContext(LineItemChildrenContext),{deleteLineItem}=useContext(LineItemContext),handleRemove=e=>{e.preventDefault(),deleteLineItem&&lineItem&&deleteLineItem(lineItem.id)},parentProps=Object.assign({handleRemove},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("a",Object.assign({},props,{href:"#",onClick:handleRemove},{children:label}))};LineItemRemoveLink.propTypes=propTypes,LineItemRemoveLink.defaultProps=defaultProps,LineItemRemoveLink.displayName=displayName;export default LineItemRemoveLink;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare type LineItemsContainer = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
filters?: Record<string, any>;
|
|
5
|
-
loader?: ReactNode;
|
|
6
|
-
};
|
|
7
|
-
declare const LineItemsContainer: FunctionComponent<LineItemsContainer>;
|
|
8
|
-
export default LineItemsContainer;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';declare type LineItemsContainer={children:ReactNode;filters?:Record<string,any>;loader?:ReactNode;};declare const LineItemsContainer:FunctionComponent<LineItemsContainer>;export default LineItemsContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../reducers/LineItemReducer";import OrderContext from"../context/OrderContext";import LineItemContext from"../context/LineItemContext";import CommerceLayerContext from"../context/CommerceLayerContext";import{isEmpty}from"lodash";import components from"../config/components";const propTypes=components.LineItemsContainer.propTypes,defaultProps=components.LineItemsContainer.defaultProps,displayName=components.LineItemsContainer.displayName,LineItemsContainer=props=>{const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>((include==null?void 0:include.includes("line_items.line_item_options.sku_option"))?(includeLoaded==null?void 0:includeLoaded["line_items.line_item_options.sku_option"])||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:"line_items.line_item_options.sku_option"}),!isEmpty(order)&&(order==null?void 0:order.line_items)&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}}),()=>{isEmpty(order)&&dispatch({type:"setLineItems",payload:{lineItems:[]}})}),[order,include,includeLoaded]);const lineItemValue=Object.assign(Object.assign({},state),{loader,updateLineItem:(lineItemId,quantity=1)=>updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:lineItemId=>deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})});return _jsx(LineItemContext.Provider,Object.assign({value:lineItemValue},{children:state.loading?loader:children})
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext}from"react";import lineItemReducer,{lineItemInitialState,updateLineItem,deleteLineItem}from"../reducers/LineItemReducer";import OrderContext from"../context/OrderContext";import LineItemContext from"../context/LineItemContext";import CommerceLayerContext from"../context/CommerceLayerContext";import{isEmpty}from"lodash";import components from"../config/components";const propTypes=components.LineItemsContainer.propTypes,defaultProps=components.LineItemsContainer.defaultProps,displayName=components.LineItemsContainer.displayName,LineItemsContainer=props=>{const{children,loader="Loading..."}=props,{order,addResourceToInclude,include,orderId,getOrder,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext),[state,dispatch]=useReducer(lineItemReducer,lineItemInitialState);useEffect(()=>((include==null?void 0:include.includes("line_items.line_item_options.sku_option"))?(includeLoaded==null?void 0:includeLoaded["line_items.line_item_options.sku_option"])||addResourceToInclude({newResourceLoaded:{"line_items.line_item_options.sku_option":!0}}):addResourceToInclude({newResource:"line_items.line_item_options.sku_option"}),!isEmpty(order)&&(order==null?void 0:order.line_items)&&dispatch({type:"setLineItems",payload:{lineItems:order.line_items}}),()=>{isEmpty(order)&&dispatch({type:"setLineItems",payload:{lineItems:[]}})}),[order,include,includeLoaded]);const lineItemValue=Object.assign(Object.assign({},state),{loader,updateLineItem:(lineItemId,quantity=1)=>updateLineItem({lineItemId,quantity,dispatch,config,getOrder,orderId,errors:state.errors}),deleteLineItem:lineItemId=>deleteLineItem({lineItemId,dispatch,config,getOrder,orderId,errors:state.errors})});return _jsx(LineItemContext.Provider,Object.assign({value:lineItemValue},{children:state.loading?loader:children}))};LineItemsContainer.propTypes=propTypes,LineItemsContainer.defaultProps=defaultProps,LineItemsContainer.displayName=displayName;export default LineItemsContainer;
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TypeAccepted } from '../utils/getLineItemsCount';
|
|
3
|
-
import { FunctionChildren } from '../typings/index';
|
|
4
|
-
declare type LineItemsCountChildrenProps = FunctionChildren<Omit<LineItemsCountProps, 'children'> & {
|
|
5
|
-
quantity: number;
|
|
6
|
-
}>;
|
|
7
|
-
declare type LineItemsCountProps = {
|
|
8
|
-
children?: LineItemsCountChildrenProps;
|
|
9
|
-
typeAccepted?: TypeAccepted[];
|
|
10
|
-
} & JSX.IntrinsicElements['span'];
|
|
11
|
-
declare const LineItemsCount: FunctionComponent<LineItemsCountProps>;
|
|
12
|
-
export default LineItemsCount;
|
|
1
|
+
import{FunctionComponent}from'react';import{TypeAccepted}from'../utils/getLineItemsCount';import{FunctionChildren}from'../typings/index';declare type LineItemsCountChildrenProps=FunctionChildren<Omit<LineItemsCountProps,'children'>&{quantity:number;}>;declare type LineItemsCountProps={children?:LineItemsCountChildrenProps;typeAccepted?:TypeAccepted[];}&JSX.IntrinsicElements['span'];declare const LineItemsCount:FunctionComponent<LineItemsCountProps>;export default LineItemsCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import{isEmpty}from"lodash";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsCount.propTypes,displayName=components.LineItemsCount.displayName,LineItemsCount=props=>{const{children,typeAccepted}=props,p=__rest(props,["children","typeAccepted"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0);useEffect(()=>{if(!isEmpty(lineItems)){const qty=getLineItemsCount({lineItems:lineItems||[],typeAccepted});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems,typeAccepted]);const parentProps=Object.assign({quantity,typeAccepted},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import{isEmpty}from"lodash";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsCount.propTypes,displayName=components.LineItemsCount.displayName,LineItemsCount=props=>{const{children,typeAccepted}=props,p=__rest(props,["children","typeAccepted"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0);useEffect(()=>{if(!isEmpty(lineItems)){const qty=getLineItemsCount({lineItems:lineItems||[],typeAccepted});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems,typeAccepted]);const parentProps=Object.assign({quantity,typeAccepted},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},p,{children:quantity}))};LineItemsCount.propTypes=propTypes,LineItemsCount.displayName=displayName;export default LineItemsCount;
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FunctionChildren } from '../typings/index';
|
|
3
|
-
export declare type LineItemsCountType = FunctionChildren<Omit<LineItemsCountProps, 'children'> & {
|
|
4
|
-
quantity: number;
|
|
5
|
-
text: string;
|
|
6
|
-
}>;
|
|
7
|
-
declare type LineItemsCountProps = {
|
|
8
|
-
children?: LineItemsCountType;
|
|
9
|
-
text?: string;
|
|
10
|
-
} & JSX.IntrinsicElements['span'];
|
|
11
|
-
declare const LineItemsEmpty: FunctionComponent<LineItemsCountProps>;
|
|
12
|
-
export default LineItemsEmpty;
|
|
1
|
+
import{FunctionComponent}from'react';import{FunctionChildren}from'../typings/index';export declare type LineItemsCountType=FunctionChildren<Omit<LineItemsCountProps,'children'>&{quantity:number;text:string;}>;declare type LineItemsCountProps={children?:LineItemsCountType;text?:string;}&JSX.IntrinsicElements['span'];declare const LineItemsEmpty:FunctionComponent<LineItemsCountProps>;export default LineItemsEmpty;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import{isEmpty}from"lodash";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsEmpty.propTypes,displayName=components.LineItemsEmpty.displayName,LineItemsEmpty=props=>{const{children,text="Your shopping bag is empty"}=props,p=__rest(props,["children","text"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0),emptyText=quantity===0?_jsx("span",Object.assign({},p,{children:text})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import Parent from"./utils/Parent";import getLineItemsCount from"../utils/getLineItemsCount";import{isEmpty}from"lodash";import LineItemContext from"../context/LineItemContext";import components from"../config/components";const propTypes=components.LineItemsEmpty.propTypes,displayName=components.LineItemsEmpty.displayName,LineItemsEmpty=props=>{const{children,text="Your shopping bag is empty"}=props,p=__rest(props,["children","text"]),{lineItems}=useContext(LineItemContext),[quantity,setQuantity]=useState(0),emptyText=quantity===0?_jsx("span",Object.assign({},p,{children:text})):null;useEffect(()=>{if(!isEmpty(lineItems)){const qty=getLineItemsCount({lineItems:lineItems||[]});setQuantity(qty)}return()=>{setQuantity(0)}},[lineItems]);const parentProps=Object.assign({quantity,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):emptyText};LineItemsEmpty.propTypes=propTypes,LineItemsEmpty.displayName=displayName;export default LineItemsEmpty;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BaseInputComponentProps } from '../typings/index';
|
|
3
|
-
export declare type MetadataInputProps = BaseInputComponentProps & JSX.IntrinsicElements['input'] & JSX.IntrinsicElements['textarea'];
|
|
4
|
-
declare const MetadataInput: FunctionComponent<MetadataInputProps>;
|
|
5
|
-
export default MetadataInput;
|
|
1
|
+
import{FunctionComponent}from'react';import{BaseInputComponentProps}from'../typings/index';export declare type MetadataInputProps=BaseInputComponentProps&JSX.IntrinsicElements['input']&JSX.IntrinsicElements['textarea'];declare const MetadataInput:FunctionComponent<MetadataInputProps>;export default MetadataInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"./utils/BaseInput";import components from"../config/components";const propTypes=components.MetadataInput.propTypes,displayName=components.MetadataInput.displayName,MetadataInput=props=>_jsx(BaseInput,Object.assign({"data-metadata":!0},props)
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseInput from"./utils/BaseInput";import components from"../config/components";const propTypes=components.MetadataInput.propTypes,displayName=components.MetadataInput.displayName,MetadataInput=props=>_jsx(BaseInput,Object.assign({"data-metadata":!0},props));MetadataInput.propTypes=propTypes,MetadataInput.displayName=displayName;export default MetadataInput;
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BaseMetadataObject } from '../typings/index';
|
|
3
|
-
import { OrderCreate } from '@commercelayer/sdk';
|
|
4
|
-
declare type OrderContainerProps = {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
metadata?: BaseMetadataObject;
|
|
7
|
-
attributes?: OrderCreate;
|
|
8
|
-
orderId?: string;
|
|
9
|
-
};
|
|
10
|
-
declare const OrderContainer: FunctionComponent<OrderContainerProps>;
|
|
11
|
-
export default OrderContainer;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';import{BaseMetadataObject}from'../typings/index';import{OrderCreate}from'@commercelayer/sdk';declare type OrderContainerProps={children:ReactNode;metadata?:BaseMetadataObject;attributes?:OrderCreate;orderId?:string;};declare const OrderContainer:FunctionComponent<OrderContainerProps>;export default OrderContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext,useMemo}from"react";import orderReducer,{createOrder,getApiOrder,setOrderErrors,setOrder,orderInitialState}from"../reducers/OrderReducer";import CommerceLayerContext from"../context/CommerceLayerContext";import OrderContext,{defaultOrderContext}from"../context/OrderContext";import{unsetOrderState}from"../reducers/OrderReducer";import components from"../config/components";import OrderStorageContext from"../context/OrderStorageContext";const propTypes=components.OrderContainer.propTypes,defaultProps=components.OrderContainer.defaultProps,displayName=components.OrderContainer.displayName,OrderContainer=props=>{const{orderId,children,metadata,attributes}=props,[state,dispatch]=useReducer(orderReducer,orderInitialState),config=useContext(CommerceLayerContext),{persistKey,clearWhenPlaced,getLocalOrder,setLocalOrder,deleteLocalOrder}=useContext(OrderStorageContext);useEffect(()=>{var _a;const startRequest=Object.keys((state==null?void 0:state.includeLoaded)||{}).filter(key=>{var _a2;return((_a2=state==null?void 0:state.includeLoaded)===null||_a2===void 0?void 0:_a2[key])===!0});if(config.accessToken){const localOrder=persistKey?getLocalOrder(persistKey):orderId;localOrder&&(dispatch({type:"setOrderId",payload:{orderId:localOrder}}),!state.order&&startRequest.length===((_a=state.include)===null||_a===void 0?void 0:_a.length)&&getApiOrder({id:localOrder,dispatch,config,persistKey,clearWhenPlaced:!!(persistKey&&clearWhenPlaced),deleteLocalOrder,state}))}return()=>unsetOrderState(dispatch)},[config.accessToken,orderId,state.includeLoaded]);const orderValue=useMemo(()=>Object.assign(Object.assign({},state),{setOrder:order=>setOrder(order,dispatch),getOrder:id=>getApiOrder({id,dispatch,config,state}),setOrderErrors:errors=>setOrderErrors({dispatch,errors}),createOrder:async()=>await createOrder({persistKey,dispatch,config,state,orderMetadata:metadata,orderAttributes:attributes}),addToCart:values=>defaultOrderContext.addToCart(Object.assign(Object.assign({},values),{persistKey,dispatch,state,config,errors:state.errors,orderMetadata:metadata||{},orderAttributes:attributes,setLocalOrder})),saveAddressToCustomerAddressBook:args=>defaultOrderContext.saveAddressToCustomerAddressBook(Object.assign(Object.assign({},args),{dispatch})),setGiftCardOrCouponCode:({code})=>defaultOrderContext.setGiftCardOrCouponCode({code,dispatch,order:state.order,config,include:state.include}),removeGiftCardOrCouponCode:({codeType})=>defaultOrderContext.removeGiftCardOrCouponCode({codeType,dispatch,order:state.order,config,include:state.include}),addResourceToInclude:args=>defaultOrderContext.addResourceToInclude(Object.assign(Object.assign({},args),{dispatch,resourcesIncluded:state.include,resourceIncludedLoaded:state.includeLoaded})),updateOrder:async args=>await defaultOrderContext.updateOrder(Object.assign(Object.assign({},args),{dispatch,config,include:state.include}))}),[state]);return _jsx(OrderContext.Provider,Object.assign({value:orderValue},{children})
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useEffect,useReducer,useContext,useMemo}from"react";import orderReducer,{createOrder,getApiOrder,setOrderErrors,setOrder,orderInitialState}from"../reducers/OrderReducer";import CommerceLayerContext from"../context/CommerceLayerContext";import OrderContext,{defaultOrderContext}from"../context/OrderContext";import{unsetOrderState}from"../reducers/OrderReducer";import components from"../config/components";import OrderStorageContext from"../context/OrderStorageContext";const propTypes=components.OrderContainer.propTypes,defaultProps=components.OrderContainer.defaultProps,displayName=components.OrderContainer.displayName,OrderContainer=props=>{const{orderId,children,metadata,attributes}=props,[state,dispatch]=useReducer(orderReducer,orderInitialState),config=useContext(CommerceLayerContext),{persistKey,clearWhenPlaced,getLocalOrder,setLocalOrder,deleteLocalOrder}=useContext(OrderStorageContext);useEffect(()=>{var _a;const startRequest=Object.keys((state==null?void 0:state.includeLoaded)||{}).filter(key=>{var _a2;return((_a2=state==null?void 0:state.includeLoaded)===null||_a2===void 0?void 0:_a2[key])===!0});if(config.accessToken){const localOrder=persistKey?getLocalOrder(persistKey):orderId;localOrder&&(dispatch({type:"setOrderId",payload:{orderId:localOrder}}),!state.order&&startRequest.length===((_a=state.include)===null||_a===void 0?void 0:_a.length)&&getApiOrder({id:localOrder,dispatch,config,persistKey,clearWhenPlaced:!!(persistKey&&clearWhenPlaced),deleteLocalOrder,state}))}return()=>unsetOrderState(dispatch)},[config.accessToken,orderId,state.includeLoaded]);const orderValue=useMemo(()=>Object.assign(Object.assign({},state),{setOrder:order=>setOrder(order,dispatch),getOrder:id=>getApiOrder({id,dispatch,config,state}),setOrderErrors:errors=>setOrderErrors({dispatch,errors}),createOrder:async()=>await createOrder({persistKey,dispatch,config,state,orderMetadata:metadata,orderAttributes:attributes}),addToCart:values=>defaultOrderContext.addToCart(Object.assign(Object.assign({},values),{persistKey,dispatch,state,config,errors:state.errors,orderMetadata:metadata||{},orderAttributes:attributes,setLocalOrder})),saveAddressToCustomerAddressBook:args=>defaultOrderContext.saveAddressToCustomerAddressBook(Object.assign(Object.assign({},args),{dispatch})),setGiftCardOrCouponCode:({code})=>defaultOrderContext.setGiftCardOrCouponCode({code,dispatch,order:state.order,config,include:state.include}),removeGiftCardOrCouponCode:({codeType})=>defaultOrderContext.removeGiftCardOrCouponCode({codeType,dispatch,order:state.order,config,include:state.include}),addResourceToInclude:args=>defaultOrderContext.addResourceToInclude(Object.assign(Object.assign({},args),{dispatch,resourcesIncluded:state.include,resourceIncludedLoaded:state.includeLoaded})),updateOrder:async args=>await defaultOrderContext.updateOrder(Object.assign(Object.assign({},args),{dispatch,config,include:state.include}))}),[state]);return _jsx(OrderContext.Provider,Object.assign({value:orderValue},{children}))};OrderContainer.propTypes=propTypes,OrderContainer.defaultProps=defaultProps,OrderContainer.displayName=displayName;export default OrderContainer;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BaseFieldProps } from './utils/BaseField';
|
|
3
|
-
export declare type OrderNumberProps = Omit<BaseFieldProps, 'attribute'>;
|
|
4
|
-
declare const OrderNumber: FunctionComponent<OrderNumberProps>;
|
|
5
|
-
export default OrderNumber;
|
|
1
|
+
import{FunctionComponent}from'react';import{BaseFieldProps}from'./utils/BaseField';export declare type OrderNumberProps=Omit<BaseFieldProps,'attribute'>;declare const OrderNumber:FunctionComponent<OrderNumberProps>;export default OrderNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import components from"../config/components";import BaseField from"./utils/BaseField";const propTypes=components.OrderNumber.propTypes,displayName=components.OrderNumber.displayName,OrderNumber=props=>_jsx(BaseField,Object.assign({attribute:"number"},props)
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import components from"../config/components";import BaseField from"./utils/BaseField";const propTypes=components.OrderNumber.propTypes,displayName=components.OrderNumber.displayName,OrderNumber=props=>_jsx(BaseField,Object.assign({attribute:"number"},props));OrderNumber.propTypes=propTypes,OrderNumber.displayName=displayName;export default OrderNumber;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare type OrderStorageProps = {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
persistKey: string;
|
|
5
|
-
clearWhenPlaced?: boolean;
|
|
6
|
-
};
|
|
7
|
-
declare const OrderStorage: FunctionComponent<OrderStorageProps>;
|
|
8
|
-
export default OrderStorage;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';declare type OrderStorageProps={children:ReactNode;persistKey:string;clearWhenPlaced?:boolean;};declare const OrderStorage:FunctionComponent<OrderStorageProps>;export default OrderStorage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderStorageContext from"../context/OrderStorageContext";import components from"../config/components";import{getLocalOrder,setLocalOrder,deleteLocalOrder}from"../utils/localStorage";const propTypes=components.OrderStorage.propTypes,displayName=components.OrderStorage.displayName,OrderStorage=props=>{const{children,clearWhenPlaced=!0}=props,p=__rest(props,["children","clearWhenPlaced"]);return _jsx(OrderStorageContext.Provider,Object.assign({value:Object.assign(Object.assign({},p),{setLocalOrder,getLocalOrder,deleteLocalOrder,clearWhenPlaced})},{children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderStorageContext from"../context/OrderStorageContext";import components from"../config/components";import{getLocalOrder,setLocalOrder,deleteLocalOrder}from"../utils/localStorage";const propTypes=components.OrderStorage.propTypes,displayName=components.OrderStorage.displayName,OrderStorage=props=>{const{children,clearWhenPlaced=!0}=props,p=__rest(props,["children","clearWhenPlaced"]);return _jsx(OrderStorageContext.Provider,Object.assign({value:Object.assign(Object.assign({},p),{setLocalOrder,getLocalOrder,deleteLocalOrder,clearWhenPlaced})},{children}))};OrderStorage.propTypes=propTypes,OrderStorage.displayName=displayName;export default OrderStorage;
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FunctionComponent } from 'react';
|
|
3
|
-
import { PaymentSourceProps } from './PaymentSource';
|
|
4
|
-
export declare type GatewayBaseType = PaymentGatewayProps & {
|
|
5
|
-
show: boolean;
|
|
6
|
-
loading: boolean;
|
|
7
|
-
loaderComponent: JSX.Element;
|
|
8
|
-
};
|
|
9
|
-
export declare type PaymentGatewayProps = PaymentSourceProps & {
|
|
10
|
-
showCard: boolean;
|
|
11
|
-
handleEditClick: (e: MouseEvent) => void;
|
|
12
|
-
show: boolean;
|
|
13
|
-
loader?: LoaderType;
|
|
14
|
-
};
|
|
15
|
-
declare const PaymentGateway: FunctionComponent<PaymentGatewayProps>;
|
|
16
|
-
export default PaymentGateway;
|
|
1
|
+
import{LoaderType}from'../typings/index';import{FunctionComponent}from'react';import{PaymentSourceProps}from'./PaymentSource';export declare type GatewayBaseType=PaymentGatewayProps&{show:boolean;loading:boolean;loaderComponent:JSX.Element;};export declare type PaymentGatewayProps=PaymentSourceProps&{showCard:boolean;handleEditClick:(e:MouseEvent)=>void;show:boolean;loader?:LoaderType;};declare const PaymentGateway:FunctionComponent<PaymentGatewayProps>;export default PaymentGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../context/OrderContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../context/PaymentMethodContext";import getPaypalConfig from"../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../utils/getLoaderComponent";import AdyenGateway from"./gateways/AdyenGateway";import StripeGateway from"./gateways/StripeGateway";import BraintreeGateway from"./gateways/BraintreeGateway";import PaypalGateway from"./gateways/PaypalGateway";import WireTransferGateway from"./gateways/WireTransferGateway";import CustomerContext from"../context/CustomerContext";import CheckoutComGateway from"./gateways/CheckoutComGateway";const PaymentGateway=_a=>{var _b,{readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading..."}=_a,p=__rest(_a,["readonly","showCard","handleEditClick","children","templateCustomerCards","templateCustomerSaveToWallet","onClickCustomerCards","show","loader"]);const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource,currentPaymentMethodType,setPaymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment==null?void 0:payment.payment_source_type;useEffect(()=>{var _a2;if((payment==null?void 0:payment.id)===currentPaymentMethodId&&paymentResource&&((_a2=order==null?void 0:order.payment_method)===null||_a2===void 0?void 0:_a2.payment_source_type)===paymentResource){const attributes=config&&paymentResource==="paypal_payments"?getPaypalConfig(paymentResource,config):{};(!paymentSource||paymentSource.type!==paymentResource)&&(setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()),setLoading(!1)}return()=>{setLoading(!0)}},[(_b=order==null?void 0:order.payment_method)===null||_b===void 0?void 0:_b.payment_source_type,show,paymentSource]);const gatewayConfig=Object.assign({readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet},p);switch(paymentResource){case"stripe_payments":return _jsx(StripeGateway,Object.assign({},gatewayConfig,{children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../context/OrderContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../context/PaymentMethodContext";import getPaypalConfig from"../utils/paypalPayment";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../utils/getLoaderComponent";import AdyenGateway from"./gateways/AdyenGateway";import StripeGateway from"./gateways/StripeGateway";import BraintreeGateway from"./gateways/BraintreeGateway";import PaypalGateway from"./gateways/PaypalGateway";import WireTransferGateway from"./gateways/WireTransferGateway";import CustomerContext from"../context/CustomerContext";import CheckoutComGateway from"./gateways/CheckoutComGateway";const PaymentGateway=_a=>{var _b,{readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading..."}=_a,p=__rest(_a,["readonly","showCard","handleEditClick","children","templateCustomerCards","templateCustomerSaveToWallet","onClickCustomerCards","show","loader"]);const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource,currentPaymentMethodType,setPaymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment==null?void 0:payment.payment_source_type;useEffect(()=>{var _a2;if((payment==null?void 0:payment.id)===currentPaymentMethodId&&paymentResource&&((_a2=order==null?void 0:order.payment_method)===null||_a2===void 0?void 0:_a2.payment_source_type)===paymentResource){const attributes=config&&paymentResource==="paypal_payments"?getPaypalConfig(paymentResource,config):{};(!paymentSource||paymentSource.type!==paymentResource)&&(setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()),setLoading(!1)}return()=>{setLoading(!0)}},[(_b=order==null?void 0:order.payment_method)===null||_b===void 0?void 0:_b.payment_source_type,show,paymentSource]);const gatewayConfig=Object.assign({readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet},p);switch(paymentResource){case"stripe_payments":return _jsx(StripeGateway,Object.assign({},gatewayConfig,{children}));case"adyen_payments":return _jsx(AdyenGateway,Object.assign({},gatewayConfig,{children}));case"braintree_payments":return _jsx(BraintreeGateway,Object.assign({},gatewayConfig,{children}));case"wire_transfers":return _jsx(WireTransferGateway,Object.assign({},gatewayConfig,{children}));case"paypal_payments":return _jsx(PaypalGateway,Object.assign({},gatewayConfig,{children}));case"checkout_com_payments":return _jsx(CheckoutComGateway,Object.assign({},gatewayConfig,{children}));default:return null}};export default PaymentGateway;
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LoaderType } from '../typings/index';
|
|
3
|
-
import { PaymentMethod as PaymentMethodType } from '@commercelayer/sdk';
|
|
4
|
-
declare type PaymentMethodProps = {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
activeClass?: string;
|
|
7
|
-
loader?: LoaderType;
|
|
8
|
-
} & Omit<JSX.IntrinsicElements['div'], 'onClick'> & ({
|
|
9
|
-
clickableContainer: true;
|
|
10
|
-
onClick?: (payment?: PaymentMethodType | Record<string, any>) => void;
|
|
11
|
-
} | {
|
|
12
|
-
clickableContainer?: never;
|
|
13
|
-
onClick?: never;
|
|
14
|
-
});
|
|
15
|
-
declare const PaymentMethod: FunctionComponent<PaymentMethodProps>;
|
|
16
|
-
export default PaymentMethod;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';import{LoaderType}from'../typings/index';import{PaymentMethod as PaymentMethodType}from'@commercelayer/sdk';declare type PaymentMethodProps={children:ReactNode;activeClass?:string;loader?:LoaderType;}&Omit<JSX.IntrinsicElements['div'],'onClick'>&({clickableContainer:true;onClick?:(payment?:PaymentMethodType|Record<string,any>)=>void;}|{clickableContainer?:never;onClick?:never;});declare const PaymentMethod:FunctionComponent<PaymentMethodProps>;export default PaymentMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useState,useEffect}from"react";import PaymentMethodContext from"../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import getLoaderComponent from"../utils/getLoaderComponent";const propTypes=components.PaymentMethod.propTypes,displayName=components.PaymentMethod.displayName,PaymentMethod=_a=>{var{children,className,activeClass,loader="Loading...",clickableContainer,onClick}=_a,p=__rest(_a,["children","className","activeClass","loader","clickableContainer","onClick"]);const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=useContext(PaymentMethodContext);useEffect(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components2=paymentMethods&&paymentMethods.map((payment,k)=>{const isActive=currentPaymentMethodId===(payment==null?void 0:payment.id),paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment,useContext,useState,useEffect}from"react";import PaymentMethodContext from"../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import getLoaderComponent from"../utils/getLoaderComponent";const propTypes=components.PaymentMethod.propTypes,displayName=components.PaymentMethod.displayName,PaymentMethod=_a=>{var{children,className,activeClass,loader="Loading...",clickableContainer,onClick}=_a,p=__rest(_a,["children","className","activeClass","loader","clickableContainer","onClick"]);const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder}=useContext(PaymentMethodContext);useEffect(()=>(paymentMethods&&setLoading(!1),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components2=paymentMethods&&paymentMethods.map((payment,k)=>{const isActive=currentPaymentMethodId===(payment==null?void 0:payment.id),paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment==null?void 0:payment.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment==null?void 0:payment.id;await setPaymentMethod({paymentResource,paymentMethodId}),onClick&&onClick(payment),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",Object.assign({"data-test-id":paymentResource,className:`${className} ${isActive?activeClass:""}`,onClick:onClickable},p,{children:_jsx(PaymentMethodChildrenContext.Provider,Object.assign({value:paymentMethodProps},{children}))}),k)});return loading?getLoaderComponent(loader):_jsx(Fragment,{children:components2})};PaymentMethod.propTypes=propTypes,PaymentMethod.displayName=displayName;export default PaymentMethod;
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BaseAmountComponent } from '../typings/index';
|
|
3
|
-
declare const PaymentMethodAmount: FunctionComponent<BaseAmountComponent>;
|
|
4
|
-
export default PaymentMethodAmount;
|
|
1
|
+
import{FunctionComponent}from'react';import{BaseAmountComponent}from'../typings/index';declare const PaymentMethodAmount:FunctionComponent<BaseAmountComponent>;export default PaymentMethodAmount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"./utils/BaseOrderPrice";import components from"../config/components";const propTypes=components.PaymentMethodAmount.propTypes,defaultProps=components.PaymentMethodAmount.defaultProps,displayName=components.PaymentMethodAmount.displayName,PaymentMethodAmount=props=>_jsx(BaseOrderPrice,Object.assign({base:"amount",type:"payment_method"},props)
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import BaseOrderPrice from"./utils/BaseOrderPrice";import components from"../config/components";const propTypes=components.PaymentMethodAmount.propTypes,defaultProps=components.PaymentMethodAmount.defaultProps,displayName=components.PaymentMethodAmount.displayName,PaymentMethodAmount=props=>_jsx(BaseOrderPrice,Object.assign({base:"amount",type:"payment_method"},props));PaymentMethodAmount.propTypes=propTypes,PaymentMethodAmount.defaultProps=defaultProps,PaymentMethodAmount.displayName=displayName;export default PaymentMethodAmount;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare type PaymentMethodNameChildrenProps = Omit<PaymentMethodNameProps, 'children'> & {
|
|
3
|
-
labelName: string;
|
|
4
|
-
};
|
|
5
|
-
declare type PaymentMethodNameProps = {
|
|
6
|
-
children?: (props: PaymentMethodNameChildrenProps) => ReactNode;
|
|
7
|
-
} & JSX.IntrinsicElements['label'];
|
|
8
|
-
declare const PaymentMethodName: FunctionComponent<PaymentMethodNameProps>;
|
|
9
|
-
export default PaymentMethodName;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';declare type PaymentMethodNameChildrenProps=Omit<PaymentMethodNameProps,'children'>&{labelName:string;};declare type PaymentMethodNameProps={children?:(props:PaymentMethodNameChildrenProps)=>ReactNode;}&JSX.IntrinsicElements['label'];declare const PaymentMethodName:FunctionComponent<PaymentMethodNameProps>;export default PaymentMethodName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodName.propTypes,displayName=components.PaymentMethodName.displayName,PaymentMethodName=props=>{const{payment}=useContext(PaymentMethodChildrenContext),labelName=payment==null?void 0:payment.name,htmlFor=payment==null?void 0:payment.payment_source_type,parentProps=Object.assign({htmlFor,labelName},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodName.propTypes,displayName=components.PaymentMethodName.displayName,PaymentMethodName=props=>{const{payment}=useContext(PaymentMethodChildrenContext),labelName=payment==null?void 0:payment.name,htmlFor=payment==null?void 0:payment.payment_source_type,parentProps=Object.assign({htmlFor,labelName},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("label",Object.assign({htmlFor},props,{children:labelName}))};PaymentMethodName.propTypes=propTypes,PaymentMethodName.displayName=displayName;export default PaymentMethodName;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BaseAmountComponent } from '../typings/index';
|
|
3
|
-
declare type Props = {
|
|
4
|
-
type?: 'amount';
|
|
5
|
-
labelFree?: string;
|
|
6
|
-
};
|
|
7
|
-
export declare type PaymentMethodPriceProps = BaseAmountComponent & Props;
|
|
8
|
-
declare const PaymentMethodPrice: FunctionComponent<PaymentMethodPriceProps>;
|
|
9
|
-
export default PaymentMethodPrice;
|
|
1
|
+
import{FunctionComponent}from'react';import{BaseAmountComponent}from'../typings/index';declare type Props={type?:'amount';labelFree?:string;};export declare type PaymentMethodPriceProps=BaseAmountComponent&Props;declare const PaymentMethodPrice:FunctionComponent<PaymentMethodPriceProps>;export default PaymentMethodPrice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../utils/getAmount";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodPrice.propTypes,displayName=components.PaymentMethodPrice.displayName,PaymentMethodPrice=props=>{const{format="formatted",type="amount",labelFree="Free"}=props,p=__rest(props,["format","type","labelFree"]),{payment}=useContext(PaymentMethodChildrenContext),[price,setPrice]=useState(""),[priceCents,setPriceCents]=useState(0);useEffect(()=>{if(payment){const p2=getAmount({base:"price",type,format,obj:payment});setPrice(p2);const c=getAmount({base:"price",type,format:"cents",obj:payment});setPriceCents(c)}return()=>{setPrice(""),setPriceCents(0)}},[payment]);const parentProps=Object.assign({labelFree,price,priceCents},p);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import getAmount from"../utils/getAmount";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentMethodPrice.propTypes,displayName=components.PaymentMethodPrice.displayName,PaymentMethodPrice=props=>{const{format="formatted",type="amount",labelFree="Free"}=props,p=__rest(props,["format","type","labelFree"]),{payment}=useContext(PaymentMethodChildrenContext),[price,setPrice]=useState(""),[priceCents,setPriceCents]=useState(0);useEffect(()=>{if(payment){const p2=getAmount({base:"price",type,format,obj:payment});setPrice(p2);const c=getAmount({base:"price",type,format:"cents",obj:payment});setPriceCents(c)}return()=>{setPrice(""),setPriceCents(0)}},[payment]);const parentProps=Object.assign({labelFree,price,priceCents},p);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("span",Object.assign({},p,{children:priceCents===0?labelFree:price}))};PaymentMethodPrice.propTypes=propTypes,PaymentMethodPrice.displayName=displayName;export default PaymentMethodPrice;
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PaymentMethod } from '@commercelayer/sdk';
|
|
3
|
-
declare type ShippingMethodRadioButtonChildrenProps = Omit<ShippingMethodRadioButtonProps, 'children'> & {
|
|
4
|
-
checked: boolean;
|
|
5
|
-
};
|
|
6
|
-
declare type ShippingMethodRadioButtonProps = {
|
|
7
|
-
children?: (props: ShippingMethodRadioButtonChildrenProps) => ReactNode;
|
|
8
|
-
onChange?: (payment?: PaymentMethod | Record<string, any>) => void;
|
|
9
|
-
} & JSX.IntrinsicElements['input'];
|
|
10
|
-
declare const PaymentMethodRadioButton: FunctionComponent<ShippingMethodRadioButtonProps>;
|
|
11
|
-
export default PaymentMethodRadioButton;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';import{PaymentMethod}from'@commercelayer/sdk';declare type ShippingMethodRadioButtonChildrenProps=Omit<ShippingMethodRadioButtonProps,'children'>&{checked:boolean;};declare type ShippingMethodRadioButtonProps={children?:(props:ShippingMethodRadioButtonChildrenProps)=>ReactNode;onChange?:(payment?:PaymentMethod|Record<string,any>)=>void;}&JSX.IntrinsicElements['input'];declare const PaymentMethodRadioButton:FunctionComponent<ShippingMethodRadioButtonProps>;export default PaymentMethodRadioButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import OrderContext from"../context/OrderContext";const propTypes=components.PaymentMethodRadioButton.propTypes,displayName=components.PaymentMethodRadioButton.displayName,PaymentMethodRadioButton=props=>{const{onChange}=props,p=__rest(props,["onChange"]),{payment,paymentSelected,setPaymentSelected,clickableContainer}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{setPaymentMethod,setLoading}=useContext(PaymentMethodContext),orderId=(order==null?void 0:order.id)||"",paymentResource=payment==null?void 0:payment.payment_source_type,paymentMethodId=payment==null?void 0:payment.id,name=`payment-${orderId}`,checked=paymentSelected===(payment==null?void 0:payment.id),handleOnChange=async e=>{e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer&&await setPaymentMethod({paymentResource,paymentMethodId}),onChange&&onChange(payment),setLoading({loading:!1})},id=payment==null?void 0:payment.payment_source_type,parentProps=Object.assign({handleOnChange,checked,id,name},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import Parent from"./utils/Parent";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import OrderContext from"../context/OrderContext";const propTypes=components.PaymentMethodRadioButton.propTypes,displayName=components.PaymentMethodRadioButton.displayName,PaymentMethodRadioButton=props=>{const{onChange}=props,p=__rest(props,["onChange"]),{payment,paymentSelected,setPaymentSelected,clickableContainer}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{setPaymentMethod,setLoading}=useContext(PaymentMethodContext),orderId=(order==null?void 0:order.id)||"",paymentResource=payment==null?void 0:payment.payment_source_type,paymentMethodId=payment==null?void 0:payment.id,name=`payment-${orderId}`,checked=paymentSelected===(payment==null?void 0:payment.id),handleOnChange=async e=>{e.stopPropagation(),setPaymentSelected&&setPaymentSelected(paymentMethodId),setLoading({loading:!0}),!clickableContainer&&await setPaymentMethod({paymentResource,paymentMethodId}),onChange&&onChange(payment),setLoading({loading:!1})},id=payment==null?void 0:payment.payment_source_type,parentProps=Object.assign({handleOnChange,checked,id,name},props);return props.children?_jsx(Parent,Object.assign({},parentProps,{children:props.children})):_jsx("input",Object.assign({type:"radio",id,onChange:handleOnChange,checked},p))};PaymentMethodRadioButton.propTypes=propTypes,PaymentMethodRadioButton.displayName=displayName;export default PaymentMethodRadioButton;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PaymentMethodConfig } from '../reducers/PaymentMethodReducer';
|
|
3
|
-
declare type PaymentMethodsContainerProps = {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
config?: PaymentMethodConfig;
|
|
6
|
-
};
|
|
7
|
-
declare const PaymentMethodsContainer: FunctionComponent<PaymentMethodsContainerProps>;
|
|
8
|
-
export default PaymentMethodsContainer;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';import{PaymentMethodConfig}from'../reducers/PaymentMethodReducer';declare type PaymentMethodsContainerProps={children:ReactNode;config?:PaymentMethodConfig;};declare const PaymentMethodsContainer:FunctionComponent<PaymentMethodsContainerProps>;export default PaymentMethodsContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig}from"../reducers/PaymentMethodReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{isEmpty}from"lodash";import{setPaymentRef}from"../reducers/PaymentMethodReducer";const propTypes=components.PaymentMethodsContainer.propTypes,displayName=components.PaymentMethodsContainer.displayName,PaymentMethodsContainer=props=>{const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useContext(OrderContext),credentials=useContext(CommerceLayerContext);useEffect(()=>{(include==null?void 0:include.includes("available_payment_methods"))?(includeLoaded==null?void 0:includeLoaded.available_payment_methods)||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPaymentMethods({order,dispatch}),credentials&&(order==null?void 0:order.payment_source)&&dispatch({type:"setPaymentSource",payload:{paymentSource:order==null?void 0:order.payment_source}})},[order,credentials,include,includeLoaded]);const contextValue=useMemo(()=>Object.assign(Object.assign({},state),{setLoading:({loading})=>defaultPaymentMethodContext.setLoading({loading,dispatch}),setPaymentRef:({ref})=>setPaymentRef({ref,dispatch}),setPaymentMethodErrors:errors=>defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch),setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod(Object.assign(Object.assign({},args),{config:credentials,updateOrder,order,dispatch,setOrderErrors})),setPaymentSource:async args=>defaultPaymentMethodContext.setPaymentSource(Object.assign(Object.assign(Object.assign({},state),args),{config:credentials,dispatch,getOrder,updateOrder,order})),updatePaymentSource:async args=>defaultPaymentMethodContext.updatePaymentSource(Object.assign(Object.assign({},args),{config:credentials,dispatch})),destroyPaymentSource:async args=>defaultPaymentMethodContext.destroyPaymentSource(Object.assign(Object.assign({},args),{dispatch,config:credentials}))}),[state]);return _jsx(PaymentMethodContext.Provider,Object.assign({value:contextValue},{children})
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig}from"../reducers/PaymentMethodReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{isEmpty}from"lodash";import{setPaymentRef}from"../reducers/PaymentMethodReducer";const propTypes=components.PaymentMethodsContainer.propTypes,displayName=components.PaymentMethodsContainer.displayName,PaymentMethodsContainer=props=>{const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useContext(OrderContext),credentials=useContext(CommerceLayerContext);useEffect(()=>{(include==null?void 0:include.includes("available_payment_methods"))?(includeLoaded==null?void 0:includeLoaded.available_payment_methods)||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPaymentMethods({order,dispatch}),credentials&&(order==null?void 0:order.payment_source)&&dispatch({type:"setPaymentSource",payload:{paymentSource:order==null?void 0:order.payment_source}})},[order,credentials,include,includeLoaded]);const contextValue=useMemo(()=>Object.assign(Object.assign({},state),{setLoading:({loading})=>defaultPaymentMethodContext.setLoading({loading,dispatch}),setPaymentRef:({ref})=>setPaymentRef({ref,dispatch}),setPaymentMethodErrors:errors=>defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch),setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod(Object.assign(Object.assign({},args),{config:credentials,updateOrder,order,dispatch,setOrderErrors})),setPaymentSource:async args=>defaultPaymentMethodContext.setPaymentSource(Object.assign(Object.assign(Object.assign({},state),args),{config:credentials,dispatch,getOrder,updateOrder,order})),updatePaymentSource:async args=>defaultPaymentMethodContext.updatePaymentSource(Object.assign(Object.assign({},args),{config:credentials,dispatch})),destroyPaymentSource:async args=>defaultPaymentMethodContext.destroyPaymentSource(Object.assign(Object.assign({},args),{dispatch,config:credentials}))}),[state]);return _jsx(PaymentMethodContext.Provider,Object.assign({value:contextValue},{children}))};PaymentMethodsContainer.propTypes=propTypes,PaymentMethodsContainer.displayName=displayName;export default PaymentMethodsContainer;
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { LoaderType } from '../typings/index';
|
|
3
|
-
import { CustomerCardsTemplateChildren } from './utils/PaymentCardsTemplate';
|
|
4
|
-
export declare type CustomerCardsProps = {
|
|
5
|
-
handleClick: () => void;
|
|
6
|
-
};
|
|
7
|
-
export declare type CustomerSaveToWalletProps = {
|
|
8
|
-
name: 'save_payment_source_to_customer_wallet';
|
|
9
|
-
};
|
|
10
|
-
export declare type PaymentSourceProps = {
|
|
11
|
-
children?: ReactNode;
|
|
12
|
-
readonly?: boolean;
|
|
13
|
-
templateCustomerCards?: CustomerCardsTemplateChildren;
|
|
14
|
-
onClickCustomerCards?: () => void;
|
|
15
|
-
templateCustomerSaveToWallet?: (props: CustomerSaveToWalletProps) => ReactNode;
|
|
16
|
-
loader?: LoaderType;
|
|
17
|
-
} & JSX.IntrinsicElements['div'];
|
|
18
|
-
declare const PaymentSource: FunctionComponent<PaymentSourceProps>;
|
|
19
|
-
export default PaymentSource;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';import{LoaderType}from'../typings/index';import{CustomerCardsTemplateChildren}from'./utils/PaymentCardsTemplate';export declare type CustomerCardsProps={handleClick:()=>void;};export declare type CustomerSaveToWalletProps={name:'save_payment_source_to_customer_wallet';};export declare type PaymentSourceProps={children?:ReactNode;readonly?:boolean;templateCustomerCards?:CustomerCardsTemplateChildren;onClickCustomerCards?:()=>void;templateCustomerSaveToWallet?:(props:CustomerSaveToWalletProps)=>ReactNode;loader?:LoaderType;}&JSX.IntrinsicElements['div'];declare const PaymentSource:FunctionComponent<PaymentSourceProps>;export default PaymentSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import CustomerContext from"../context/CustomerContext";import PaymentGateway from"./PaymentGateway";import getCardDetails from"../utils/getCardDetails";const propTypes=components.PaymentSource.propTypes,displayName=components.PaymentSource.displayName,PaymentSource=props=>{const{readonly}=props,{payment}=useContext(PaymentMethodChildrenContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):(payment==null?void 0:payment.id)===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment==null?void 0:payment.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!1),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly]);const handleEditClick=e=>{e.stopPropagation(),paymentSource&&destroyPaymentSource({paymentSourceId:paymentSource==null?void 0:paymentSource.id,paymentResource:payment==null?void 0:payment.payment_source_type}),setShowCard(!showCard),setShow(!0)},gatewayProps=Object.assign(Object.assign({},props),{show,showCard,handleEditClick,readonly});return _jsx(PaymentGateway,Object.assign({},gatewayProps)
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../context/PaymentMethodChildrenContext";import components from"../config/components";import PaymentMethodContext from"../context/PaymentMethodContext";import CustomerContext from"../context/CustomerContext";import PaymentGateway from"./PaymentGateway";import getCardDetails from"../utils/getCardDetails";const propTypes=components.PaymentSource.propTypes,displayName=components.PaymentSource.displayName,PaymentSource=props=>{const{readonly}=props,{payment}=useContext(PaymentMethodChildrenContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):(payment==null?void 0:payment.id)===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment==null?void 0:payment.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!1),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly]);const handleEditClick=e=>{e.stopPropagation(),paymentSource&&destroyPaymentSource({paymentSourceId:paymentSource==null?void 0:paymentSource.id,paymentResource:payment==null?void 0:payment.payment_source_type}),setShowCard(!showCard),setShow(!0)},gatewayProps=Object.assign(Object.assign({},props),{show,showCard,handleEditClick,readonly});return _jsx(PaymentGateway,Object.assign({},gatewayProps))};PaymentSource.propTypes=propTypes,PaymentSource.displayName=displayName;export default PaymentSource;
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FunctionComponent } from 'react';
|
|
3
|
-
import { FunctionChildren } from '../typings/index';
|
|
4
|
-
declare type CustomComponent = FunctionChildren<Omit<Props & {
|
|
5
|
-
brand: IconBrand;
|
|
6
|
-
defaultSrc: string;
|
|
7
|
-
url: string;
|
|
8
|
-
}, 'children'>>;
|
|
9
|
-
declare type Props = {
|
|
10
|
-
children?: CustomComponent;
|
|
11
|
-
width?: number;
|
|
12
|
-
height?: number;
|
|
13
|
-
} & JSX.IntrinsicElements['img'];
|
|
14
|
-
declare const PaymentSourceBrandIcon: FunctionComponent<Props>;
|
|
15
|
-
export default PaymentSourceBrandIcon;
|
|
1
|
+
import{IconBrand}from'../context/PaymentSourceContext';import{FunctionComponent}from'react';import{FunctionChildren}from'../typings/index';declare type CustomComponent=FunctionChildren<Omit<Props&{brand:IconBrand;defaultSrc:string;url:string;},'children'>>;declare type Props={children?:CustomComponent;width?:number;height?:number;}&JSX.IntrinsicElements['img'];declare const PaymentSourceBrandIcon:FunctionComponent<Props>;export default PaymentSourceBrandIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext,useRef}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandIcon.propTypes,displayName=components.PaymentSourceBrandIcon.displayName,PaymentSourceBrandIcon=_a=>{var{src,width=32,children}=_a,p=__rest(_a,["src","width","children"]);const{brand}=useContext(PaymentSourceContext),ref=useRef(null),defaultSrc="//data.commercelayer.app/assets/images/icons/credit-cards/color/credit-card.svg",url=src||`//data.commercelayer.app/assets/images/icons/credit-cards/color/${brand}.svg`,handleError=()=>{ref.current&&(ref.current.src=defaultSrc)},parentProps=Object.assign({brand,defaultSrc,url,width},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext,useRef}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandIcon.propTypes,displayName=components.PaymentSourceBrandIcon.displayName,PaymentSourceBrandIcon=_a=>{var{src,width=32,children}=_a,p=__rest(_a,["src","width","children"]);const{brand}=useContext(PaymentSourceContext),ref=useRef(null),defaultSrc="//data.commercelayer.app/assets/images/icons/credit-cards/color/credit-card.svg",url=src||`//data.commercelayer.app/assets/images/icons/credit-cards/color/${brand}.svg`,handleError=()=>{ref.current&&(ref.current.src=defaultSrc)},parentProps=Object.assign({brand,defaultSrc,url,width},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("img",Object.assign({ref,src:url,onError:handleError,width},p))};PaymentSourceBrandIcon.propTypes=propTypes,PaymentSourceBrandIcon.displayName=displayName;export default PaymentSourceBrandIcon;
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FunctionComponent } from 'react';
|
|
3
|
-
import { FunctionChildren } from '../typings/index';
|
|
4
|
-
declare type CustomComponent = FunctionChildren<Omit<Props & {
|
|
5
|
-
brand: IconBrand;
|
|
6
|
-
}, 'children'>>;
|
|
7
|
-
declare type Props = {
|
|
8
|
-
children?: CustomComponent;
|
|
9
|
-
label?: string;
|
|
10
|
-
} & JSX.IntrinsicElements['span'];
|
|
11
|
-
declare const PaymentSourceBrandName: FunctionComponent<Props>;
|
|
12
|
-
export default PaymentSourceBrandName;
|
|
1
|
+
import{IconBrand}from'../context/PaymentSourceContext';import{FunctionComponent}from'react';import{FunctionChildren}from'../typings/index';declare type CustomComponent=FunctionChildren<Omit<Props&{brand:IconBrand;},'children'>>;declare type Props={children?:CustomComponent;label?:string;}&JSX.IntrinsicElements['span'];declare const PaymentSourceBrandName:FunctionComponent<Props>;export default PaymentSourceBrandName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{capitalize}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandName.propTypes,displayName=components.PaymentSourceBrandName.displayName,PaymentSourceBrandName=_a=>{var{children,label}=_a,props=__rest(_a,["children","label"]);const{brand}=useContext(PaymentSourceContext),brandName=brand&&capitalize(brand.replace("-"," ")),parentProps=Object.assign({brand:brandName,label},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{capitalize}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const propTypes=components.PaymentSourceBrandName.propTypes,displayName=components.PaymentSourceBrandName.displayName,PaymentSourceBrandName=_a=>{var{children,label}=_a,props=__rest(_a,["children","label"]);const{brand}=useContext(PaymentSourceContext),brandName=brand&&capitalize(brand.replace("-"," ")),parentProps=Object.assign({brand:brandName,label},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},props,{children:label||capitalize(brandName)}))};PaymentSourceBrandName.propTypes=propTypes,PaymentSourceBrandName.displayName=displayName;export default PaymentSourceBrandName;
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FunctionChildren } from '../typings/index';
|
|
3
|
-
export declare type PaymentSourceDetailType = 'last4' | 'exp_year' | 'exp_month';
|
|
4
|
-
declare type CustomComponent = FunctionChildren<Omit<Props & {
|
|
5
|
-
text: string;
|
|
6
|
-
}, 'children'>>;
|
|
7
|
-
declare type Props = {
|
|
8
|
-
children?: CustomComponent;
|
|
9
|
-
type: PaymentSourceDetailType;
|
|
10
|
-
} & JSX.IntrinsicElements['span'];
|
|
11
|
-
declare const PaymentSourceDetail: FunctionComponent<Props>;
|
|
12
|
-
export default PaymentSourceDetail;
|
|
1
|
+
import{FunctionComponent}from'react';import{FunctionChildren}from'../typings/index';export declare type PaymentSourceDetailType='last4'|'exp_year'|'exp_month';declare type CustomComponent=FunctionChildren<Omit<Props&{text:string;},'children'>>;declare type Props={children?:CustomComponent;type:PaymentSourceDetailType;}&JSX.IntrinsicElements['span'];declare const PaymentSourceDetail:FunctionComponent<Props>;export default PaymentSourceDetail;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import components from"../config/components";import PaymentSourceContext from"../context/PaymentSourceContext";import{has}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";const propTypes=components.PaymentSourceDetail.propTypes,displayName=components.PaymentSourceDetail.displayName,PaymentSourceDetail=_a=>{var{type,children}=_a,p=__rest(_a,["type","children"]);const card=useContext(PaymentSourceContext),text=has(card,type)?card[type]:type==="last4"?"****":"**",parentProps=Object.assign({type,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import components from"../config/components";import PaymentSourceContext from"../context/PaymentSourceContext";import{has}from"lodash";import{useContext}from"react";import Parent from"./utils/Parent";const propTypes=components.PaymentSourceDetail.propTypes,displayName=components.PaymentSourceDetail.displayName,PaymentSourceDetail=_a=>{var{type,children}=_a,p=__rest(_a,["type","children"]);const card=useContext(PaymentSourceContext),text=has(card,type)?card[type]:type==="last4"?"****":"**",parentProps=Object.assign({type,text},p);return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("span",Object.assign({},p,{children:text}))};PaymentSourceDetail.propTypes=propTypes,PaymentSourceDetail.displayName=displayName;export default PaymentSourceDetail;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FunctionChildren } from '../typings/index';
|
|
3
|
-
declare type CustomComponent = FunctionChildren<Omit<Props, 'children'>>;
|
|
4
|
-
declare type Props = {
|
|
5
|
-
children?: CustomComponent;
|
|
6
|
-
label?: string | ReactNode;
|
|
7
|
-
} & Omit<JSX.IntrinsicElements['button'], 'onClick'>;
|
|
8
|
-
declare const PaymentSourceEditButton: FunctionComponent<Props>;
|
|
9
|
-
export default PaymentSourceEditButton;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';import{FunctionChildren}from'../typings/index';declare type CustomComponent=FunctionChildren<Omit<Props,'children'>>;declare type Props={children?:CustomComponent;label?:string|ReactNode;}&Omit<JSX.IntrinsicElements['button'],'onClick'>;declare const PaymentSourceEditButton:FunctionComponent<Props>;export default PaymentSourceEditButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const displayName=components.PaymentSourceEditButton.displayName,propTypes=components.PaymentSourceEditButton.propTypes,PaymentSourceEditButton=_a=>{var{children,label="Edit"}=_a,props=__rest(_a,["children","label"]);const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps=Object.assign({showCard,label,handleEditClick},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../context/PaymentSourceContext";import{useContext}from"react";import Parent from"./utils/Parent";import components from"../config/components";const displayName=components.PaymentSourceEditButton.displayName,propTypes=components.PaymentSourceEditButton.propTypes,PaymentSourceEditButton=_a=>{var{children,label="Edit"}=_a,props=__rest(_a,["children","label"]);const{showCard,handleEditClick,readonly}=useContext(PaymentSourceContext),parentProps=Object.assign({showCard,label,handleEditClick},props);return children?_jsx(Parent,Object.assign({},parentProps,{children})):readonly?null:_jsx("button",Object.assign({},props,{onClick:handleEditClick},{children:label}))};PaymentSourceEditButton.propTypes=propTypes,PaymentSourceEditButton.displayName=displayName;export default PaymentSourceEditButton;
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare type PaypalConfig = {
|
|
3
|
-
return_url: string;
|
|
4
|
-
cancel_url: string;
|
|
5
|
-
infoMessage?: {
|
|
6
|
-
text?: string | ReactNode;
|
|
7
|
-
className?: string;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
declare type Props = Omit<PaypalConfig, 'return_url' | 'cancel_url'> & JSX.IntrinsicElements['div'];
|
|
11
|
-
declare const PaypalPayment: FunctionComponent<Props>;
|
|
12
|
-
export default PaypalPayment;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';export declare type PaypalConfig={return_url:string;cancel_url:string;infoMessage?:{text?:string|ReactNode;className?:string;};};declare type Props=Omit<PaypalConfig,'return_url'|'cancel_url'>&JSX.IntrinsicElements['div'];declare const PaypalPayment:FunctionComponent<Props>;export default PaypalPayment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext from"../context/PaymentMethodContext";import isFunction from"lodash/isFunction";import{useContext,useEffect,useRef}from"react";const defaultMessage="by placing the order, you will be redirected to the PayPal website to sign in and authorize the payment",PaypalPayment=_a=>{var{infoMessage}=_a,p=__rest(_a,["infoMessage"]);const ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&¤tPaymentMethodType&&(paymentSource==null?void 0:paymentSource.approval_url)&&(ref.current.onsubmit=()=>handleClick(),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType]);const handleClick=async()=>{if(paymentSource&¤tPaymentMethodType)try{return await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{metadata:{card:{id:paymentSource.id,brand:"paypal",last4:""}}}}),!0}catch{return!1}return!1};return _jsx("form",Object.assign({ref},{children:_jsx("div",Object.assign({},p,{children:_jsx("span",Object.assign({className:infoMessage==null?void 0:infoMessage.className},{children:isFunction(infoMessage==null?void 0:infoMessage.text)?infoMessage==null?void 0:infoMessage.text():(infoMessage==null?void 0:infoMessage.text)||defaultMessage})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext from"../context/PaymentMethodContext";import isFunction from"lodash/isFunction";import{useContext,useEffect,useRef}from"react";const defaultMessage="by placing the order, you will be redirected to the PayPal website to sign in and authorize the payment",PaypalPayment=_a=>{var{infoMessage}=_a,p=__rest(_a,["infoMessage"]);const ref=useRef(null),{setPaymentSource,paymentSource,currentPaymentMethodType,setPaymentRef}=useContext(PaymentMethodContext);useEffect(()=>(ref.current&&paymentSource&¤tPaymentMethodType&&(paymentSource==null?void 0:paymentSource.approval_url)&&(ref.current.onsubmit=()=>handleClick(),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,paymentSource,currentPaymentMethodType]);const handleClick=async()=>{if(paymentSource&¤tPaymentMethodType)try{return await setPaymentSource({paymentSourceId:paymentSource.id,paymentResource:currentPaymentMethodType,attributes:{metadata:{card:{id:paymentSource.id,brand:"paypal",last4:""}}}}),!0}catch{return!1}return!1};return _jsx("form",Object.assign({ref},{children:_jsx("div",Object.assign({},p,{children:_jsx("span",Object.assign({className:infoMessage==null?void 0:infoMessage.className},{children:isFunction(infoMessage==null?void 0:infoMessage.text)?infoMessage==null?void 0:infoMessage.text():(infoMessage==null?void 0:infoMessage.text)||defaultMessage}))}))}))};export default PaypalPayment;
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FunctionChildren } from '../typings/index';
|
|
3
|
-
declare type PlaceOrderButtonChildrenProps = FunctionChildren<Omit<PlaceOrderButtonProps, 'children'>>;
|
|
4
|
-
declare type PlaceOrderButtonProps = {
|
|
5
|
-
children?: PlaceOrderButtonChildrenProps;
|
|
6
|
-
label?: string | ReactNode;
|
|
7
|
-
onClick?: (response: {
|
|
8
|
-
placed: boolean;
|
|
9
|
-
}) => void;
|
|
10
|
-
} & JSX.IntrinsicElements['button'];
|
|
11
|
-
declare const PlaceOrderButton: FunctionComponent<PlaceOrderButtonProps>;
|
|
12
|
-
export default PlaceOrderButton;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';import{FunctionChildren}from'../typings/index';declare type PlaceOrderButtonChildrenProps=FunctionChildren<Omit<PlaceOrderButtonProps,'children'>>;declare type PlaceOrderButtonProps={children?:PlaceOrderButtonChildrenProps;label?:string|ReactNode;onClick?:(response:{placed:boolean;})=>void;}&JSX.IntrinsicElements['button'];declare const PlaceOrderButton:FunctionComponent<PlaceOrderButtonProps>;export default PlaceOrderButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import Parent from"./utils/Parent";import components from"../config/components";import PlaceOrderContext from"../context/PlaceOrderContext";import isFunction from"lodash/isFunction";import PaymentMethodContext from"../context/PaymentMethodContext";import OrderContext from"../context/OrderContext";import getCardDetails from"../utils/getCardDetails";const propTypes=components.PlaceOrderButton.propTypes,defaultProps=components.PlaceOrderButton.defaultProps,displayName=components.PlaceOrderButton.displayName,PlaceOrderButton=props=>{var _a;const{children,label="Place order",disabled,onClick}=props,p=__rest(props,["children","label","disabled","onClick"]),{isPermitted,setPlaceOrder,options,paymentType}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,paymentSource,loading,currentPaymentMethodType}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),isFree=(order==null?void 0:order.total_amount_with_taxes_cents)===0;useEffect(()=>{var _a2;if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});(isFree||((_a2=currentPaymentMethodRef==null?void 0:currentPaymentMethodRef.current)===null||_a2===void 0?void 0:_a2.onsubmit)||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!isFree);return()=>{setNotPermitted(!0)}},[isPermitted,paymentType,(_a=currentPaymentMethodRef==null?void 0:currentPaymentMethodRef.current)===null||_a===void 0?void 0:_a.onsubmit,paymentSource,loading,currentPaymentMethodType,order]),useEffect(()=>{paymentType==="paypal_payments"&&(options==null?void 0:options.paypalPayerId)&&(order==null?void 0:order.status)&&["draft","pending"].includes(order==null?void 0:order.status)&&handleClick()},[options==null?void 0:options.paypalPayerId]),useEffect(()=>{var _a2,_b;paymentType==="adyen_payments"&&((_a2=options==null?void 0:options.adyen)===null||_a2===void 0?void 0:_a2.MD)&&((_b=options==null?void 0:options.adyen)===null||_b===void 0?void 0:_b.PaRes)&&(order==null?void 0:order.status)&&["draft","pending"].includes(order==null?void 0:order.status)&&handleClick()},[options==null?void 0:options.adyen]),useEffect(()=>{var _a2;paymentType==="checkout_com_payments"&&((_a2=options==null?void 0:options.checkoutCom)===null||_a2===void 0?void 0:_a2.session_id)&&(order==null?void 0:order.status)&&["draft","pending"].includes(order==null?void 0:order.status)&&handleClick()},[options==null?void 0:options.checkoutCom]);const handleClick=async()=>{var _a2,_b,_c,_d;let isValid=!0;setForceDisable(!0);const card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:paymentSource}});((_a2=currentPaymentMethodRef==null?void 0:currentPaymentMethodRef.current)===null||_a2===void 0?void 0:_a2.onsubmit)&&[!(options==null?void 0:options.paypalPayerId),!((_b=options==null?void 0:options.adyen)===null||_b===void 0?void 0:_b.MD),!((_c=options==null?void 0:options.checkoutCom)===null||_c===void 0?void 0:_c.session_id)].every(Boolean)?isValid=await((_d=currentPaymentMethodRef.current)===null||_d===void 0?void 0:_d.onsubmit()):(card==null?void 0:card.brand)&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(paymentSource||isFree)&&await setPlaceOrder({paymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps=Object.assign(Object.assign({},p),{label,disabled:disabledButton,handleClick});return children?_jsx(Parent,Object.assign({},parentProps,{children})
|
|
1
|
+
import{__rest}from"tslib";import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useEffect,useState}from"react";import Parent from"./utils/Parent";import components from"../config/components";import PlaceOrderContext from"../context/PlaceOrderContext";import isFunction from"lodash/isFunction";import PaymentMethodContext from"../context/PaymentMethodContext";import OrderContext from"../context/OrderContext";import getCardDetails from"../utils/getCardDetails";const propTypes=components.PlaceOrderButton.propTypes,defaultProps=components.PlaceOrderButton.defaultProps,displayName=components.PlaceOrderButton.displayName,PlaceOrderButton=props=>{var _a;const{children,label="Place order",disabled,onClick}=props,p=__rest(props,["children","label","disabled","onClick"]),{isPermitted,setPlaceOrder,options,paymentType}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),{currentPaymentMethodRef,paymentSource,loading,currentPaymentMethodType}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),isFree=(order==null?void 0:order.total_amount_with_taxes_cents)===0;useEffect(()=>{var _a2;if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});(isFree||((_a2=currentPaymentMethodRef==null?void 0:currentPaymentMethodRef.current)===null||_a2===void 0?void 0:_a2.onsubmit)||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!isFree);return()=>{setNotPermitted(!0)}},[isPermitted,paymentType,(_a=currentPaymentMethodRef==null?void 0:currentPaymentMethodRef.current)===null||_a===void 0?void 0:_a.onsubmit,paymentSource,loading,currentPaymentMethodType,order]),useEffect(()=>{paymentType==="paypal_payments"&&(options==null?void 0:options.paypalPayerId)&&(order==null?void 0:order.status)&&["draft","pending"].includes(order==null?void 0:order.status)&&handleClick()},[options==null?void 0:options.paypalPayerId,paymentType]),useEffect(()=>{var _a2,_b;paymentType==="adyen_payments"&&((_a2=options==null?void 0:options.adyen)===null||_a2===void 0?void 0:_a2.MD)&&((_b=options==null?void 0:options.adyen)===null||_b===void 0?void 0:_b.PaRes)&&(order==null?void 0:order.status)&&["draft","pending"].includes(order==null?void 0:order.status)&&handleClick()},[options==null?void 0:options.adyen,paymentType]),useEffect(()=>{var _a2;paymentType==="checkout_com_payments"&&((_a2=options==null?void 0:options.checkoutCom)===null||_a2===void 0?void 0:_a2.session_id)&&(order==null?void 0:order.status)&&["draft","pending"].includes(order==null?void 0:order.status)&&handleClick()},[options==null?void 0:options.checkoutCom,paymentType]);const handleClick=async()=>{var _a2,_b,_c,_d;let isValid=!0;setForceDisable(!0);const card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:paymentSource}});((_a2=currentPaymentMethodRef==null?void 0:currentPaymentMethodRef.current)===null||_a2===void 0?void 0:_a2.onsubmit)&&[!(options==null?void 0:options.paypalPayerId),!((_b=options==null?void 0:options.adyen)===null||_b===void 0?void 0:_b.MD),!((_c=options==null?void 0:options.checkoutCom)===null||_c===void 0?void 0:_c.session_id)].every(Boolean)?isValid=await((_d=currentPaymentMethodRef.current)===null||_d===void 0?void 0:_d.onsubmit()):(card==null?void 0:card.brand)&&(isValid=!0);const placed=isValid&&setPlaceOrder&&(paymentSource||isFree)&&await setPlaceOrder({paymentSource});setForceDisable(!1),onClick&&placed&&onClick(placed)},disabledButton=disabled!==void 0?disabled:notPermitted,parentProps=Object.assign(Object.assign({},p),{label,disabled:disabledButton,handleClick});return children?_jsx(Parent,Object.assign({},parentProps,{children})):_jsx("button",Object.assign({type:"button",disabled:disabledButton||forceDisable,onClick:handleClick},p,{children:isFunction(label)?label():label}))};PlaceOrderButton.propTypes=propTypes,PlaceOrderButton.defaultProps=defaultProps,PlaceOrderButton.displayName=displayName;export default PlaceOrderButton;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PlaceOrderOptions } from '../reducers/PlaceOrderReducer';
|
|
3
|
-
declare type PlaceOrderContainerProps = {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
options?: PlaceOrderOptions;
|
|
6
|
-
};
|
|
7
|
-
declare const PlaceOrderContainer: FunctionComponent<PlaceOrderContainerProps>;
|
|
8
|
-
export default PlaceOrderContainer;
|
|
1
|
+
import{FunctionComponent,ReactNode}from'react';import{PlaceOrderOptions}from'../reducers/PlaceOrderReducer';declare type PlaceOrderContainerProps={children:ReactNode;options?:PlaceOrderOptions;};declare const PlaceOrderContainer:FunctionComponent<PlaceOrderContainerProps>;export default PlaceOrderContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import PlaceOrderContext from"../context/PlaceOrderContext";import{useContext,useEffect,useReducer}from"react";import placeOrderReducer,{placeOrderInitialState,placeOrderPermitted}from"../reducers/PlaceOrderReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{setPlaceOrder}from"../reducers/PlaceOrderReducer";const propTypes=components.PlaceOrderContainer.propTypes,displayName=components.PlaceOrderContainer.displayName,PlaceOrderContainer=props=>{const{children,options}=props,[state,dispatch]=useReducer(placeOrderReducer,placeOrderInitialState),{order,setOrderErrors,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{(include==null?void 0:include.includes("shipments.available_shipping_methods"))?(includeLoaded==null?void 0:includeLoaded["shipments.available_shipping_methods"])||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.shipment_line_items.line_item","shipments.shipping_method","shipments.stock_transfers","shipments.stock_location"]}),(include==null?void 0:include.includes("billing_address"))?(includeLoaded==null?void 0:includeLoaded.billing_address)||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),(include==null?void 0:include.includes("shipping_address"))?(includeLoaded==null?void 0:includeLoaded.shipping_address)||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address",resourcesIncluded:include}),order&&placeOrderPermitted({config,dispatch,order,options:Object.assign({},options)})},[order,include,includeLoaded]);const contextValue=Object.assign(Object.assign({},state),{setPlaceOrder:({paymentSource})=>setPlaceOrder({config,order,state,setOrderErrors,paymentSource}),placeOrderPermitted:()=>placeOrderPermitted({config,dispatch,order,options:Object.assign({},options)})});return _jsx(PlaceOrderContext.Provider,Object.assign({value:contextValue},{children})
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PlaceOrderContext from"../context/PlaceOrderContext";import{useContext,useEffect,useReducer}from"react";import placeOrderReducer,{placeOrderInitialState,placeOrderPermitted}from"../reducers/PlaceOrderReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{setPlaceOrder}from"../reducers/PlaceOrderReducer";const propTypes=components.PlaceOrderContainer.propTypes,displayName=components.PlaceOrderContainer.displayName,PlaceOrderContainer=props=>{const{children,options}=props,[state,dispatch]=useReducer(placeOrderReducer,placeOrderInitialState),{order,setOrderErrors,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{(include==null?void 0:include.includes("shipments.available_shipping_methods"))?(includeLoaded==null?void 0:includeLoaded["shipments.available_shipping_methods"])||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.shipment_line_items.line_item","shipments.shipping_method","shipments.stock_transfers","shipments.stock_location"]}),(include==null?void 0:include.includes("billing_address"))?(includeLoaded==null?void 0:includeLoaded.billing_address)||addResourceToInclude({newResourceLoaded:{billing_address:!0}}):addResourceToInclude({newResource:"billing_address"}),(include==null?void 0:include.includes("shipping_address"))?(includeLoaded==null?void 0:includeLoaded.shipping_address)||addResourceToInclude({newResourceLoaded:{shipping_address:!0}}):addResourceToInclude({newResource:"shipping_address",resourcesIncluded:include}),order&&placeOrderPermitted({config,dispatch,order,options:Object.assign({},options)})},[order,include,includeLoaded]);const contextValue=Object.assign(Object.assign({},state),{setPlaceOrder:({paymentSource})=>setPlaceOrder({config,order,state,setOrderErrors,paymentSource}),placeOrderPermitted:()=>placeOrderPermitted({config,dispatch,order,options:Object.assign({},options)})});return _jsx(PlaceOrderContext.Provider,Object.assign({value:contextValue},{children}))};PlaceOrderContainer.propTypes=propTypes,PlaceOrderContainer.displayName=displayName;export default PlaceOrderContainer;
|