Merge branch 'trunk' into PCP-4120-add-payment-method-modal-data-to-data-store

This commit is contained in:
Emili Castells Guasch 2025-01-23 11:16:05 +01:00
commit 55a0dd4824
24 changed files with 346 additions and 181 deletions

View file

@ -12,8 +12,31 @@ const SelectBox = ( props ) => {
boxClassName += ' selected';
}
const handleClick = () => {
if ( props.type === 'checkbox' ) {
let newValue;
if ( Array.isArray( props.currentValue ) ) {
if ( props.currentValue.includes( props.value ) ) {
newValue = props.currentValue.filter(
( optionValue ) => optionValue !== props.value
);
} else {
newValue = [ ...props.currentValue, props.value ];
}
} else {
newValue = ! props.currentValue;
}
props.changeCallback( newValue );
}
};
return (
<div className={ boxClassName }>
<div
className={ boxClassName }
onClick={ props.type === 'checkbox' ? handleClick : undefined }
>
{ props.type === 'radio' && (
<PayPalRdb
{ ...{
@ -22,11 +45,7 @@ const SelectBox = ( props ) => {
} }
/>
) }
{ props.type === 'checkbox' && (
<PayPalCheckbox
{ ...props }
/>
) }
{ props.type === 'checkbox' && <PayPalCheckbox { ...props } /> }
<div className="ppcp-r-select-box__content">
<div className="ppcp-r-select-box__content-inner">
<span className="ppcp-r-select-box__title">

View file

@ -36,7 +36,8 @@ const ALL_STEPS = [
id: 'methods',
title: __( 'Choose checkout options', 'woocommerce-paypal-payments' ),
StepComponent: StepPaymentMethods,
canProceed: () => true,
canProceed: ( { methods } ) =>
methods.areOptionalPaymentMethodsEnabled !== null,
},
{
id: 'complete',

View file

@ -136,10 +136,12 @@ export const useSteps = () => {
export const useNavigationState = () => {
const products = useProducts();
const business = useBusiness();
const methods = useOptionalPaymentMethods();
return {
products,
business,
methods,
};
};