Create new hook to handle the save logic

This commit is contained in:
Philipp Stracker 2025-01-21 13:15:40 +01:00
parent ee156881c2
commit 6d81cf5139
No known key found for this signature in database
2 changed files with 37 additions and 15 deletions

View 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 };
};