♻️ Refactor payment method choices

This commit is contained in:
Philipp Stracker 2025-02-07 19:25:40 +01:00
parent 307a55b4ec
commit 618b687428
No known key found for this signature in database

View file

@ -1,4 +1,5 @@
import { __ } from '@wordpress/i18n';
import { useMemo } from '@wordpress/element';
import { CommonHooks, OnboardingHooks } from '../../../../data';
import { OptionSelector } from '../../../ReusableComponents/Fields';
@ -6,9 +7,37 @@ import PricingDescription from '../Components/PricingDescription';
import OnboardingHeader from '../Components/OnboardingHeader';
import PaymentFlow from '../Components/PaymentFlow';
const StepPaymentMethods = ( {} ) => {
const StepPaymentMethods = () => {
const { optionalMethods, setOptionalMethods } =
OnboardingHooks.useOptionalPaymentMethods();
const { isCasualSeller } = OnboardingHooks.useBusiness();
const optionalMethodTitle = useMemo( () => {
// The BCDC flow does not show a title.
if ( isCasualSeller ) {
return null;
}
return __(
'Available with additional application',
'woocommerce-paypal-payments'
);
}, [ isCasualSeller ] );
const methodChoices = [
{
value: true,
title: optionalMethodTitle,
description: <OptionalMethodDescription />,
},
{
title: __(
'No thanks, I prefer to use a different provider for processing credit cards, digital wallets, and local payment methods',
'woocommerce-paypal-payments'
),
value: false,
},
];
return (
<div className="ppcp-r-page-optional-payment-methods">
@ -45,20 +74,6 @@ const PaymentStepTitle = () => {
);
};
const OptionalMethodTitle = () => {
const { isCasualSeller } = OnboardingHooks.useBusiness();
// The BCDC flow does not show a title.
if ( isCasualSeller ) {
return '';
}
return __(
'Available with additional application',
'woocommerce-paypal-payments'
);
};
const OptionalMethodDescription = () => {
const { storeCountry, storeCurrency } = CommonHooks.useWooSettings();
const { isCasualSeller } = OnboardingHooks.useBusiness();
@ -78,18 +93,3 @@ const OptionalMethodDescription = () => {
/>
);
};
const methodChoices = [
{
value: true,
title: <OptionalMethodTitle />,
description: <OptionalMethodDescription />,
},
{
title: __(
'No thanks, I prefer to use a different provider for processing credit cards, digital wallets, and local payment methods',
'woocommerce-paypal-payments'
),
value: false,
},
];