mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
✨ Implement logic for the enable buttons checkbox
This commit is contained in:
parent
2eac7bc5c9
commit
5c371d928e
3 changed files with 37 additions and 12 deletions
|
@ -10,7 +10,8 @@ import {
|
|||
} from '../Layout';
|
||||
|
||||
const LocationSelector = ( { location, setLocation } ) => {
|
||||
const { choices, details } = StylingHooks.useLocationProps( location );
|
||||
const { choices, details, isActive, setActive } =
|
||||
StylingHooks.useLocationProps( location );
|
||||
|
||||
const activateCheckbox = {
|
||||
value: 'active',
|
||||
|
@ -51,7 +52,8 @@ const LocationSelector = ( { location, setLocation } ) => {
|
|||
className="location-activation"
|
||||
separatorAndGap={ false }
|
||||
options={ [ activateCheckbox ] }
|
||||
value={ 'active' }
|
||||
value={ isActive }
|
||||
onChange={ setActive }
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -6,16 +6,36 @@ import {
|
|||
ButtonLabel,
|
||||
ButtonColor,
|
||||
} from './Content';
|
||||
import { StylingHooks } from '../../../../../data';
|
||||
|
||||
const SettingsPanel = ( { location, setLocation } ) => (
|
||||
<div className="settings-panel">
|
||||
<LocationSelector location={ location } setLocation={ setLocation } />
|
||||
<PaymentMethods location={ location } />
|
||||
<ButtonLayout location={ location } />
|
||||
<ButtonShape location={ location } />
|
||||
<ButtonLabel location={ location } />
|
||||
<ButtonColor location={ location } />
|
||||
</div>
|
||||
);
|
||||
const SettingsPanel = ( { location, setLocation } ) => {
|
||||
const { isActive } = StylingHooks.useLocationProps( location );
|
||||
|
||||
const LocationDetails = () => {
|
||||
if ( ! isActive ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<PaymentMethods location={ location } />
|
||||
<ButtonLayout location={ location } />
|
||||
<ButtonShape location={ location } />
|
||||
<ButtonLabel location={ location } />
|
||||
<ButtonColor location={ location } />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="settings-panel">
|
||||
<LocationSelector
|
||||
location={ location }
|
||||
setLocation={ setLocation }
|
||||
/>
|
||||
<LocationDetails />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsPanel;
|
||||
|
|
|
@ -83,11 +83,14 @@ export const useStylingLocation = () => {
|
|||
};
|
||||
|
||||
export const useLocationProps = ( location ) => {
|
||||
const { getLocationProp, setLocationProp } = useHooks();
|
||||
const details = STYLING_LOCATIONS[ location ] ?? {};
|
||||
|
||||
return {
|
||||
choices: Object.values( STYLING_LOCATIONS ),
|
||||
details,
|
||||
isActive: getLocationProp( location, 'enabled' ),
|
||||
setActive: ( state ) => setLocationProp( location, 'enabled', state ),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue