mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
♻️ Move icon-selection to the payment-config hook
Reason: Business logic (icon choice) should be kept in a single place, instead of letting the rendering component decide which icons to use.
This commit is contained in:
parent
822086e64c
commit
6021ef6db2
2 changed files with 7 additions and 10 deletions
|
@ -12,10 +12,10 @@ import AdvancedOptionsForm from '../Components/AdvancedOptionsForm';
|
|||
import { usePaymentConfig } from '../hooks/usePaymentConfig';
|
||||
|
||||
const StepWelcome = ( { setStep, currentStep } ) => {
|
||||
const { storeCountry } = CommonHooks.useWooSettings();
|
||||
const { storeCountry, isBranded } = CommonHooks.useWooSettings();
|
||||
const { canUseCardPayments, canUseFastlane } = OnboardingHooks.useFlags();
|
||||
|
||||
const { acdcIcons, bcdcIcons } = usePaymentConfig(
|
||||
const { icons } = usePaymentConfig(
|
||||
storeCountry,
|
||||
canUseCardPayments,
|
||||
canUseFastlane
|
||||
|
@ -42,9 +42,7 @@ const StepWelcome = ( { setStep, currentStep } ) => {
|
|||
/>
|
||||
<div className="ppcp-r-inner-container">
|
||||
<WelcomeFeatures />
|
||||
<PaymentMethodIcons
|
||||
icons={ canUseCardPayments ? acdcIcons : bcdcIcons }
|
||||
/>
|
||||
<PaymentMethodIcons icons={ icons } />
|
||||
<p className="ppcp-r-button__description">
|
||||
{ __(
|
||||
'Click the button below to be guided through connecting your existing PayPal account or creating a new one. You will be able to choose the payment options that are right for your store.',
|
||||
|
|
|
@ -131,14 +131,14 @@ const filterMethods = ( methods, conditions ) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const usePaymentConfig = ( country, useAcdc, isFastlane ) => {
|
||||
export const usePaymentConfig = ( country, canUseCardPayments, isFastlane ) => {
|
||||
return useMemo( () => {
|
||||
const countryConfig = countrySpecificConfigs[ country ] || {};
|
||||
const config = { ...defaultConfig, ...countryConfig };
|
||||
const learnMoreConfig = learnMoreLinks[ country ] || {};
|
||||
|
||||
// Determine the "right side" items: Either BCDC or ACDC items.
|
||||
const optionalMethods = useAcdc
|
||||
const optionalMethods = canUseCardPayments
|
||||
? config.extendedMethods
|
||||
: config.basicMethods;
|
||||
|
||||
|
@ -151,8 +151,7 @@ export const usePaymentConfig = ( country, useAcdc, isFastlane ) => {
|
|||
...config,
|
||||
optionalMethods: availableOptionalMethods,
|
||||
learnMoreConfig,
|
||||
acdcIcons: config.acdcIcons,
|
||||
bcdcIcons: config.bcdcIcons,
|
||||
icons: canUseCardPayments ? config.acdcIcons : config.bcdcIcons,
|
||||
};
|
||||
}, [ country, useAcdc, isFastlane ] );
|
||||
}, [ country, canUseCardPayments, isFastlane ] );
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue