From 7b12e65ca8fa5af4bfa04d7f033b45ff88291aff Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Wed, 23 Oct 2024 18:17:08 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Integrate=20new=20Redux=20props=20t?= =?UTF-8?q?o=20the=20welcome=20screen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new fields are managed by a debounced field hook that instantly stores the field values in a local state and propagates the new value to the Redux store after a debouncing-delay --- .../Screens/Onboarding/StepWelcome.js | 19 +++++++ .../ppcp-settings/resources/js/utils/hooks.js | 51 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 modules/ppcp-settings/resources/js/utils/hooks.js diff --git a/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/StepWelcome.js b/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/StepWelcome.js index 095136c56..914729016 100644 --- a/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/StepWelcome.js +++ b/modules/ppcp-settings/resources/js/Components/Screens/Onboarding/StepWelcome.js @@ -5,6 +5,7 @@ import PaymentMethodIcons from '../../ReusableComponents/PaymentMethodIcons'; import SettingsToggleBlock from '../../ReusableComponents/SettingsToggleBlock'; import Separator from '../../ReusableComponents/Separator'; import { useOnboardingDetails } from '../../../data'; +import { useDebounceField } from '../../../utils/hooks'; const StepWelcome = () => { return ( @@ -78,8 +79,22 @@ const WelcomeForm = () => { setSandboxMode, isManualConnectionMode, setManualConnectionMode, + clientId, + setClientId, + clientSecret, + setClientSecret, } = useOnboardingDetails(); + const [ currentClientId, updateClientId ] = useDebounceField( + setClientId, + clientId + ); + + const [ currentClientSecret, updateClientSecret ] = useDebounceField( + setClientSecret, + clientSecret + ); + const advancedUsersDescription = sprintf( // translators: %s: Link to PayPal REST application guide __( @@ -122,12 +137,16 @@ const WelcomeForm = () => { 'Sandbox Client ID', 'woocommerce-paypal-payments' ) } + value={ currentClientId } + onChange={ updateClientId } >