mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
✨ Create new hook to handle the save logic
This commit is contained in:
parent
ee156881c2
commit
6d81cf5139
2 changed files with 37 additions and 15 deletions
34
modules/ppcp-settings/resources/js/hooks/useSaveSettings.js
Normal file
34
modules/ppcp-settings/resources/js/hooks/useSaveSettings.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import {
|
||||
CommonHooks,
|
||||
PaymentHooks,
|
||||
SettingsHooks,
|
||||
StylingHooks,
|
||||
} from '../data';
|
||||
|
||||
export const useSaveSettings = () => {
|
||||
const { withActivity } = CommonHooks.useBusyState();
|
||||
|
||||
const { persist: persistPayment } = PaymentHooks.useStore();
|
||||
const { persist: persistSettings } = SettingsHooks.useStore();
|
||||
const { persist: persistStyling } = StylingHooks.useStore();
|
||||
|
||||
const persistAll = () => {
|
||||
withActivity(
|
||||
'persist-methods',
|
||||
'Save payment methods',
|
||||
persistPayment
|
||||
);
|
||||
withActivity(
|
||||
'persist-settings',
|
||||
'Save the settings',
|
||||
persistSettings
|
||||
);
|
||||
withActivity(
|
||||
'persist-styling',
|
||||
'Save styling details',
|
||||
persistStyling
|
||||
);
|
||||
};
|
||||
|
||||
return { persistAll };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue