mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
♻️ Migrate ToggleSetting to ControlToggleButton
This commit is contained in:
parent
0ca45eef53
commit
8bd29e921f
8 changed files with 87 additions and 124 deletions
|
@ -0,0 +1,19 @@
|
||||||
|
import { ToggleControl } from '@wordpress/components';
|
||||||
|
import { Action, Description } from '../Elements';
|
||||||
|
|
||||||
|
const ControlToggleButton = ( { label, description, value, onChange } ) => {
|
||||||
|
return (
|
||||||
|
<Action>
|
||||||
|
<ToggleControl
|
||||||
|
className="ppcp-r-settings-block__toggle-control"
|
||||||
|
__nextHasNoMarginBottom={ true }
|
||||||
|
checked={ value }
|
||||||
|
onChange={ onChange }
|
||||||
|
label={ label }
|
||||||
|
help={ <Description>{ description }</Description> }
|
||||||
|
/>
|
||||||
|
</Action>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ControlToggleButton;
|
|
@ -1,27 +0,0 @@
|
||||||
import { ToggleControl } from '@wordpress/components';
|
|
||||||
import SettingsBlock from '../SettingsBlock';
|
|
||||||
import { Header, Title, Action, Description } from '../Elements';
|
|
||||||
|
|
||||||
const ToggleSettingsBlock = ( { title, description, ...props } ) => (
|
|
||||||
<SettingsBlock { ...props } className="ppcp-r-settings-block__toggle">
|
|
||||||
<Action>
|
|
||||||
<ToggleControl
|
|
||||||
className="ppcp-r-settings-block__toggle-control"
|
|
||||||
__nextHasNoMarginBottom={ true }
|
|
||||||
checked={ props.actionProps?.value }
|
|
||||||
onChange={ ( newValue ) =>
|
|
||||||
props.actionProps?.callback(
|
|
||||||
props.actionProps?.key,
|
|
||||||
newValue
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Action>
|
|
||||||
<Header>
|
|
||||||
{ title && <Title>{ title }</Title> }
|
|
||||||
{ description && <Description>{ description }</Description> }
|
|
||||||
</Header>
|
|
||||||
</SettingsBlock>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default ToggleSettingsBlock;
|
|
|
@ -1,10 +1,10 @@
|
||||||
export { default as ButtonSettingsBlock } from './ButtonSettingsBlock';
|
export { default as ButtonSettingsBlock } from './ButtonSettingsBlock';
|
||||||
export { default as SelectSettingsBlock } from './SelectSettingsBlock';
|
export { default as SelectSettingsBlock } from './SelectSettingsBlock';
|
||||||
export { default as AccordionSettingsBlock } from './AccordionSettingsBlock';
|
export { default as AccordionSettingsBlock } from './AccordionSettingsBlock';
|
||||||
export { default as ToggleSettingsBlock } from './ToggleSettingsBlock';
|
|
||||||
export { default as RadioSettingsBlock } from './RadioSettingsBlock';
|
export { default as RadioSettingsBlock } from './RadioSettingsBlock';
|
||||||
export { default as PaymentMethodsBlock } from './PaymentMethodsBlock';
|
export { default as PaymentMethodsBlock } from './PaymentMethodsBlock';
|
||||||
export { default as PaymentMethodItemBlock } from './PaymentMethodItemBlock';
|
export { default as PaymentMethodItemBlock } from './PaymentMethodItemBlock';
|
||||||
|
|
||||||
export { default as ControlStaticValue } from './ControlStaticValue';
|
export { default as ControlStaticValue } from './ControlStaticValue';
|
||||||
export { default as ControlTextInput } from './ControlTextInput';
|
export { default as ControlTextInput } from './ControlTextInput';
|
||||||
|
export { default as ControlToggleButton } from './ControlToggleButton';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { __ } from '@wordpress/i18n';
|
||||||
import {
|
import {
|
||||||
AccordionSettingsBlock,
|
AccordionSettingsBlock,
|
||||||
RadioSettingsBlock,
|
RadioSettingsBlock,
|
||||||
ToggleSettingsBlock,
|
ControlToggleButton,
|
||||||
ControlTextInput,
|
ControlTextInput,
|
||||||
SelectSettingsBlock,
|
SelectSettingsBlock,
|
||||||
} from '../../../../ReusableComponents/SettingsBlocks';
|
} from '../../../../ReusableComponents/SettingsBlocks';
|
||||||
|
@ -66,7 +66,7 @@ const PaypalSettings = ( { updateFormValue, settings } ) => {
|
||||||
} }
|
} }
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ToggleSettingsBlock
|
<ControlToggleButton
|
||||||
title={ __(
|
title={ __(
|
||||||
'Instant payments only',
|
'Instant payments only',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
} from '../../../../../ReusableComponents/Elements';
|
} from '../../../../../ReusableComponents/Elements';
|
||||||
import {
|
import {
|
||||||
AccordionSettingsBlock,
|
AccordionSettingsBlock,
|
||||||
ToggleSettingsBlock,
|
ControlToggleButton,
|
||||||
} from '../../../../../ReusableComponents/SettingsBlocks';
|
} from '../../../../../ReusableComponents/SettingsBlocks';
|
||||||
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ const Troubleshooting = ( { updateFormValue, settings } ) => {
|
||||||
value: settings.payNowExperience,
|
value: settings.payNowExperience,
|
||||||
} }
|
} }
|
||||||
>
|
>
|
||||||
<ToggleSettingsBlock
|
<ControlToggleButton
|
||||||
title={ __( 'Logging', 'woocommerce-paypal-payments' ) }
|
title={ __( 'Logging', 'woocommerce-paypal-payments' ) }
|
||||||
description={ __(
|
description={ __(
|
||||||
'Log additional debugging information in the WooCommerce logs that can assist technical staff to determine issues.',
|
'Log additional debugging information in the WooCommerce logs that can assist technical staff to determine issues.',
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import {
|
|
||||||
Header,
|
import { ControlToggleButton } from '../../../../../ReusableComponents/SettingsBlocks';
|
||||||
Title,
|
|
||||||
Description,
|
|
||||||
} from '../../../../../ReusableComponents/Elements';
|
|
||||||
import { ToggleSettingsBlock } from '../../../../../ReusableComponents/SettingsBlocks';
|
|
||||||
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
||||||
import { SettingsHooks } from '../../../../../../data';
|
import { SettingsHooks } from '../../../../../../data';
|
||||||
|
|
||||||
|
@ -17,38 +13,26 @@ const OrderIntent = () => {
|
||||||
} = SettingsHooks.useSettings();
|
} = SettingsHooks.useSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsBlock>
|
<SettingsBlock
|
||||||
<Header>
|
title={ __( 'Order Intent', 'woocommerce-paypal-payments' ) }
|
||||||
<Title>
|
description={ __(
|
||||||
{ __( 'Order Intent', 'woocommerce-paypal-payments' ) }
|
'Choose between immediate capture or authorization-only, with manual capture in the Order section.',
|
||||||
</Title>
|
'woocommerce-paypal-payments'
|
||||||
<Description>
|
) }
|
||||||
{ __(
|
>
|
||||||
'Choose between immediate capture or authorization-only, with manual capture in the Order section.',
|
<ControlToggleButton
|
||||||
'woocommerce-paypal-payments'
|
label={ __( 'Authorize Only', 'woocommerce-paypal-payments' ) }
|
||||||
) }
|
onChange={ setAuthorizeOnly }
|
||||||
</Description>
|
value={ authorizeOnly }
|
||||||
</Header>
|
|
||||||
|
|
||||||
<ToggleSettingsBlock
|
|
||||||
title={ __( 'Authorize Only', 'woocommerce-paypal-payments' ) }
|
|
||||||
actionProps={ {
|
|
||||||
callback: setAuthorizeOnly,
|
|
||||||
key: 'authorizeOnly',
|
|
||||||
value: authorizeOnly,
|
|
||||||
} }
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ToggleSettingsBlock
|
<ControlToggleButton
|
||||||
title={ __(
|
label={ __(
|
||||||
'Capture Virtual-Only Orders',
|
'Capture Virtual-Only Orders',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
actionProps={ {
|
onChange={ setCaptureVirtualOnlyOrders }
|
||||||
callback: setCaptureVirtualOnlyOrders,
|
value={ captureVirtualOnlyOrders }
|
||||||
key: 'captureVirtualOnlyOrders',
|
|
||||||
value: captureVirtualOnlyOrders,
|
|
||||||
} }
|
|
||||||
/>
|
/>
|
||||||
</SettingsBlock>
|
</SettingsBlock>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,24 +1,28 @@
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { ToggleSettingsBlock } from '../../../../../ReusableComponents/SettingsBlocks';
|
|
||||||
|
import { ControlToggleButton } from '../../../../../ReusableComponents/SettingsBlocks';
|
||||||
import { SettingsHooks } from '../../../../../../data';
|
import { SettingsHooks } from '../../../../../../data';
|
||||||
|
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
||||||
|
|
||||||
const PayNowExperience = () => {
|
const PayNowExperience = () => {
|
||||||
const { payNowExperience, setPayNowExperience } =
|
const { payNowExperience, setPayNowExperience } =
|
||||||
SettingsHooks.useSettings();
|
SettingsHooks.useSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToggleSettingsBlock
|
<SettingsBlock>
|
||||||
title={ __( 'Pay Now Experience', 'woocommerce-paypal-payments' ) }
|
<ControlToggleButton
|
||||||
description={ __(
|
label={ __(
|
||||||
'Let PayPal customers skip the Order Review page by selecting shipping options directly within PayPal.',
|
'Pay Now Experience',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
actionProps={ {
|
description={ __(
|
||||||
key: 'payNowExperience',
|
'Let PayPal customers skip the Order Review page by selecting shipping options directly within PayPal.',
|
||||||
callback: setPayNowExperience,
|
'woocommerce-paypal-payments'
|
||||||
value: payNowExperience,
|
) }
|
||||||
} }
|
onChange={ setPayNowExperience }
|
||||||
/>
|
value={ payNowExperience }
|
||||||
|
/>
|
||||||
|
</SettingsBlock>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
Description,
|
Description,
|
||||||
} from '../../../../../ReusableComponents/Elements';
|
} from '../../../../../ReusableComponents/Elements';
|
||||||
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
import SettingsBlock from '../../../../../ReusableComponents/SettingsBlock';
|
||||||
import { ToggleSettingsBlock } from '../../../../../ReusableComponents/SettingsBlocks';
|
import { ControlToggleButton } from '../../../../../ReusableComponents/SettingsBlocks';
|
||||||
import { SettingsHooks } from '../../../../../../data';
|
import { SettingsHooks } from '../../../../../../data';
|
||||||
|
|
||||||
const SavePaymentMethods = () => {
|
const SavePaymentMethods = () => {
|
||||||
|
@ -17,51 +17,37 @@ const SavePaymentMethods = () => {
|
||||||
} = SettingsHooks.useSettings();
|
} = SettingsHooks.useSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsBlock className="ppcp-r-settings-block--save-payment-methods">
|
<SettingsBlock
|
||||||
<Header>
|
title={ __(
|
||||||
<Title>
|
'Save payment methods',
|
||||||
{ __(
|
'woocommerce-paypal-payments'
|
||||||
'Save payment methods',
|
) }
|
||||||
'woocommerce-paypal-payments'
|
description={ __(
|
||||||
) }
|
"Securely store customers' payment methods for future payments and subscriptions, simplifying checkout and enabling recurring transactions.",
|
||||||
</Title>
|
'woocommerce-paypal-payments'
|
||||||
<Description>
|
) }
|
||||||
{ __(
|
className="ppcp--save-payment-methods"
|
||||||
"Securely store customers' payment methods for future payments and subscriptions, simplifying checkout and enabling recurring transactions.",
|
>
|
||||||
'woocommerce-paypal-payments'
|
<ControlToggleButton
|
||||||
) }
|
label={ __(
|
||||||
</Description>
|
|
||||||
</Header>
|
|
||||||
|
|
||||||
<ToggleSettingsBlock
|
|
||||||
title={ __(
|
|
||||||
'Save PayPal and Venmo',
|
'Save PayPal and Venmo',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
description={
|
description={ sprintf(
|
||||||
<div
|
/* translators: 1: URL to Pay Later documentation, 2: URL to Alternative Payment Methods documentation */
|
||||||
dangerouslySetInnerHTML={ {
|
__(
|
||||||
__html: sprintf(
|
'Securely store your customers\' PayPal accounts for a seamless checkout experience. <br />This will disable all <a target="_blank" rel="noreferrer" href="%1$s">Pay Later</a> features and <a target="_blank" rel="noreferrer" href="%2$s">Alternative Payment Methods</a> on your site.',
|
||||||
/* translators: 1: URL to Pay Later documentation, 2: URL to Alternative Payment Methods documentation */
|
'woocommerce-paypal-payments'
|
||||||
__(
|
),
|
||||||
'Securely store your customers\' PayPal accounts for a seamless checkout experience. <br />This will disable all <a target="_blank" rel="noreferrer" href="%1$s">Pay Later</a> features and <a target="_blank" rel="noreferrer" href="%2$s">Alternative Payment Methods</a> on your site.',
|
'https://woocommerce.com/document/woocommerce-paypal-payments/#pay-later',
|
||||||
'woocommerce-paypal-payments'
|
'https://woocommerce.com/document/woocommerce-paypal-payments/#alternative-payment-methods'
|
||||||
),
|
) }
|
||||||
'https://woocommerce.com/document/woocommerce-paypal-payments/#pay-later',
|
value={ savePaypalAndVenmo }
|
||||||
'https://woocommerce.com/document/woocommerce-paypal-payments/#alternative-payment-methods'
|
onChange={ setSavePaypalAndVenmo }
|
||||||
),
|
|
||||||
} }
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
actionProps={ {
|
|
||||||
value: savePaypalAndVenmo,
|
|
||||||
callback: setSavePaypalAndVenmo,
|
|
||||||
key: 'savePaypalAndVenmo',
|
|
||||||
} }
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ToggleSettingsBlock
|
<ControlToggleButton
|
||||||
title={ __(
|
label={ __(
|
||||||
'Save Credit and Debit Cards',
|
'Save Credit and Debit Cards',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
|
@ -69,11 +55,8 @@ const SavePaymentMethods = () => {
|
||||||
"Securely store your customer's credit card.",
|
"Securely store your customer's credit card.",
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
) }
|
) }
|
||||||
actionProps={ {
|
onChange={ setSaveCardDetails }
|
||||||
callback: setSaveCardDetails,
|
value={ saveCardDetails }
|
||||||
key: 'saveCreditCardAndDebitCard',
|
|
||||||
value: saveCardDetails,
|
|
||||||
} }
|
|
||||||
/>
|
/>
|
||||||
</SettingsBlock>
|
</SettingsBlock>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue