2024-10-22 15:15:55 +02:00
|
|
|
import { dispatch } from '@wordpress/data';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { apiFetch } from '@wordpress/data-controls';
|
|
|
|
import { NAMESPACE } from '../constants';
|
2024-10-28 18:57:39 +01:00
|
|
|
import { setIsReady, setOnboardingDetails } from './actions';
|
2024-10-22 15:15:55 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve settings from the site's REST API.
|
|
|
|
*/
|
2024-10-23 18:11:09 +02:00
|
|
|
export function* getPersistentData() {
|
2024-10-22 15:15:55 +02:00
|
|
|
const path = `${ NAMESPACE }/onboarding`;
|
|
|
|
|
|
|
|
try {
|
|
|
|
const result = yield apiFetch( { path } );
|
2024-10-23 18:12:17 +02:00
|
|
|
yield setOnboardingDetails( result );
|
2024-10-28 18:57:39 +01:00
|
|
|
yield setIsReady( true );
|
2024-10-22 15:15:55 +02:00
|
|
|
} catch ( e ) {
|
|
|
|
yield dispatch( 'core/notices' ).createErrorNotice(
|
|
|
|
__(
|
|
|
|
'Error retrieving onboarding details.',
|
|
|
|
'woocommerce-paypal-payments'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|