Add busy-state to the save button

This commit is contained in:
Philipp Stracker 2025-01-17 19:07:26 +01:00
parent 7365f75eba
commit 1726878f55
No known key found for this signature in database

View file

@ -2,27 +2,33 @@ import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import TopNavigation from '../../../ReusableComponents/TopNavigation';
import { StylingHooks } from '../../../../data';
import { CommonHooks, StylingHooks } from '../../../../data';
import BusyStateWrapper from '../../../ReusableComponents/BusyStateWrapper';
const SettingsNavigation = () => {
const { withActivity, isBusy } = CommonHooks.useBusyState();
// Todo: Implement other stores here.
const { persist: persistStyling } = StylingHooks.useStore();
const isBusy = false; // TODO: Implement loading state.
const handleSaveClick = () => {
persistStyling();
// Todo: Add other stores here.
withActivity(
'persist-styling',
'Save styling details',
persistStyling
);
};
const title = __( 'PayPal Payments', 'woocommerce-paypal-payments' );
return (
<TopNavigation title={ title } exitOnTitleClick={ true }>
<Button
variant="primary"
disabled={ isBusy }
onClick={ handleSaveClick }
>
{ __( 'Save', 'woocommerce-paypal-payments' ) }
</Button>
<BusyStateWrapper>
<Button variant="primary" onClick={ handleSaveClick }>
{ __( 'Save', 'woocommerce-paypal-payments' ) }
</Button>
</BusyStateWrapper>
</TopNavigation>
);
};