mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
♻️ Refactor onboarding state management
This commit is contained in:
parent
81f45692f4
commit
fee9a016c6
6 changed files with 100 additions and 148 deletions
|
@ -1,19 +1,20 @@
|
|||
import { dispatch } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { apiFetch } from '@wordpress/data-controls';
|
||||
|
||||
import { NAMESPACE } from '../constants';
|
||||
import { REST_HYDRATE_PATH } from './constants';
|
||||
import { setIsReady, setOnboardingDetails } from './actions';
|
||||
import { setIsReady, hydrateOnboardingDetails } from './actions';
|
||||
|
||||
/**
|
||||
* Retrieve settings from the site's REST API.
|
||||
*/
|
||||
export function* getPersistentData() {
|
||||
export function* onboardingPersistentData() {
|
||||
const path = `${ NAMESPACE }/${ REST_HYDRATE_PATH }`;
|
||||
|
||||
try {
|
||||
const result = yield apiFetch( { path } );
|
||||
yield setOnboardingDetails( result );
|
||||
yield hydrateOnboardingDetails( result );
|
||||
yield setIsReady( true );
|
||||
} catch ( e ) {
|
||||
yield dispatch( 'core/notices' ).createErrorNotice(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue