@commercelayer/react-components 4.4.0-beta.2 → 4.4.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/ExternalFunction.js +1 -1
- package/lib/cjs/components/MetadataInput.js +1 -1
- package/lib/cjs/components/SubmitButton.js +1 -1
- package/lib/cjs/components/addresses/Address.js +1 -1
- package/lib/cjs/components/addresses/AddressCountrySelector.js +1 -1
- package/lib/cjs/components/addresses/AddressField.js +1 -1
- package/lib/cjs/components/addresses/AddressInput.js +1 -1
- package/lib/cjs/components/addresses/AddressStateSelector.js +1 -1
- package/lib/cjs/components/addresses/AddressesContainer.js +1 -1
- package/lib/cjs/components/addresses/AddressesEmpty.js +1 -1
- package/lib/cjs/components/addresses/BillingAddressContainer.js +1 -1
- package/lib/cjs/components/addresses/BillingAddressForm.js +1 -1
- package/lib/cjs/components/addresses/SaveAddressesButton.js +1 -1
- package/lib/cjs/components/addresses/ShippingAddressContainer.js +1 -1
- package/lib/cjs/components/addresses/ShippingAddressForm.js +1 -1
- package/lib/cjs/components/auth/CommerceLayer.js +1 -1
- package/lib/cjs/components/customers/CustomerAddressForm.js +1 -1
- package/lib/cjs/components/customers/CustomerContainer.js +1 -1
- package/lib/cjs/components/customers/CustomerField.js +1 -1
- package/lib/cjs/components/customers/CustomerInput.js +1 -1
- package/lib/cjs/components/customers/CustomerPaymentSource.js +1 -1
- package/lib/cjs/components/customers/CustomerPaymentSourceEmpty.js +1 -1
- package/lib/cjs/components/customers/SaveCustomerButton.js +1 -1
- package/lib/cjs/components/errors/Errors.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCard.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardContainer.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardCurrencySelector.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardInput.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponCode.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponForm.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponInput.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponRemoveButton.js +1 -1
- package/lib/cjs/components/gift_cards/GiftCardOrCouponSubmit.js +1 -1
- package/lib/cjs/components/line_items/LineItem.js +1 -1
- package/lib/cjs/components/line_items/LineItemAmount.js +1 -1
- package/lib/cjs/components/line_items/LineItemCode.js +1 -1
- package/lib/cjs/components/line_items/LineItemField.js +1 -1
- package/lib/cjs/components/line_items/LineItemImage.js +1 -1
- package/lib/cjs/components/line_items/LineItemName.js +1 -1
- package/lib/cjs/components/line_items/LineItemOption.js +1 -1
- package/lib/cjs/components/line_items/LineItemOptions.js +1 -1
- package/lib/cjs/components/line_items/LineItemQuantity.js +1 -1
- package/lib/cjs/components/line_items/LineItemRemoveLink.js +1 -1
- package/lib/cjs/components/line_items/LineItemsContainer.js +1 -1
- package/lib/cjs/components/line_items/LineItemsCount.js +1 -1
- package/lib/cjs/components/line_items/LineItemsEmpty.js +1 -1
- package/lib/cjs/components/orders/AddToCartButton.js +1 -1
- package/lib/cjs/components/orders/AdjustmentAmount.js +1 -1
- package/lib/cjs/components/orders/CartLink.js +1 -1
- package/lib/cjs/components/orders/CheckoutLink.js +1 -1
- package/lib/cjs/components/orders/DiscountAmount.js +1 -1
- package/lib/cjs/components/orders/GiftCardAmount.js +1 -1
- package/lib/cjs/components/orders/OrderContainer.js +1 -1
- package/lib/cjs/components/orders/OrderList.js +1 -1
- package/lib/cjs/components/orders/OrderListEmpty.js +1 -1
- package/lib/cjs/components/orders/OrderListPaginationButtons.js +1 -1
- package/lib/cjs/components/orders/OrderListPaginationInfo.js +1 -1
- package/lib/cjs/components/orders/OrderListRow.js +1 -1
- package/lib/cjs/components/orders/OrderNumber.js +1 -1
- package/lib/cjs/components/orders/OrderStorage.js +1 -1
- package/lib/cjs/components/orders/PaymentMethodAmount.js +1 -1
- package/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
- package/lib/cjs/components/orders/PlaceOrderContainer.js +1 -1
- package/lib/cjs/components/orders/PrivacyAndTermsCheckbox.js +1 -1
- package/lib/cjs/components/orders/ShippingAmount.js +1 -1
- package/lib/cjs/components/orders/SubTotalAmount.js +1 -1
- package/lib/cjs/components/orders/TaxesAmount.js +1 -1
- package/lib/cjs/components/orders/TotalAmount.js +1 -1
- package/lib/cjs/components/parcels/ParcelField.js +1 -1
- package/lib/cjs/components/parcels/ParcelLineItem.js +1 -1
- package/lib/cjs/components/parcels/ParcelLineItemField.js +1 -1
- package/lib/cjs/components/parcels/ParcelLineItemsCount.js +1 -1
- package/lib/cjs/components/parcels/Parcels.js +1 -1
- package/lib/cjs/components/parcels/ParcelsCount.js +1 -1
- package/lib/cjs/components/payment_gateways/AdyenGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/BraintreeGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/CheckoutComGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/ExternalGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/KlarnaGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/PaymentGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/PaypalGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/StripeGateway.js +1 -1
- package/lib/cjs/components/payment_gateways/WireTransferGateway.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethod.d.ts +14 -1
- package/lib/cjs/components/payment_methods/PaymentMethod.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodName.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodPrice.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodRadioButton.js +1 -1
- package/lib/cjs/components/payment_methods/PaymentMethodsContainer.js +1 -1
- package/lib/cjs/components/payment_source/AdyenPayment.js +1 -1
- package/lib/cjs/components/payment_source/BraintreePayment.js +1 -1
- package/lib/cjs/components/payment_source/CheckoutComPayment.js +1 -1
- package/lib/cjs/components/payment_source/ExternalPayment.js +1 -1
- package/lib/cjs/components/payment_source/KlarnaPayment.js +1 -1
- package/lib/cjs/components/payment_source/PaymentSource.js +1 -1
- package/lib/cjs/components/payment_source/PaymentSourceBrandIcon.js +1 -1
- package/lib/cjs/components/payment_source/PaymentSourceBrandName.js +1 -1
- package/lib/cjs/components/payment_source/PaymentSourceDetail.js +1 -1
- package/lib/cjs/components/payment_source/PaymentSourceEditButton.js +1 -1
- package/lib/cjs/components/payment_source/PaypalPayment.js +1 -1
- package/lib/cjs/components/payment_source/StripeExpressPayment.d.ts +5 -0
- package/lib/cjs/components/payment_source/StripeExpressPayment.js +1 -0
- package/lib/cjs/components/payment_source/StripePayment.d.ts +2 -1
- package/lib/cjs/components/payment_source/StripePayment.js +1 -1
- package/lib/cjs/components/payment_source/WireTransferPayment.js +1 -1
- package/lib/cjs/components/prices/Price.js +1 -1
- package/lib/cjs/components/prices/PricesContainer.js +1 -1
- package/lib/cjs/components/shipments/Shipment.js +1 -1
- package/lib/cjs/components/shipments/ShipmentField.js +1 -1
- package/lib/cjs/components/shipments/ShipmentsContainer.js +1 -1
- package/lib/cjs/components/shipments/ShipmentsCount.js +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethod.js +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodName.js +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodPrice.js +1 -1
- package/lib/cjs/components/shipping_methods/ShippingMethodRadioButton.js +1 -1
- package/lib/cjs/components/skus/AvailabilityContainer.js +1 -1
- package/lib/cjs/components/skus/AvailabilityTemplate.js +1 -1
- package/lib/cjs/components/skus/DeliveryLeadTime.js +1 -1
- package/lib/cjs/components/skus/SkuField.js +1 -1
- package/lib/cjs/components/skus/SkuListsContainer.js +1 -1
- package/lib/cjs/components/skus/Skus.js +1 -1
- package/lib/cjs/components/skus/SkusContainer.js +1 -1
- package/lib/cjs/components/stock_transfers/StockTransfer.js +1 -1
- package/lib/cjs/components/stock_transfers/StockTransferField.js +1 -1
- package/lib/cjs/components/utils/AddressCardsTemplate.js +1 -1
- package/lib/cjs/components/utils/BaseField.js +1 -1
- package/lib/cjs/components/utils/BaseInput.js +1 -1
- package/lib/cjs/components/utils/BaseOrderPrice.js +1 -1
- package/lib/cjs/components/utils/BaseSelect.js +1 -1
- package/lib/cjs/components/utils/ErrorBoundary.js +1 -1
- package/lib/cjs/components/utils/GenericFieldComponent.js +1 -1
- package/lib/cjs/components/utils/Parent.js +1 -1
- package/lib/cjs/components/utils/PaymentCardsTemplate.js +1 -1
- package/lib/cjs/components/utils/PriceTemplate.js +1 -1
- package/lib/cjs/components/utils/getAllErrors.js +1 -1
- package/lib/cjs/context/ExternalFunctionContext.js +1 -1
- package/lib/cjs/context/OrderContext.js +1 -1
- package/lib/cjs/context/PaymentMethodChildrenContext.d.ts +1 -0
- package/lib/cjs/hooks/useOrderContainer.js +1 -1
- package/lib/cjs/reducers/AddressReducer.js +1 -1
- package/lib/cjs/reducers/AvailabilityReducer.js +1 -1
- package/lib/cjs/reducers/BillingAddressReducer.js +1 -1
- package/lib/cjs/reducers/CustomerReducer.js +1 -1
- package/lib/cjs/reducers/GiftCardReducer.js +1 -1
- package/lib/cjs/reducers/LineItemReducer.js +1 -1
- package/lib/cjs/reducers/OrderReducer.js +1 -1
- package/lib/cjs/reducers/PaymentMethodReducer.js +1 -1
- package/lib/cjs/reducers/PlaceOrderReducer.js +1 -1
- package/lib/cjs/reducers/PriceReducer.js +1 -1
- package/lib/cjs/reducers/ShipmentReducer.js +1 -1
- package/lib/cjs/reducers/ShippingAddressReducer.js +1 -1
- package/lib/cjs/reducers/SkuListsReducer.js +1 -1
- package/lib/cjs/reducers/SkuReducer.js +1 -1
- package/lib/cjs/typings/index.d.ts +2 -2
- package/lib/cjs/typings/index.js +1 -1
- package/lib/cjs/utils/baseReducer.js +1 -1
- package/lib/cjs/utils/expressPaymentHelper.d.ts +83 -0
- package/lib/cjs/utils/expressPaymentHelper.js +1 -0
- package/lib/cjs/utils/getCardDetails.js +1 -1
- package/lib/cjs/utils/getErrors.js +1 -1
- package/lib/cjs/utils/getPrices.js +1 -1
- package/lib/cjs/utils/getSdk.js +1 -1
- package/lib/cjs/utils/icons.js +1 -1
- package/lib/cjs/utils/isEmpty.d.ts +1 -0
- package/lib/cjs/utils/isEmpty.js +1 -0
- package/lib/cjs/utils/promisify.js +1 -1
- package/lib/cjs/utils/shipments.js +1 -1
- package/lib/cjs/utils/snakeToCamelCase.js +1 -1
- package/lib/cjs/utils/validateFormFields.js +1 -1
- package/lib/esm/components/customers/CustomerField.js +1 -1
- package/lib/esm/components/line_items/LineItemField.js +1 -1
- package/lib/esm/components/parcels/ParcelField.js +1 -1
- package/lib/esm/components/parcels/ParcelLineItemField.js +1 -1
- package/lib/esm/components/payment_gateways/PaymentGateway.js +1 -1
- package/lib/esm/components/payment_gateways/StripeGateway.js +1 -1
- package/lib/esm/components/payment_methods/PaymentMethod.d.ts +14 -1
- package/lib/esm/components/payment_methods/PaymentMethod.js +1 -1
- package/lib/esm/components/payment_methods/PaymentMethodsContainer.js +1 -1
- package/lib/esm/components/payment_source/PaymentSource.js +1 -1
- package/lib/esm/components/payment_source/PaymentSourceBrandName.js +1 -1
- package/lib/esm/components/payment_source/StripeExpressPayment.d.ts +5 -0
- package/lib/esm/components/payment_source/StripeExpressPayment.js +1 -0
- package/lib/esm/components/payment_source/StripePayment.d.ts +2 -1
- package/lib/esm/components/payment_source/StripePayment.js +1 -1
- package/lib/esm/components/skus/SkuField.js +1 -1
- package/lib/esm/components/stock_transfers/StockTransferField.js +1 -1
- package/lib/esm/context/PaymentMethodChildrenContext.d.ts +1 -0
- package/lib/esm/typings/index.d.ts +2 -2
- package/lib/esm/utils/expressPaymentHelper.d.ts +83 -0
- package/lib/esm/utils/expressPaymentHelper.js +1 -0
- package/lib/esm/utils/isEmpty.d.ts +1 -0
- package/lib/esm/utils/isEmpty.js +1 -0
- package/package.json +16 -16
- package/lib/tsconfig.prod.esm.tsbuildinfo +0 -1
- package/lib/tsconfig.prod.tsbuildinfo +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.expressRedirectUrl=exports.setExpressPlaceOrder=exports.setExpressShippingMethod=exports.getExpressShippingMethods=exports.setExpressFakeAddress=exports.getAvailableExpressPayments=void 0;const tslib_1=require("tslib"),getSdk_1=tslib_1.__importDefault(require("./getSdk")),availablePaymentMethods=["stripe_payments"];function getAvailableExpressPayments(paymentMethods){return paymentMethods.filter(payment=>payment.payment_source_type?availablePaymentMethods.includes(payment.payment_source_type):!1)}exports.getAvailableExpressPayments=getAvailableExpressPayments;function setExpressFakeAddress({orderId,config,address,email}){return tslib_1.__awaiter(this,void 0,void 0,function*(){const params={include:["shipments.available_shipping_methods"]},sdk=(0,getSdk_1.default)(config),fakeAddress=yield sdk.addresses.create(address),resource={id:orderId,billing_address:sdk.addresses.relationship(fakeAddress.id),_shipping_address_same_as_billing:!0};return email!=null&&(resource.customer_email=email),yield sdk.orders.update(resource,params),yield sdk.orders.retrieve(orderId,params)})}exports.setExpressFakeAddress=setExpressFakeAddress;function getExpressShippingMethods(order){var _a,_b;const isSingleShipment=((_a=order?.shipments)===null||_a===void 0?void 0:_a.length)===1,shippingMethods=(_b=order?.shipments)===null||_b===void 0?void 0:_b.map(shipment=>shipment.available_shipping_methods);if(isSingleShipment)return shippingMethods==null?null:shippingMethods.flat().map(method=>{var _a2,_b2,_c;return{id:(_a2=method?.id)!==null&&_a2!==void 0?_a2:"",label:(_b2=method?.name)!==null&&_b2!==void 0?_b2:"",amount:(_c=method?.price_amount_for_shipment_cents)!==null&&_c!==void 0?_c:0,detail:""}});{if(shippingMethods==null)return null;const shippingOptionsAmount=[];return shippingMethods.forEach(methods=>{var _a2;if(methods!=null){const[firstMethod]=methods;firstMethod!=null&&shippingOptionsAmount.push((_a2=firstMethod.price_amount_for_shipment_cents)!==null&&_a2!==void 0?_a2:0)}}),[{id:"shipping",label:"Shipping",amount:shippingOptionsAmount.reduce((a,b)=>a+b,0),detail:""}]}}exports.getExpressShippingMethods=getExpressShippingMethods;function setExpressShippingMethod({config,orderId,selectFirst=!0,selectedShippingMethodId,params}){var _a,_b,_c;return tslib_1.__awaiter(this,void 0,void 0,function*(){const sdk=(0,getSdk_1.default)(config),order=yield sdk.orders.retrieve(orderId,params),shippingMethods=getExpressShippingMethods(order);if(order?.shipments==null)throw new Error("No shipments found");const isSingleShipment=order.shipments.length===1,[shipmentId]=order.shipments.map(shipment=>shipment.id);if(shipmentId==null)throw new Error("No shipment found");if(shippingMethods==null||shippingMethods?.length===0)throw new Error("No shipping methods found");if(isSingleShipment)if(selectFirst){const[firstShippingMethodId]=shippingMethods.map(method=>method.id);firstShippingMethodId!=null&&(yield sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(firstShippingMethodId)}))}else selectedShippingMethodId!=null&&(yield sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(selectedShippingMethodId)}));else for(const shipment of(_a=order?.shipments)!==null&&_a!==void 0?_a:[]){const[firstShippingMethodId]=(_c=(_b=shipment?.available_shipping_methods)===null||_b===void 0?void 0:_b.map(method=>method.id))!==null&&_c!==void 0?_c:[];firstShippingMethodId!=null&&(yield sdk.shipments.update({id:shipment.id,shipping_method:sdk.shipping_methods.relationship(firstShippingMethodId)}))}return yield sdk.orders.retrieve(order.id,params)})}exports.setExpressShippingMethod=setExpressShippingMethod;function setExpressPlaceOrder({config,orderId,paymentResource,paymentSourceId}){return tslib_1.__awaiter(this,void 0,void 0,function*(){const sdk=(0,getSdk_1.default)(config);return yield sdk.orders.retrieve(orderId,{include:["shipments.shipping_method","payment_source","payment_method"]}),yield sdk[paymentResource].update({id:paymentSourceId,order:sdk.orders.relationship(orderId)}),yield sdk.orders.update({id:orderId,payment_source:sdk[paymentResource].relationship(paymentSourceId)}),yield sdk.orders.update({id:orderId,_place:!0})})}exports.setExpressPlaceOrder=setExpressPlaceOrder;function expressRedirectUrl({order,config:{accessToken,endpoint}}){if(accessToken==null)throw new Error("No access token found");if(endpoint==null)throw new Error("No endpoint found");const[slug]=endpoint.split(".commercelayer");if(slug==null)throw new Error("No slug found");const href=order?.checkout_url!=null?order?.checkout_url:`${slug}.commercelayer.app/checkout/${order.id}?accessToken=${accessToken}`;window.location.pathname.includes("/checkout")||window.location.pathname.includes(`/${order.id}`)?window.location.reload():window.location.href=href}exports.expressRedirectUrl=expressRedirectUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function getCardDetails({paymentType,customerPayment}){switch(paymentType){case"checkout_com_payments":{const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function getCardDetails({paymentType,customerPayment}){var _a,_b,_c,_d,_e,_f,_g,_h,_j;switch(paymentType){case"checkout_com_payments":{const ps=customerPayment.payment_source,source=(_a=ps?.payment_response)===null||_a===void 0?void 0:_a.source;if(source)return{brand:source.scheme.toLowerCase(),exp_month:source.expiry_month,exp_year:source.expiry_year,last4:source.last4};break}case"stripe_payments":{const ps=customerPayment.payment_source,source=(_c=(_b=ps?.options)===null||_b===void 0?void 0:_b.card)!==null&&_c!==void 0?_c:(_d=ps?.payment_method)===null||_d===void 0?void 0:_d.card;if(source)return Object.assign({},source);break}case"braintree_payments":{const ps=customerPayment.payment_source,source=(_e=ps?.options)===null||_e===void 0?void 0:_e.card;if(source)return Object.assign({},source);break}case"adyen_payments":{const ps=customerPayment.payment_source,source=(_f=ps?.payment_request_data)===null||_f===void 0?void 0:_f.payment_method,authorized=((_g=ps?.payment_response)===null||_g===void 0?void 0:_g.resultCode)==="Authorised";if(source&&authorized){const brand=source.type==="scheme"?(_h=source.brand)!==null&&_h!==void 0?_h:"credit-card":source.type.replace("_account","");return Object.assign(Object.assign({},source),{brand})}break}default:{const ps=customerPayment.payment_source,source=(_j=ps?.metadata)===null||_j===void 0?void 0:_j.card;if(source)return Object.assign({},source);break}}return{brand:"",exp_month:"**",exp_year:"**",last4:"****"}}exports.default=getCardDetails;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setErrors=void 0;const tslib_1=require("tslib"),differenceBy_1=tslib_1.__importDefault(require("lodash/differenceBy"));function getErrors({error,resource,field,attributes}){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setErrors=void 0;const tslib_1=require("tslib"),differenceBy_1=tslib_1.__importDefault(require("lodash/differenceBy"));function getErrors({error,resource,field,attributes}){var _a;return(_a=error?.errors)===null||_a===void 0?void 0:_a.map(e=>Object.assign(Object.assign(Object.assign(Object.assign({},e),{resource}),field!=null&&field!==""&&{field}),attributes!=null&&attributes))}exports.default=getErrors;function setErrors({currentErrors=[],newErrors=[],dispatch,filterBy="code"}){const errorsDifference=(0,differenceBy_1.default)(currentErrors,newErrors,filterBy),mergeErrors=currentErrors?.length===0?newErrors:errorsDifference,errors=[...currentErrors||[],...mergeErrors];return dispatch?.({type:"setErrors",payload:{errors}}),errors}exports.setErrors=setErrors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPricesComponent=exports.getPriceByCode=void 0;const tslib_1=require("tslib"),react_1=require("react"),jsx_runtime_1=require("react/jsx-runtime"),lodash_1=require("lodash"),PriceTemplate_1=tslib_1.__importDefault(require("../components/utils/PriceTemplate"));function getPriceByCode(skuPrices,code=""){return code?(0,lodash_1.first)(skuPrices.filter(p=>p.currency_code===code)):(0,lodash_1.first)(skuPrices)}exports.getPriceByCode=getPriceByCode;function getPricesComponent(skuPrices,props){return(0,lodash_1.isEmpty)(skuPrices)?(0,jsx_runtime_1.jsx)(PriceTemplate_1.default,{
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPricesComponent=exports.getPriceByCode=void 0;const tslib_1=require("tslib"),react_1=require("react"),jsx_runtime_1=require("react/jsx-runtime"),lodash_1=require("lodash"),PriceTemplate_1=tslib_1.__importDefault(require("../components/utils/PriceTemplate"));function getPriceByCode(skuPrices,code=""){return code?(0,lodash_1.first)(skuPrices.filter(p=>p.currency_code===code)):(0,lodash_1.first)(skuPrices)}exports.getPriceByCode=getPriceByCode;function getPricesComponent(skuPrices,props){return(0,lodash_1.isEmpty)(skuPrices)?(0,jsx_runtime_1.jsx)(PriceTemplate_1.default,Object.assign({},props)):skuPrices.map((p,k)=>{const showCompare=typeof props.showCompare>"u"&&p?.compare_at_amount_cents>p?.amount_cents||props.showCompare;return(0,react_1.createElement)(PriceTemplate_1.default,Object.assign({},props,{key:k,showCompare,formattedAmount:p.formatted_amount,formattedCompare:p.formatted_compare_at_amount,skuCode:p.sku_code}))})}exports.getPricesComponent=getPricesComponent;function getPrices(prices){const obj={};return(0,lodash_1.isArray)(prices)&&prices.forEach(p=>{const sku=p.sku_code;(0,lodash_1.has)(obj,sku)?obj[sku].push(p):obj[sku]=[p]}),obj}exports.default=getPrices;
|
package/lib/cjs/utils/getSdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),organization_1=tslib_1.__importDefault(require("./organization")),sdk_1=tslib_1.__importDefault(require("@commercelayer/sdk"));function getSdk({endpoint,accessToken}){if(accessToken==null||endpoint==null)throw new Error("accessToken and endpoint are required parameters");const org=(0,organization_1.default)(endpoint);return(0,sdk_1.default)({accessToken
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),organization_1=tslib_1.__importDefault(require("./organization")),sdk_1=tslib_1.__importDefault(require("@commercelayer/sdk"));function getSdk({endpoint,accessToken}){if(accessToken==null||endpoint==null)throw new Error("accessToken and endpoint are required parameters");const org=(0,organization_1.default)(endpoint);return(0,sdk_1.default)(Object.assign({accessToken},org))}exports.default=getSdk;
|
package/lib/cjs/utils/icons.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.sortAscIcon=exports.sortDescIcon=void 0;const jsx_runtime_1=require("react/jsx-runtime");exports.sortDescIcon=(0,jsx_runtime_1.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,jsx_runtime_1.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4"})}),exports.sortAscIcon=(0,jsx_runtime_1.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,jsx_runtime_1.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.sortAscIcon=exports.sortDescIcon=void 0;const jsx_runtime_1=require("react/jsx-runtime");exports.sortDescIcon=(0,jsx_runtime_1.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},{children:(0,jsx_runtime_1.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4"})})),exports.sortAscIcon=(0,jsx_runtime_1.jsx)("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:20,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},{children:(0,jsx_runtime_1.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"})}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEmpty<V>(value: V): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isEmpty=void 0;function isEmpty(value){if(value==null)return!0;if(Array.isArray(value)||typeof value=="string")return value.length===0;if(typeof value=="object")return Object.keys(value).length===0;throw new Error("Invalid value for isEmpty function")}exports.isEmpty=isEmpty;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),isFunction_1=tslib_1.__importDefault(require("lodash/isFunction"));
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),isFunction_1=tslib_1.__importDefault(require("lodash/isFunction"));function promisify(cb,params){return tslib_1.__awaiter(this,void 0,void 0,function*(){return yield new Promise((resolve,reject)=>{params?cb(params,(err,res)=>{err&&reject(err),resolve(res)}):(0,isFunction_1.default)(cb?.tokenize)?cb?.tokenize((err,payload)=>{err&&reject(err),resolve(payload)}):cb((err,res)=>{err&&reject(err),resolve(res)})})})}exports.default=promisify;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isDoNotShip=exports.shipmentsFilled=void 0;const tslib_1=require("tslib"),compact_1=tslib_1.__importDefault(require("lodash/compact")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty"));function shipmentsFilled(shipments){const filled=(0,compact_1.default)(shipments.filter(shipment=>!(0,isEmpty_1.default)(shipment.shipping_method)));return!(0,isEmpty_1.default)(filled)}exports.shipmentsFilled=shipmentsFilled;function isDoNotShip(lineItems){const itemDoNotShip=[],items=lineItems?lineItems.filter(({item_type})=>item_type==="skus").map(lineItem=>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isDoNotShip=exports.shipmentsFilled=void 0;const tslib_1=require("tslib"),compact_1=tslib_1.__importDefault(require("lodash/compact")),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty"));function shipmentsFilled(shipments){const filled=(0,compact_1.default)(shipments.filter(shipment=>!(0,isEmpty_1.default)(shipment.shipping_method)));return!(0,isEmpty_1.default)(filled)}exports.shipmentsFilled=shipmentsFilled;function isDoNotShip(lineItems){const itemDoNotShip=[],items=lineItems?lineItems.filter(({item_type})=>item_type==="skus").map(lineItem=>{var _a;return lineItem.item&&(!((_a=lineItem?.item)===null||_a===void 0)&&_a.do_not_ship)&&itemDoNotShip.push(!0),lineItem}):[];return itemDoNotShip.length>0&&itemDoNotShip.length===items.length}exports.isDoNotShip=isDoNotShip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.snakeToCamelCase=void 0;function snakeToCamelCase(value){const words=value.toLowerCase().split("_"),first=words[0]
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.snakeToCamelCase=void 0;function snakeToCamelCase(value){var _a,_b,_c,_d,_e,_f;const words=value.toLowerCase().split("_"),first=(_a=words[0])!==null&&_a!==void 0?_a:"",firstLetter=(_d=(_c=(_b=words[1])===null||_b===void 0?void 0:_b[0])===null||_c===void 0?void 0:_c.toUpperCase())!==null&&_d!==void 0?_d:"",second=(_f=(_e=words[1])===null||_e===void 0?void 0:_e.substring(1))!==null&&_f!==void 0?_f:"";return`${first}${firstLetter}${second}`}exports.snakeToCamelCase=snakeToCamelCase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.businessMandatoryField=exports.fieldsExist=exports.validateValue=void 0;const tslib_1=require("tslib"),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),isString_1=tslib_1.__importDefault(require("lodash/isString")),without_1=tslib_1.__importDefault(require("lodash/without")),keys_1=tslib_1.__importDefault(require("lodash/keys")),map_1=tslib_1.__importDefault(require("lodash/map")),AddressReducer_1=require("../reducers/AddressReducer"),EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/,validateValue=(val,name,type,resourceType)=>val?type==="email"&&(0,isString_1.default)(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};exports.validateValue=validateValue;const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return(0,map_1.default)(fields,v=>{const val="checked"in v||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.includes(attrName)||v.required){const error=(0,exports.validateValue)(val,v.name,v.type,resourceType);(0,isEmpty_1.default)(error)||errors.push(error),values={
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.businessMandatoryField=exports.fieldsExist=exports.validateValue=void 0;const tslib_1=require("tslib"),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),isString_1=tslib_1.__importDefault(require("lodash/isString")),without_1=tslib_1.__importDefault(require("lodash/without")),keys_1=tslib_1.__importDefault(require("lodash/keys")),map_1=tslib_1.__importDefault(require("lodash/map")),AddressReducer_1=require("../reducers/AddressReducer"),EMAIL_PATTERN=/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$/,validateValue=(val,name,type,resourceType)=>val?type==="email"&&(0,isString_1.default)(val)&&!val.match(EMAIL_PATTERN)?{field:name,code:"VALIDATION_ERROR",message:`${name} - is not valid`,resourceType}:{}:{field:name,code:"VALIDATION_ERROR",message:`${name} - is required`,resourceType};exports.validateValue=validateValue;const validateFormFields=(fields,required,resourceType)=>{const errors=[];let values={metadata:{}};return(0,map_1.default)(fields,v=>{const val="checked"in v||(v.value==="on"?!1:v.value),attrName=v.getAttribute("name");if(attrName&&required.includes(attrName)||v.required){const error=(0,exports.validateValue)(val,v.name,v.type,resourceType);(0,isEmpty_1.default)(error)||errors.push(error),values=Object.assign(Object.assign({},values),{[`${v.name}`]:val})}v.getAttribute("name")&&(values=!!v.getAttribute("data-metadata")?Object.assign(Object.assign({},values),{metadata:Object.assign(Object.assign({},values.metadata),{[`${v.name}`]:val})}):Object.assign(Object.assign({},values),{[`${v.name}`]:val}))}),{errors,values}},fieldsExist=(address,schema=AddressReducer_1.addressFields)=>{if(address.business){const required=(0,without_1.default)(schema,"first_name","last_name"),validAddress=(0,keys_1.default)(address).filter(k=>required.includes(k));return required.length>validAddress.length}else{const required=(0,without_1.default)(schema,"line_2","company"),validAddress=(0,keys_1.default)(address).filter(k=>required.includes(k));return required.length>validAddress.length}};exports.fieldsExist=fieldsExist;const businessOptionalFields=["billing_address_first_name","billing_address_last_name","shipping_address_first_name","shipping_address_last_name","first_name","last_name"],customerOptionalFields=["billing_address_company","shipping_address_company","company"];function businessMandatoryField(fieldName,isBusiness){return!(isBusiness&&businessOptionalFields.includes(fieldName)||!isBusiness&&customerOptionalFields.includes(fieldName))}exports.businessMandatoryField=businessMandatoryField,exports.default=validateFormFields;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import CustomerContext from"../../context/CustomerContext";export function CustomerField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"customers",attribute,tagElement,context:CustomerContext,...p,children})}export default CustomerField;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import CustomerContext from"../../context/CustomerContext";export function CustomerField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"customers",attribute,tagElement,context:CustomerContext,...p,children})}export default CustomerField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function LineItemField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"lineItem",attribute,tagElement,context:LineItemChildrenContext,...p,children})}export default LineItemField;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import LineItemChildrenContext from"../../context/LineItemChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function LineItemField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"lineItem",attribute,tagElement,context:LineItemChildrenContext,...p,children})}export default LineItemField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelChildrenContext from"../../context/ParcelChildrenContext";export function ParcelField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcel",attribute,tagElement,context:ParcelChildrenContext,...p,children})}export default ParcelField;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelChildrenContext from"../../context/ParcelChildrenContext";export function ParcelField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcel",attribute,tagElement,context:ParcelChildrenContext,...p,children})}export default ParcelField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelLineItemChildrenContext from"../../context/ParcelLineItemChildrenContext";export function ParcelLineItemField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcelLineItem",attribute,tagElement,context:ParcelLineItemChildrenContext,...p,children})}export default ParcelLineItemField;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import GenericFieldComponent from"../utils/GenericFieldComponent";import ParcelLineItemChildrenContext from"../../context/ParcelLineItemChildrenContext";export function ParcelLineItemField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"parcelLineItem",attribute,tagElement,context:ParcelLineItemChildrenContext,...p,children})}export default ParcelLineItemField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show||(!paymentSource||paymentSource
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{useContext,useEffect,useState}from"react";import getLoaderComponent from"../../utils/getLoaderComponent";import AdyenGateway from"./AdyenGateway";import StripeGateway from"./StripeGateway";import BraintreeGateway from"./BraintreeGateway";import PaypalGateway from"./PaypalGateway";import WireTransferGateway from"./WireTransferGateway";import CustomerContext from"../../context/CustomerContext";import CheckoutComGateway from"./CheckoutComGateway";import KlarnaGateway from"./KlarnaGateway";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import ExternalGateway from"./ExternalGateway";export function PaymentGateway({readonly,showCard,handleEditClick,children,templateCustomerCards,templateCustomerSaveToWallet,onClickCustomerCards,show,loader="Loading...",...p}){const loaderComponent=getLoaderComponent(loader),[loading,setLoading]=useState(!0),{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext),{currentPaymentMethodId,config,currentPaymentMethodType,setPaymentSource,paymentSource}=useContext(PaymentMethodContext),paymentResource=readonly?currentPaymentMethodType:payment?.payment_source_type;useEffect(()=>{if(payment?.id===currentPaymentMethodId&&paymentResource&&order?.payment_method?.payment_source_type===paymentResource&&!expressPayments){let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config));const setPaymentSources=async()=>{await setPaymentSource({paymentResource,order,attributes}),getCustomerPaymentSources&&getCustomerPaymentSources()};(!paymentSource&&order?.payment_method.id&&show&&!expressPayments||(!paymentSource&&!expressPayments||paymentSource?.type!==paymentResource)&&show)&&setPaymentSources(),paymentSource?.mismatched_amounts&&show&&setPaymentSources(),setLoading(!1)}return expressPayments&&setLoading(!1),()=>{setLoading(!0)}},[order?.payment_method?.id,show,paymentSource]);const gatewayConfig={readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,onClickCustomerCards,loaderComponent,templateCustomerSaveToWallet,...p};switch(paymentResource){case"adyen_payments":return _jsx(AdyenGateway,{...gatewayConfig,children});case"braintree_payments":return _jsx(BraintreeGateway,{...gatewayConfig,children});case"checkout_com_payments":return _jsx(CheckoutComGateway,{...gatewayConfig,children});case"external_payments":return _jsx(ExternalGateway,{...gatewayConfig,children});case"klarna_payments":return _jsx(KlarnaGateway,{...gatewayConfig,children});case"stripe_payments":return _jsx(StripeGateway,{...gatewayConfig,children});case"wire_transfers":return _jsx(WireTransferGateway,{...gatewayConfig,children});case"paypal_payments":return _jsx(PaypalGateway,{...gatewayConfig,children});default:return null}}export default PaymentGateway;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import StripePayment from"../payment_source/StripePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function StripeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="stripe_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publishableKey=paymentSource?.publishable_key,clientSecret=paymentSource?.client_secret,paymentSourceId=order?.payment_source?.id||paymentSource?.id,stripeConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(StripePayment,{show,templateCustomerSaveToWallet,publishableKey,clientSecret,locale,...stripeConfig})]}):publishableKey&&!loading&&paymentSourceId?_jsx(StripePayment,{show,publishableKey,clientSecret,locale,...stripeConfig}):loaderComponent}export default StripeGateway;
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import StripePayment from"../payment_source/StripePayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import getCardDetails from"../../utils/getCardDetails";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";export function StripeGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment,expressPayments}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="stripe_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publishableKey=paymentSource?.publishable_key,clientSecret=paymentSource?.client_secret,paymentSourceId=order?.payment_source?.id||paymentSource?.id,stripeConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return isEmpty(card)?null:_jsx(PaymentSourceContext.Provider,{value,children})}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(StripePayment,{show,templateCustomerSaveToWallet,publishableKey,clientSecret,expressPayments,locale,...stripeConfig})]}):publishableKey&&!loading&&paymentSourceId?_jsx(StripePayment,{show,publishableKey,clientSecret,locale,expressPayments,...stripeConfig}):loaderComponent}export default StripeGateway;
|
|
@@ -12,9 +12,22 @@ type Props = {
|
|
|
12
12
|
*/
|
|
13
13
|
hide?: PaymentResource[] | ((payment: PaymentMethodType) => boolean);
|
|
14
14
|
children: DefaultChildrenType;
|
|
15
|
+
/**
|
|
16
|
+
* Set CSS classes when the payment method is selected
|
|
17
|
+
*/
|
|
15
18
|
activeClass?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Customize the loader component
|
|
21
|
+
*/
|
|
16
22
|
loader?: LoaderType;
|
|
23
|
+
/**
|
|
24
|
+
* Auto select the payment method when there is only one available
|
|
25
|
+
*/
|
|
17
26
|
autoSelectSinglePaymentMethod?: boolean | (() => void);
|
|
27
|
+
/**
|
|
28
|
+
* Enable express payment. Other payment methods will be disabled.
|
|
29
|
+
*/
|
|
30
|
+
expressPayments?: boolean;
|
|
18
31
|
} & Omit<JSX.IntrinsicElements['div'], 'onClick' | 'children'> & ({
|
|
19
32
|
clickableContainer: true;
|
|
20
33
|
onClick?: (params?: TOnClickParams) => void;
|
|
@@ -22,5 +35,5 @@ type Props = {
|
|
|
22
35
|
clickableContainer?: never;
|
|
23
36
|
onClick?: never;
|
|
24
37
|
});
|
|
25
|
-
export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, autoSelectSinglePaymentMethod, hide, onClick, ...p }: Props): JSX.Element;
|
|
38
|
+
export declare function PaymentMethod({ children, className, activeClass, loader, clickableContainer, autoSelectSinglePaymentMethod, expressPayments, hide, onClick, ...p }: Props): JSX.Element;
|
|
26
39
|
export default PaymentMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import useCustomContext from"../../utils/hooks/useCustomContext";import OrderContext from"../../context/OrderContext";import CustomerContext from"../../context/CustomerContext";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,autoSelectSinglePaymentMethod,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder,paymentSource,setPaymentSource,config}=useCustomContext({context:PaymentMethodContext,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"}),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext);useEffect(()=>{paymentMethods!=null&&autoSelectSinglePaymentMethod!=null&&(async()=>{if(paymentMethods.length===1){const[paymentMethod]=paymentMethods??[];if(paymentMethod&&!paymentSource){setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId});let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config)),await setPaymentSource({paymentResource,order,attributes})&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,order}),setTimeout(()=>{setLoading(!1)},200)),getCustomerPaymentSources&&getCustomerPaymentSources(),setLoadingPlaceOrder({loading:!1})}typeof autoSelectSinglePaymentMethod=="function"&&autoSelectSinglePaymentMethod()}else setTimeout(()=>{setLoading(!1)},200)})()},[paymentMethods]),useEffect(()=>(paymentMethods&&(paymentMethods.length===1&&autoSelectSinglePaymentMethod?paymentSource&&setTimeout(()=>{setLoading(!1)},200):setLoading(!1)),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(Array.isArray(hide)){const source=payment?.payment_source_type;return!hide?.includes(source)}else if(typeof hide=="function")return hide(payment);return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id,{order:order2}=await setPaymentMethod({paymentResource,paymentMethodId});onClick&&onClick({payment,order:order2}),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-testid":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default PaymentMethod;
|
|
1
|
+
import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{useState,useEffect,useContext}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import getLoaderComponent from"../../utils/getLoaderComponent";import useCustomContext from"../../utils/hooks/useCustomContext";import OrderContext from"../../context/OrderContext";import CustomerContext from"../../context/CustomerContext";import{getExternalPaymentAttributes,getPaypalAttributes}from"../../utils/getPaymentAttributes";import{isEmpty}from"../../utils/isEmpty";import{getAvailableExpressPayments}from"../../utils/expressPaymentHelper";export function PaymentMethod({children,className,activeClass,loader="Loading...",clickableContainer,autoSelectSinglePaymentMethod,expressPayments,hide,onClick,...p}){const[loading,setLoading]=useState(!0),[paymentSelected,setPaymentSelected]=useState(""),{paymentMethods,currentPaymentMethodId,setPaymentMethod,setLoading:setLoadingPlaceOrder,paymentSource,setPaymentSource,config}=useCustomContext({context:PaymentMethodContext,contextComponentName:"PaymentMethodsContainer",currentComponentName:"PaymentMethod",key:"paymentMethods"}),{order}=useContext(OrderContext),{getCustomerPaymentSources}=useContext(CustomerContext);useEffect(()=>{if(paymentMethods!=null&&!isEmpty(paymentMethods)&&expressPayments){const[paymentMethod]=getAvailableExpressPayments(paymentMethods);!paymentSource&&paymentMethod!=null&&(async()=>{setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId}),await setPaymentSource({paymentResource,order})&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,order}),setTimeout(()=>{setLoading(!1)},200)),setLoadingPlaceOrder({loading:!1})})()}},[!isEmpty(paymentMethods),expressPayments]),useEffect(()=>{paymentMethods!=null&&autoSelectSinglePaymentMethod!=null&&!expressPayments&&(async()=>{if(paymentMethods.length===1){const[paymentMethod]=paymentMethods??[];if(paymentMethod&&!paymentSource){setLoadingPlaceOrder({loading:!0}),setPaymentSelected(paymentMethod.id);const paymentMethodId=paymentMethod?.id,paymentResource=paymentMethod?.payment_source_type;await setPaymentMethod({paymentResource,paymentMethodId});let attributes={};config!=null&&paymentResource==="paypal_payments"&&(attributes=getPaypalAttributes(paymentResource,config)),config!=null&&paymentResource==="external_payments"&&(attributes=getExternalPaymentAttributes(paymentResource,config)),await setPaymentSource({paymentResource,order,attributes})&&paymentMethod&&onClick!=null&&(onClick({payment:paymentMethod,order}),setTimeout(()=>{setLoading(!1)},200)),getCustomerPaymentSources&&getCustomerPaymentSources(),setLoadingPlaceOrder({loading:!1})}typeof autoSelectSinglePaymentMethod=="function"&&autoSelectSinglePaymentMethod()}else setTimeout(()=>{setLoading(!1)},200)})()},[paymentMethods,expressPayments]),useEffect(()=>(paymentMethods&&(paymentMethods.length===1&&autoSelectSinglePaymentMethod?paymentSource&&setTimeout(()=>{setLoading(!1)},200):setLoading(!1)),currentPaymentMethodId&&setPaymentSelected(currentPaymentMethodId),()=>{setLoading(!0)}),[paymentMethods,currentPaymentMethodId]);const components=paymentMethods?.filter(payment=>{if(Array.isArray(hide)){const source=payment?.payment_source_type;return!hide?.includes(source)}else if(typeof hide=="function")return hide(payment);return!0}).map((payment,k)=>{const isActive=currentPaymentMethodId===payment?.id,paymentMethodProps={payment,clickableContainer,paymentSelected,setPaymentSelected,expressPayments},paymentResource=payment?.payment_source_type,onClickable=clickableContainer?async e=>{e.stopPropagation(),setLoadingPlaceOrder({loading:!0}),setPaymentSelected(payment.id);const paymentMethodId=payment?.id,{order:order2}=await setPaymentMethod({paymentResource,paymentMethodId});onClick&&onClick({payment,order:order2}),setLoadingPlaceOrder({loading:!1})}:void 0;return _jsx("div",{"data-testid":paymentResource,className:`${className??""} ${isActive&&activeClass!=null?activeClass:""}`,onClick:onClickable,...p,children:_jsx(PaymentMethodChildrenContext.Provider,{value:paymentMethodProps,children})},k)});return loading?getLoaderComponent(loader):_jsx(_Fragment,{children:components})}export default PaymentMethod;
|
|
@@ -1 +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,setPaymentRef}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PaymentMethodContext,{defaultPaymentMethodContext}from"../../context/PaymentMethodContext";import{useContext,useEffect,useReducer,useMemo}from"react";import paymentMethodReducer,{paymentMethodInitialState,getPaymentMethods,setPaymentMethodConfig,setPaymentRef}from"../../reducers/PaymentMethodReducer";import OrderContext from"../../context/OrderContext";import CommerceLayerContext from"../../context/CommerceLayerContext";import useCustomContext from"../../utils/hooks/useCustomContext";import{isEmpty}from"../../utils/isEmpty";export function PaymentMethodsContainer(props){const{children,config}=props,[state,dispatch]=useReducer(paymentMethodReducer,paymentMethodInitialState),{order,getOrder,setOrderErrors,include,addResourceToInclude,updateOrder,includeLoaded}=useCustomContext({context:OrderContext,contextComponentName:"OrderContainer",currentComponentName:"PaymentMethodsContainer",key:"order"}),credentials=useContext(CommerceLayerContext);async function getPayMethods(){order&&await getPaymentMethods({order,dispatch})}useEffect(()=>{include?.includes("available_payment_methods")?includeLoaded?.available_payment_methods||addResourceToInclude({newResourceLoaded:{available_payment_methods:!0,payment_source:!0,payment_method:!0,"line_items.line_item_options.sku_option":!0,"line_items.item":!0}}):addResourceToInclude({newResource:["available_payment_methods","payment_source","payment_method","line_items.line_item_options.sku_option","line_items.item"]}),config&&isEmpty(state.config)&&setPaymentMethodConfig(config,dispatch),credentials&&order&&!state.paymentMethods&&getPayMethods(),order?.payment_source&&dispatch({type:"setPaymentSource",payload:{paymentSource:order?.payment_source}}),order?.payment_source===null&&dispatch({type:"setPaymentSource",payload:{paymentSource:void 0}})},[order,credentials,include?.length,Object.keys(includeLoaded??[]).length]);const contextValue=useMemo(()=>({...state,setLoading:({loading})=>{defaultPaymentMethodContext.setLoading({loading,dispatch})},setPaymentRef:({ref})=>{setPaymentRef({ref,dispatch})},setPaymentMethodErrors:errors=>{defaultPaymentMethodContext.setPaymentMethodErrors(errors,dispatch)},setPaymentMethod:async args=>await defaultPaymentMethodContext.setPaymentMethod({...args,config:credentials,updateOrder,order,dispatch,setOrderErrors}),setPaymentSource:async args=>await defaultPaymentMethodContext.setPaymentSource({...state,...args,config:credentials,dispatch,getOrder,updateOrder,order}),updatePaymentSource:async args=>{await defaultPaymentMethodContext.updatePaymentSource({...args,config:credentials,dispatch})},destroyPaymentSource:async args=>{await defaultPaymentMethodContext.destroyPaymentSource({...args,dispatch,config:credentials,updateOrder,orderId:order?.id})}}),[state]);return _jsx(PaymentMethodContext.Provider,{value:contextValue,children})}export default PaymentMethodsContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useContext,useState,useEffect}from"react";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import CustomerContext from"../../context/CustomerContext";import PaymentGateway from"../payment_gateways/PaymentGateway";import getCardDetails from"../../utils/getCardDetails";import OrderContext from"../../context/OrderContext";export function PaymentSource(props){const{readonly}=props,{payment,expressPayments}=useContext(PaymentMethodChildrenContext),{order}=useContext(OrderContext),{payments}=useContext(CustomerContext),{currentPaymentMethodId,paymentSource,destroyPaymentSource}=useContext(PaymentMethodContext),[show,setShow]=useState(!1),[showCard,setShowCard]=useState(!1);useEffect(()=>(readonly?(setShow(!0),setShowCard(!0)):payment?.id===currentPaymentMethodId?(setShow(!0),getCardDetails({paymentType:payment?.payment_source_type,customerPayment:{payment_source:paymentSource}}).brand&&setShowCard(!0)):setShow(!!expressPayments),()=>{setShow(!1),setShowCard(!1)}),[currentPaymentMethodId,paymentSource,payments,payment,readonly,order]);const gatewayProps={...props,show,showCard,handleEditClick:async e=>{if(e.stopPropagation(),paymentSource){const paymentSourceId=paymentSource?.id;await destroyPaymentSource({paymentSourceId,paymentResource:payment?.payment_source_type})}setShowCard(!showCard),setShow(!0)},readonly};return _jsx(PaymentGateway,{...gatewayProps})}export default PaymentSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import capitalize from"lodash/capitalize";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandName({children,label,...props}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,brandName=cardBrand&&capitalize(cardBrand.
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import capitalize from"lodash/capitalize";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandName({children,label,...props}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,brandName=cardBrand&&capitalize(cardBrand.replace(/_|-/gm," ")),parentProps={brand:brandName,label,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...props,children:label||capitalize(brandName)})}export default PaymentSourceBrandName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import{getAvailableExpressPayments,getExpressShippingMethods,setExpressFakeAddress,setExpressPlaceOrder,setExpressShippingMethod,expressRedirectUrl}from"../../utils/expressPaymentHelper";import{isEmpty}from"../../utils/isEmpty";import{PaymentRequestButtonElement,useStripe}from"@stripe/react-stripe-js";import{useContext,useEffect,useState}from"react";export function StripeExpressPayment({clientSecret}){const stripe=useStripe(),[paymentRequest,setPaymentRequest]=useState(null),{accessToken,endpoint}=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{paymentMethods,paymentSource}=useContext(PaymentMethodContext);return useEffect(()=>{if(stripe==null||order==null)return;const pr=stripe.paymentRequest({country:order.country_code??"",currency:order?.currency_code?.toLowerCase()??"",total:{label:`#${order?.number??""}`,amount:order?.total_amount_with_taxes_cents??0},requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:!0,requestShipping:!0});pr.canMakePayment().then(result=>{console.log("available payment:",result),result&&setPaymentRequest(pr)}).catch(err=>{console.error("Can make payment:",err)})},[isEmpty(stripe),isEmpty(order)]),paymentRequest!=null&&stripe!=null?(paymentRequest.on("shippingaddresschange",async ev=>{if(order!=null&&accessToken!=null&&endpoint!=null){const requiresBillingInfo=order?.requires_billing_info??!1,orderWithShipments=await setExpressFakeAddress({orderId:order.id,config:{accessToken,endpoint},address:{first_name:"Fake name",last_name:"Fake lastname",country_code:ev.shippingAddress.country??"",line_1:"Fake street 123",city:ev.shippingAddress.city??"Fake city",zip_code:ev.shippingAddress.postalCode??"12345",state_code:ev.shippingAddress.region??"Fake state",phone:"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0}}),shippingOptions=getExpressShippingMethods(orderWithShipments);shippingOptions!=null&&!isEmpty(shippingOptions)?ev.updateWith({status:"success",shippingOptions,total:{label:`#${orderWithShipments?.number??""}`,amount:orderWithShipments?.total_amount_with_taxes_cents??0}}):ev.updateWith({status:"invalid_shipping_address"})}else ev.updateWith({status:"fail"})}),paymentRequest.on("shippingoptionchange",async ev=>{if(order!=null&&accessToken!=null&&endpoint!=null){const updatedOrder=await setExpressShippingMethod({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev.shippingOption.id,params:{include:["shipments.available_shipping_methods"]}});ev.updateWith({status:"success",total:{label:`#${updatedOrder?.number??""}`,amount:updatedOrder?.total_amount_with_taxes_cents??0}})}else ev.updateWith({status:"fail"})}),paymentRequest.on("paymentmethod",async ev=>{if(console.log("ev",ev),order?.id==null)throw new Error("Order is null");if(paymentMethods==null)throw new Error("Payment methods are null");const[paymentMethod]=getAvailableExpressPayments(paymentMethods);if(paymentMethod==null)throw new Error("Payment method is null");if(paymentSource==null)throw new Error("Payment source is null");const requiresBillingInfo=order?.requires_billing_info??!1,paymentResource=paymentMethod?.payment_source_type;if(accessToken!=null&&endpoint!=null){const[firstName,lastName]=ev.payerName?.split(" ")??[],[line]=ev.shippingAddress?.addressLine??"";await setExpressFakeAddress({orderId:order.id,config:{accessToken,endpoint},address:{first_name:firstName??"Fake name",last_name:lastName??"Fake lastname",country_code:ev?.shippingAddress?.country??"",line_1:line??"Fake street 123",city:ev?.shippingAddress?.city??"Fake city",zip_code:ev?.shippingAddress?.postalCode??"12345",state_code:ev?.shippingAddress?.region??"Fake state",phone:ev?.payerPhone??"1234567890",billing_info:requiresBillingInfo?"Fake billing info":void 0}}),await setExpressShippingMethod({orderId:order.id,config:{accessToken,endpoint},selectFirst:!1,selectedShippingMethodId:ev?.shippingOption?.id,params:{include:["shipments.available_shipping_methods"]}});const{paymentIntent,error:confirmError}=await stripe.confirmCardPayment(clientSecret,{payment_method:ev.paymentMethod.id},{handleActions:!1});if(confirmError)ev.complete("fail"),console.error("Confirm card payment:",confirmError);else if(ev.complete("success"),paymentIntent.status==="requires_action"){const{error}=await stripe.confirmCardPayment(clientSecret);if(error)console.error("Confirm card payment:",error);else{const placeOrderParams={config:{accessToken,endpoint},orderId:order?.id,paymentResource,paymentSourceId:paymentSource?.id};try{const order2=await setExpressPlaceOrder(placeOrderParams);ev.complete("success"),expressRedirectUrl({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}else{const placeOrderParams={config:{accessToken,endpoint},orderId:order?.id,paymentResource,paymentSourceId:paymentSource?.id};try{const order2=await setExpressPlaceOrder(placeOrderParams);ev.complete("success"),expressRedirectUrl({order:order2,config:{accessToken,endpoint}})}catch(err){console.error("Place order:",err),ev.complete("fail")}}}}),_jsx(PaymentRequestButtonElement,{className:"",options:{paymentRequest}})):null}
|
|
@@ -14,6 +14,7 @@ type Props = PaymentMethodConfig['stripePayment'] & JSX.IntrinsicElements['div']
|
|
|
14
14
|
publishableKey: string;
|
|
15
15
|
locale?: StripeElementLocale;
|
|
16
16
|
clientSecret: string;
|
|
17
|
+
expressPayments?: boolean;
|
|
17
18
|
};
|
|
18
|
-
export declare function StripePayment({ publishableKey, show, options, clientSecret, locale, ...p }: Props): JSX.Element | null;
|
|
19
|
+
export declare function StripePayment({ publishableKey, show, options, clientSecret, locale, expressPayments, ...p }: Props): JSX.Element | null;
|
|
19
20
|
export default StripePayment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import{Elements,PaymentElement,useElements,useStripe}from"@stripe/react-stripe-js";import Parent from"../utils/Parent";import{setCustomerOrderParam}from"../../utils/localStorage";import OrderContext from"../../context/OrderContext";const defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet}){const ref=useRef(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),stripe=useStripe(),elements=useElements();useEffect(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=async()=>await onSubmit({event:ref.current,stripe,elements}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=async({event,stripe:stripe2,elements:elements2})=>{if(!stripe2)return!1;const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=order?.customer_email,billingDetails={name:billingInfo?.full_name,email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:billingInfo?.line_2,postal_code:billingInfo?.zip_code,state:billingInfo?.state_code}},{error}=await stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:window.location.href,payment_method_data:{billing_details:billingDetails}}});return error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1):!0}return!1};return _jsxs("form",{ref,children:[_jsx(PaymentElement,{id:"payment-element",options:{...defaultOptions,...options}}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}export function StripePayment({publishableKey,show,options,clientSecret,locale="auto",...p}){const[isLoaded,setIsLoaded]=useState(!1),[stripe,setStripe]=useState(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance,...divProps}=p;useEffect(()=>(show&&publishableKey&&import("@stripe/stripe-js").then(({loadStripe})=>{(async()=>{const res=await loadStripe(publishableKey,{locale});res!=null&&(setStripe(res),setIsLoaded(!0))})()}),()=>{setIsLoaded(!1)}),[show,publishableKey]);const elementsOptions={clientSecret,appearance:{...defaultAppearance,...appearance},fonts};return isLoaded&&stripe!=null&&clientSecret!=null?_jsx("div",{className:containerClassName,...divProps,children:_jsx(Elements,{stripe,options:elementsOptions,children:_jsx(StripePaymentForm,{options,templateCustomerSaveToWallet})})}):null}export default StripePayment;
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef,useState}from"react";import PaymentMethodContext from"../../context/PaymentMethodContext";import{Elements,PaymentElement,useElements,useStripe}from"@stripe/react-stripe-js";import Parent from"../utils/Parent";import{setCustomerOrderParam}from"../../utils/localStorage";import OrderContext from"../../context/OrderContext";import{StripeExpressPayment}from"./StripeExpressPayment";const defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet}){const ref=useRef(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=useContext(PaymentMethodContext),{order}=useContext(OrderContext),stripe=useStripe(),elements=useElements();useEffect(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=async()=>await onSubmit({event:ref.current,stripe,elements}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=async({event,stripe:stripe2,elements:elements2})=>{if(!stripe2)return!1;const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=order?.customer_email,billingDetails={name:billingInfo?.full_name,email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:billingInfo?.line_2,postal_code:billingInfo?.zip_code,state:billingInfo?.state_code}},{error}=await stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:window.location.href,payment_method_data:{billing_details:billingDetails}}});return error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message}]),!1):!0}return!1};return _jsxs("form",{ref,children:[_jsx(PaymentElement,{id:"payment-element",options:{...defaultOptions,...options}}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}export function StripePayment({publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1,...p}){const[isLoaded,setIsLoaded]=useState(!1),[stripe,setStripe]=useState(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance,...divProps}=p;useEffect(()=>(show&&publishableKey&&import("@stripe/stripe-js").then(({loadStripe})=>{(async()=>{const res=await loadStripe(publishableKey,{locale});res!=null&&(setStripe(res),setIsLoaded(!0))})()}),()=>{setIsLoaded(!1)}),[show,publishableKey]);const elementsOptions={clientSecret,appearance:{...defaultAppearance,...appearance},fonts};return isLoaded&&stripe!=null&&clientSecret!=null?_jsx("div",{className:containerClassName,...divProps,children:_jsx(Elements,{stripe,options:elementsOptions,children:expressPayments?_jsx(StripeExpressPayment,{clientSecret}):_jsx(StripePaymentForm,{options,templateCustomerSaveToWallet})})}):null}export default StripePayment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function SkuField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"sku",attribute,tagElement,context:SkuChildrenContext,...p,children})}export default SkuField;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import SkuChildrenContext from"../../context/SkuChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function SkuField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"sku",attribute,tagElement,context:SkuChildrenContext,...p,children})}export default SkuField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import StockTransferChildrenContext from"../../context/StockTransferChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function StockTransferField(props){const{attribute,tagElement,children,...p}=props;return _jsx(GenericFieldComponent,{resource:"stock_transfers",attribute,tagElement,context:StockTransferChildrenContext,...p,children})}export default StockTransferField;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import StockTransferChildrenContext from"../../context/StockTransferChildrenContext";import GenericFieldComponent from"../utils/GenericFieldComponent";export function StockTransferField(props){const{attribute,tagElement="span",children,...p}=props;return _jsx(GenericFieldComponent,{resource:"stock_transfers",attribute,tagElement,context:StockTransferChildrenContext,...p,children})}export default StockTransferField;
|
|
@@ -5,6 +5,7 @@ export interface InitialPaymentMethodChildrenContext {
|
|
|
5
5
|
clickableContainer?: boolean;
|
|
6
6
|
paymentSelected?: string;
|
|
7
7
|
setPaymentSelected?: (paymentId: string) => void;
|
|
8
|
+
expressPayments?: boolean;
|
|
8
9
|
}
|
|
9
10
|
declare const PaymentMethodChildrenContext: import("react").Context<InitialPaymentMethodChildrenContext>;
|
|
10
11
|
export default PaymentMethodChildrenContext;
|
|
@@ -108,9 +108,9 @@ export type ExcludeTag<T extends keyof JSX.IntrinsicElements> = Exclude<keyof JS
|
|
|
108
108
|
export type ExtractTag<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements, T>;
|
|
109
109
|
export type ConditionalElement<E> = ({
|
|
110
110
|
attribute: Extract<keyof E, 'image_url'>;
|
|
111
|
-
tagElement
|
|
111
|
+
tagElement?: ExtractTag<'img'>;
|
|
112
112
|
} & JSX.IntrinsicElements['img']) | ({
|
|
113
113
|
attribute: Exclude<keyof E, 'image_url'>;
|
|
114
|
-
tagElement
|
|
114
|
+
tagElement?: ExcludeTag<'img'>;
|
|
115
115
|
} & Omit<JSX.IntrinsicElements[ExcludeTag<'img'>], 'children'>);
|
|
116
116
|
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type CommerceLayerConfig } from '../context/CommerceLayerContext';
|
|
2
|
+
import { type Order, type PaymentMethod, type QueryParamsRetrieve, type AddressCreate } from '@commercelayer/sdk';
|
|
3
|
+
import { type PaymentRequestShippingOption } from '@stripe/stripe-js';
|
|
4
|
+
import { type PaymentResource } from '../reducers/PaymentMethodReducer';
|
|
5
|
+
export declare function getAvailableExpressPayments(paymentMethods: PaymentMethod[]): PaymentMethod[];
|
|
6
|
+
interface TFakeAddressParams {
|
|
7
|
+
/**
|
|
8
|
+
* The order id
|
|
9
|
+
*/
|
|
10
|
+
orderId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The Commerce Layer config
|
|
13
|
+
*/
|
|
14
|
+
config: Required<CommerceLayerConfig>;
|
|
15
|
+
/**
|
|
16
|
+
* The address resource
|
|
17
|
+
*/
|
|
18
|
+
address: AddressCreate;
|
|
19
|
+
/**
|
|
20
|
+
* The customer email
|
|
21
|
+
*/
|
|
22
|
+
email?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function setExpressFakeAddress({ orderId, config, address, email }: TFakeAddressParams): Promise<Order>;
|
|
25
|
+
export declare function getExpressShippingMethods(order: Order): PaymentRequestShippingOption[] | null;
|
|
26
|
+
type TSetExpressShippingMethodParams = {
|
|
27
|
+
/**
|
|
28
|
+
* The Commerce Layer config
|
|
29
|
+
*/
|
|
30
|
+
config: CommerceLayerConfig;
|
|
31
|
+
/**
|
|
32
|
+
* The order id
|
|
33
|
+
*/
|
|
34
|
+
orderId: string;
|
|
35
|
+
/**
|
|
36
|
+
* The query params
|
|
37
|
+
*/
|
|
38
|
+
params?: QueryParamsRetrieve;
|
|
39
|
+
} & ({
|
|
40
|
+
/**
|
|
41
|
+
* Select the first shipping method
|
|
42
|
+
*/
|
|
43
|
+
selectFirst: false;
|
|
44
|
+
/**
|
|
45
|
+
* The selected shipping method id
|
|
46
|
+
*/
|
|
47
|
+
selectedShippingMethodId?: string;
|
|
48
|
+
} | {
|
|
49
|
+
selectFirst?: true;
|
|
50
|
+
selectedShippingMethodId?: never;
|
|
51
|
+
});
|
|
52
|
+
export declare function setExpressShippingMethod({ config, orderId, selectFirst, selectedShippingMethodId, params }: TSetExpressShippingMethodParams): Promise<Order>;
|
|
53
|
+
export interface TSetExpressPlaceOrderParams {
|
|
54
|
+
/**
|
|
55
|
+
* The Commerce Layer config
|
|
56
|
+
*/
|
|
57
|
+
config: CommerceLayerConfig;
|
|
58
|
+
/**
|
|
59
|
+
* The order id
|
|
60
|
+
*/
|
|
61
|
+
orderId: string;
|
|
62
|
+
/**
|
|
63
|
+
* The payment resource
|
|
64
|
+
*/
|
|
65
|
+
paymentResource: PaymentResource;
|
|
66
|
+
/**
|
|
67
|
+
* The payment source id
|
|
68
|
+
*/
|
|
69
|
+
paymentSourceId: string;
|
|
70
|
+
}
|
|
71
|
+
export declare function setExpressPlaceOrder({ config, orderId, paymentResource, paymentSourceId }: TSetExpressPlaceOrderParams): Promise<Order>;
|
|
72
|
+
interface TExpressRedirectUrlParams {
|
|
73
|
+
/**
|
|
74
|
+
* Order resource
|
|
75
|
+
*/
|
|
76
|
+
order: Order;
|
|
77
|
+
/**
|
|
78
|
+
* The Commerce Layer config
|
|
79
|
+
*/
|
|
80
|
+
config: CommerceLayerConfig;
|
|
81
|
+
}
|
|
82
|
+
export declare function expressRedirectUrl({ order, config: { accessToken, endpoint } }: TExpressRedirectUrlParams): void;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import getSdk from"./getSdk";const availablePaymentMethods=["stripe_payments"];export function getAvailableExpressPayments(paymentMethods){return paymentMethods.filter(payment=>payment.payment_source_type?availablePaymentMethods.includes(payment.payment_source_type):!1)}export async function setExpressFakeAddress({orderId,config,address,email}){const params={include:["shipments.available_shipping_methods"]},sdk=getSdk(config),fakeAddress=await sdk.addresses.create(address),resource={id:orderId,billing_address:sdk.addresses.relationship(fakeAddress.id),_shipping_address_same_as_billing:!0};return email!=null&&(resource.customer_email=email),await sdk.orders.update(resource,params),await sdk.orders.retrieve(orderId,params)}export function getExpressShippingMethods(order){const isSingleShipment=order?.shipments?.length===1,shippingMethods=order?.shipments?.map(shipment=>shipment.available_shipping_methods);if(isSingleShipment)return shippingMethods==null?null:shippingMethods.flat().map(method=>({id:method?.id??"",label:method?.name??"",amount:method?.price_amount_for_shipment_cents??0,detail:""}));{if(shippingMethods==null)return null;const shippingOptionsAmount=[];return shippingMethods.forEach(methods=>{if(methods!=null){const[firstMethod]=methods;firstMethod!=null&&shippingOptionsAmount.push(firstMethod.price_amount_for_shipment_cents??0)}}),[{id:"shipping",label:"Shipping",amount:shippingOptionsAmount.reduce((a,b)=>a+b,0),detail:""}]}}export async function setExpressShippingMethod({config,orderId,selectFirst=!0,selectedShippingMethodId,params}){const sdk=getSdk(config),order=await sdk.orders.retrieve(orderId,params),shippingMethods=getExpressShippingMethods(order);if(order?.shipments==null)throw new Error("No shipments found");const isSingleShipment=order.shipments.length===1,[shipmentId]=order.shipments.map(shipment=>shipment.id);if(shipmentId==null)throw new Error("No shipment found");if(shippingMethods==null||shippingMethods?.length===0)throw new Error("No shipping methods found");if(isSingleShipment)if(selectFirst){const[firstShippingMethodId]=shippingMethods.map(method=>method.id);firstShippingMethodId!=null&&await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(firstShippingMethodId)})}else selectedShippingMethodId!=null&&await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(selectedShippingMethodId)});else for(const shipment of order?.shipments??[]){const[firstShippingMethodId]=shipment?.available_shipping_methods?.map(method=>method.id)??[];firstShippingMethodId!=null&&await sdk.shipments.update({id:shipment.id,shipping_method:sdk.shipping_methods.relationship(firstShippingMethodId)})}return await sdk.orders.retrieve(order.id,params)}export async function setExpressPlaceOrder({config,orderId,paymentResource,paymentSourceId}){const sdk=getSdk(config);return await sdk.orders.retrieve(orderId,{include:["shipments.shipping_method","payment_source","payment_method"]}),await sdk[paymentResource].update({id:paymentSourceId,order:sdk.orders.relationship(orderId)}),await sdk.orders.update({id:orderId,payment_source:sdk[paymentResource].relationship(paymentSourceId)}),await sdk.orders.update({id:orderId,_place:!0})}export function expressRedirectUrl({order,config:{accessToken,endpoint}}){if(accessToken==null)throw new Error("No access token found");if(endpoint==null)throw new Error("No endpoint found");const[slug]=endpoint.split(".commercelayer");if(slug==null)throw new Error("No slug found");const href=order?.checkout_url!=null?order?.checkout_url:`${slug}.commercelayer.app/checkout/${order.id}?accessToken=${accessToken}`;window.location.pathname.includes("/checkout")||window.location.pathname.includes(`/${order.id}`)?window.location.reload():window.location.href=href}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEmpty<V>(value: V): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function isEmpty(value){if(value==null)return!0;if(Array.isArray(value)||typeof value=="string")return value.length===0;if(typeof value=="object")return Object.keys(value).length===0;throw new Error("Invalid value for isEmpty function")}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/react-components",
|
|
3
|
-
"version": "4.4.0-beta.
|
|
3
|
+
"version": "4.4.0-beta.4",
|
|
4
4
|
"description": "The Official Commerce Layer React Components",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -160,34 +160,34 @@
|
|
|
160
160
|
"dependencies": {
|
|
161
161
|
"@ac-dev/countries-service": "^1.2.0",
|
|
162
162
|
"@ac-dev/states-service": "^1.1.1",
|
|
163
|
-
"@adyen/adyen-web": "^5.
|
|
163
|
+
"@adyen/adyen-web": "^5.40.0",
|
|
164
164
|
"@commercelayer/sdk": "^4.27.0",
|
|
165
165
|
"@stripe/react-stripe-js": "^2.1.0",
|
|
166
|
-
"@stripe/stripe-js": "^1.52.
|
|
167
|
-
"axios": "^1.3.
|
|
168
|
-
"braintree-web": "^3.92.
|
|
166
|
+
"@stripe/stripe-js": "^1.52.1",
|
|
167
|
+
"axios": "^1.3.6",
|
|
168
|
+
"braintree-web": "^3.92.1",
|
|
169
169
|
"frames-react": "^1.1.0",
|
|
170
170
|
"jwt-decode": "^3.1.2",
|
|
171
171
|
"lodash": "^4.17.21",
|
|
172
172
|
"rapid-form": "^2.1.0",
|
|
173
173
|
"react-table": "^7.8.0",
|
|
174
|
-
"react-window": "^1.8.
|
|
174
|
+
"react-window": "^1.8.9"
|
|
175
175
|
},
|
|
176
176
|
"devDependencies": {
|
|
177
177
|
"@commercelayer/js-auth": "^2.3.0",
|
|
178
|
-
"@playwright/test": "^1.32.
|
|
178
|
+
"@playwright/test": "^1.32.3",
|
|
179
179
|
"@testing-library/dom": "^9.2.0",
|
|
180
180
|
"@testing-library/react": "^14.0.0",
|
|
181
181
|
"@types/braintree-web": "^3.75.23",
|
|
182
|
-
"@types/lodash": "^4.14.
|
|
183
|
-
"@types/node": "^18.15.
|
|
182
|
+
"@types/lodash": "^4.14.194",
|
|
183
|
+
"@types/node": "^18.15.13",
|
|
184
184
|
"@types/prop-types": "^15.7.5",
|
|
185
|
-
"@types/react": "^18.0.
|
|
185
|
+
"@types/react": "^18.0.37",
|
|
186
186
|
"@types/react-table": "^7.7.14",
|
|
187
187
|
"@types/react-test-renderer": "^18.0.0",
|
|
188
188
|
"@types/react-window": "^1.8.5",
|
|
189
|
-
"@vitejs/plugin-react": "^
|
|
190
|
-
"@vitest/coverage-c8": "^0.
|
|
189
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
190
|
+
"@vitest/coverage-c8": "^0.30.1",
|
|
191
191
|
"jsdom": "^21.1.1",
|
|
192
192
|
"minimize-js": "^1.3.1",
|
|
193
193
|
"msw": "^1.2.1",
|
|
@@ -196,10 +196,10 @@
|
|
|
196
196
|
"react-test-renderer": "^18.2.0",
|
|
197
197
|
"tsc-alias": "^1.8.5",
|
|
198
198
|
"tslib": "^2.5.0",
|
|
199
|
-
"typescript": "^5.0.
|
|
200
|
-
"vite": "^4.
|
|
201
|
-
"vite-tsconfig-paths": "^4.0
|
|
202
|
-
"vitest": "^0.
|
|
199
|
+
"typescript": "^5.0.4",
|
|
200
|
+
"vite": "^4.3.1",
|
|
201
|
+
"vite-tsconfig-paths": "^4.2.0",
|
|
202
|
+
"vitest": "^0.30.1"
|
|
203
203
|
},
|
|
204
204
|
"peerDependencies": {
|
|
205
205
|
"react": "^18.0.0"
|