mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
♻️ Minor code improvement
This commit is contained in:
parent
2a28f38491
commit
88f2ed9185
1 changed files with 11 additions and 13 deletions
|
@ -7,7 +7,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
||||||
import SettingsToggleBlock from '../../../ReusableComponents/SettingsToggleBlock';
|
import SettingsToggleBlock from '../../../ReusableComponents/SettingsToggleBlock';
|
||||||
import Separator from '../../../ReusableComponents/Separator';
|
import Separator from '../../../ReusableComponents/Separator';
|
||||||
import DataStoreControl from '../../../ReusableComponents/DataStoreControl';
|
import DataStoreControl from '../../../ReusableComponents/DataStoreControl';
|
||||||
import { OnboardingHooks, CommonHooks } from '../../../../data';
|
import { CommonHooks } from '../../../../data';
|
||||||
|
|
||||||
const AdvancedOptionsForm = ( { setCompleted } ) => {
|
const AdvancedOptionsForm = ( { setCompleted } ) => {
|
||||||
const { isBusy } = CommonHooks.useBusyState();
|
const { isBusy } = CommonHooks.useBusyState();
|
||||||
|
@ -61,17 +61,9 @@ const AdvancedOptionsForm = ( { setCompleted } ) => {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleServerError = ( res ) => {
|
const handleServerError = ( res, genericMessage ) => {
|
||||||
if ( res.message ) {
|
console.error( 'Connection error', res );
|
||||||
createErrorNotice( res.message );
|
createErrorNotice( res?.message ?? genericMessage );
|
||||||
} else {
|
|
||||||
createErrorNotice(
|
|
||||||
__(
|
|
||||||
'Could not connect to PayPal. Please make sure your Client ID and Secret Key are correct.',
|
|
||||||
'woocommerce-paypal-payments'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleServerSuccess = () => {
|
const handleServerSuccess = () => {
|
||||||
|
@ -107,7 +99,13 @@ const AdvancedOptionsForm = ( { setCompleted } ) => {
|
||||||
if ( res.success ) {
|
if ( res.success ) {
|
||||||
handleServerSuccess();
|
handleServerSuccess();
|
||||||
} else {
|
} else {
|
||||||
handleServerError( res );
|
handleServerError(
|
||||||
|
res,
|
||||||
|
__(
|
||||||
|
'Could not connect to PayPal. Please make sure your Client ID and Secret Key are correct.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue