mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Conditionally check/uncheck the Order Intent
This commit is contained in:
parent
5059ca24ff
commit
167e12e54e
2 changed files with 16 additions and 1 deletions
|
@ -1,7 +1,13 @@
|
|||
import { ToggleControl } from '@wordpress/components';
|
||||
import { Action, Description } from '../Elements';
|
||||
|
||||
const ControlToggleButton = ( { label, description, value, onChange } ) => (
|
||||
const ControlToggleButton = ( {
|
||||
label,
|
||||
description,
|
||||
value,
|
||||
onChange,
|
||||
disabled = false,
|
||||
} ) => (
|
||||
<Action>
|
||||
<ToggleControl
|
||||
className="ppcp--control-toggle"
|
||||
|
@ -12,6 +18,7 @@ const ControlToggleButton = ( { label, description, value, onChange } ) => (
|
|||
help={
|
||||
description ? <Description>{ description }</Description> : null
|
||||
}
|
||||
disabled={ disabled }
|
||||
/>
|
||||
</Action>
|
||||
);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { __ } from '@wordpress/i18n';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { ControlToggleButton } from '../../../../../ReusableComponents/Controls';
|
||||
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
||||
|
@ -12,6 +13,12 @@ const OrderIntent = () => {
|
|||
setCaptureVirtualOnlyOrders,
|
||||
} = SettingsHooks.useSettings();
|
||||
|
||||
useEffect( () => {
|
||||
if ( ! authorizeOnly && captureVirtualOnlyOrders ) {
|
||||
setCaptureVirtualOnlyOrders( false );
|
||||
}
|
||||
}, [ authorizeOnly ] );
|
||||
|
||||
return (
|
||||
<SettingsBlock
|
||||
title={ __( 'Order Intent', 'woocommerce-paypal-payments' ) }
|
||||
|
@ -34,6 +41,7 @@ const OrderIntent = () => {
|
|||
) }
|
||||
onChange={ setCaptureVirtualOnlyOrders }
|
||||
value={ captureVirtualOnlyOrders }
|
||||
disabled={ ! authorizeOnly }
|
||||
/>
|
||||
</SettingsBlock>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue