woocommerce-paypal-payments/modules/ppcp-settings/resources/js/data/onboarding/resolvers.js
Philipp Stracker c5e8a85acf
♻️ Rename store selectors
Selectors now only differentiate between persistent or transient data
2024-10-23 18:11:09 +02:00

24 lines
635 B
JavaScript

import { dispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { apiFetch } from '@wordpress/data-controls';
import { NAMESPACE } from '../constants';
import { updateOnboardingDetails } from './actions';
/**
* Retrieve settings from the site's REST API.
*/
export function* getPersistentData() {
const path = `${ NAMESPACE }/onboarding`;
try {
const result = yield apiFetch( { path } );
yield updateOnboardingDetails( result );
} catch ( e ) {
yield dispatch( 'core/notices' ).createErrorNotice(
__(
'Error retrieving onboarding details.',
'woocommerce-paypal-payments'
)
);
}
}