♻️ Shorten hook property name

This commit is contained in:
Philipp Stracker 2025-01-23 19:52:17 +01:00
parent 3840352c54
commit fbb4420b80
No known key found for this signature in database
2 changed files with 13 additions and 19 deletions

View file

@ -7,10 +7,8 @@ import OnboardingHeader from '../Components/OnboardingHeader';
import OptionalPaymentMethods from '../Components/OptionalPaymentMethods';
const StepPaymentMethods = ( {} ) => {
const {
areOptionalPaymentMethodsEnabled,
setAreOptionalPaymentMethodsEnabled,
} = OnboardingHooks.useOptionalPaymentMethods();
const { optionalMethods, setOptionalMethods } =
OnboardingHooks.useOptionalPaymentMethods();
return (
<div className="ppcp-r-page-optional-payment-methods">
@ -19,8 +17,8 @@ const StepPaymentMethods = ( {} ) => {
<OptionSelector
multiSelect={ false }
options={ methodChoices }
onChange={ setAreOptionalPaymentMethodsEnabled }
value={ areOptionalPaymentMethodsEnabled }
onChange={ setOptionalMethods }
value={ optionalMethods }
/>
<PricingDescription />

View file

@ -36,10 +36,9 @@ const useHooks = () => {
const [ completed, setCompleted ] = usePersistent( 'completed' );
const [ isCasualSeller, setIsCasualSeller ] =
usePersistent( 'isCasualSeller' );
const [
areOptionalPaymentMethodsEnabled,
setAreOptionalPaymentMethodsEnabled,
] = usePersistent( 'areOptionalPaymentMethodsEnabled' );
const [ optionalMethods, setOptionalMethods ] = usePersistent(
'areOptionalPaymentMethodsEnabled'
);
const [ products, setProducts ] = usePersistent( 'products' );
const savePersistent = async ( setter, value ) => {
@ -70,9 +69,9 @@ const useHooks = () => {
setManualClientSecret: ( value ) => {
return savePersistent( setManualClientSecret, value );
},
areOptionalPaymentMethodsEnabled,
setAreOptionalPaymentMethodsEnabled: ( value ) => {
return savePersistent( setAreOptionalPaymentMethodsEnabled, value );
optionalMethods,
setOptionalMethods: ( value ) => {
return savePersistent( setOptionalMethods, value );
},
products,
setProducts: ( activeProducts ) => {
@ -114,14 +113,11 @@ export const useProducts = () => {
};
export const useOptionalPaymentMethods = () => {
const {
areOptionalPaymentMethodsEnabled,
setAreOptionalPaymentMethodsEnabled,
} = useHooks();
const { optionalMethods, setOptionalMethods } = useHooks();
return {
areOptionalPaymentMethodsEnabled,
setAreOptionalPaymentMethodsEnabled,
optionalMethods,
setOptionalMethods,
};
};