From 88f2ed9185fd8f8f9a035e54572055807c8a100a Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Thu, 21 Nov 2024 19:08:50 +0100
Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Minor=20code=20improvement?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Components/AdvancedOptionsForm.js | 24 +++++++++----------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Components/AdvancedOptionsForm.js b/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Components/AdvancedOptionsForm.js
index 3702a6e14..79724a533 100644
--- a/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Components/AdvancedOptionsForm.js
+++ b/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/Components/AdvancedOptionsForm.js
@@ -7,7 +7,7 @@ import { store as noticesStore } from '@wordpress/notices';
import SettingsToggleBlock from '../../../ReusableComponents/SettingsToggleBlock';
import Separator from '../../../ReusableComponents/Separator';
import DataStoreControl from '../../../ReusableComponents/DataStoreControl';
-import { OnboardingHooks, CommonHooks } from '../../../../data';
+import { CommonHooks } from '../../../../data';
const AdvancedOptionsForm = ( { setCompleted } ) => {
const { isBusy } = CommonHooks.useBusyState();
@@ -61,17 +61,9 @@ const AdvancedOptionsForm = ( { setCompleted } ) => {
return true;
};
- const handleServerError = ( res ) => {
- if ( res.message ) {
- createErrorNotice( res.message );
- } else {
- createErrorNotice(
- __(
- 'Could not connect to PayPal. Please make sure your Client ID and Secret Key are correct.',
- 'woocommerce-paypal-payments'
- )
- );
- }
+ const handleServerError = ( res, genericMessage ) => {
+ console.error( 'Connection error', res );
+ createErrorNotice( res?.message ?? genericMessage );
};
const handleServerSuccess = () => {
@@ -107,7 +99,13 @@ const AdvancedOptionsForm = ( { setCompleted } ) => {
if ( res.success ) {
handleServerSuccess();
} else {
- handleServerError( res );
+ handleServerError(
+ res,
+ __(
+ 'Could not connect to PayPal. Please make sure your Client ID and Secret Key are correct.',
+ 'woocommerce-paypal-payments'
+ )
+ );
}
};