diff --git a/modules/ppcp-settings/resources/js/data/common/hooks.js b/modules/ppcp-settings/resources/js/data/common/hooks.js index fd6ba3157..9e7116b6a 100644 --- a/modules/ppcp-settings/resources/js/data/common/hooks.js +++ b/modules/ppcp-settings/resources/js/data/common/hooks.js @@ -41,8 +41,6 @@ const useHooks = () => { const { useTransient, usePersistent, dispatch, select } = useStoreData(); const { persist, - sandboxOnboardingUrl, - productionOnboardingUrl, authenticateWithCredentials, authenticateWithOAuth, startWebhookSimulation, @@ -55,7 +53,6 @@ const useHooks = () => { useTransient( 'activeHighlight' ); // Persistent accessors. - const [ isSandboxMode, setSandboxMode ] = usePersistent( 'useSandbox' ); const [ isManualConnectionMode, setManualConnectionMode ] = usePersistent( 'useManualConnection' ); @@ -75,16 +72,10 @@ const useHooks = () => { setActiveModal, activeHighlight, setActiveHighlight, - isSandboxMode, - setSandboxMode: ( state ) => { - return savePersistent( setSandboxMode, state ); - }, isManualConnectionMode, setManualConnectionMode: ( state ) => { return savePersistent( setManualConnectionMode, state ); }, - sandboxOnboardingUrl, - productionOnboardingUrl, authenticateWithCredentials, authenticateWithOAuth, wooSettings, @@ -109,13 +100,23 @@ export const useStore = () => { }; export const useSandbox = () => { - const { isSandboxMode, setSandboxMode, sandboxOnboardingUrl } = useHooks(); + const { dispatch, usePersistent } = useStoreData(); + const [ isSandboxMode, setSandboxMode ] = usePersistent( 'useSandbox' ); + const { sandboxOnboardingUrl, persist } = dispatch; - return { isSandboxMode, setSandboxMode, sandboxOnboardingUrl }; + return { + isSandboxMode, + setSandboxMode: ( state ) => { + setSandboxMode( state ); + return persist(); + }, + sandboxOnboardingUrl, + }; }; export const useProduction = () => { - const { productionOnboardingUrl } = useHooks(); + const { dispatch } = useStoreData(); + const { productionOnboardingUrl } = dispatch; return { productionOnboardingUrl }; };