From 3813191f0df2064e200bfcfa3314d412dd66db74 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Thu, 9 Jan 2025 15:25:46 +0400 Subject: [PATCH] Create the single component for connection details --- .../Blocks/ConnectionDetails.js | 41 ++++ .../TabSettingsElements/Blocks/Sandbox.js | 202 ------------------ 2 files changed, 41 insertions(+), 202 deletions(-) create mode 100644 modules/ppcp-settings/resources/js/Components/Screens/Overview/TabSettingsElements/Blocks/ConnectionDetails.js delete mode 100644 modules/ppcp-settings/resources/js/Components/Screens/Overview/TabSettingsElements/Blocks/Sandbox.js diff --git a/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabSettingsElements/Blocks/ConnectionDetails.js b/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabSettingsElements/Blocks/ConnectionDetails.js new file mode 100644 index 000000000..b1b5fcb4d --- /dev/null +++ b/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabSettingsElements/Blocks/ConnectionDetails.js @@ -0,0 +1,41 @@ +import { __, sprintf } from '@wordpress/i18n'; +import { Button } from '@wordpress/components'; +import { + AccordionSettingsBlock, + RadioSettingsBlock, + InputSettingsBlock, +} from '../../../../ReusableComponents/SettingsBlocks'; +import { + sandboxData, + productionData, +} from '../../../../../data/settings/connection-details-data'; + +const ConnectionDetails = ( { settings, updateFormValue } ) => { + const isSandbox = settings.sandboxConnected; + + const modeConfig = isSandbox + ? productionData( { settings, updateFormValue } ) + : sandboxData( { settings, updateFormValue } ); + + const modeKey = isSandbox ? 'productionMode' : 'sandboxMode'; + + return ( + + + + ); +}; + +export default ConnectionDetails; diff --git a/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabSettingsElements/Blocks/Sandbox.js b/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabSettingsElements/Blocks/Sandbox.js deleted file mode 100644 index 93a4a7d0d..000000000 --- a/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabSettingsElements/Blocks/Sandbox.js +++ /dev/null @@ -1,202 +0,0 @@ -import { __, sprintf } from '@wordpress/i18n'; -import { Button } from '@wordpress/components'; -import { - AccordionSettingsBlock, - ButtonSettingsBlock, - RadioSettingsBlock, - ToggleSettingsBlock, - InputSettingsBlock, -} from '../../../../ReusableComponents/SettingsBlocks'; -import TitleBadge, { - TITLE_BADGE_POSITIVE, -} from '../../../../ReusableComponents/TitleBadge'; -import ConnectionInfo, { - connectionStatusDataDefault, -} from '../../../../ReusableComponents/ConnectionInfo'; - -const Sandbox = ( { settings, updateFormValue } ) => { - const className = settings.sandboxConnected - ? 'ppcp-r-settings-block--sandbox-connected' - : 'ppcp-r-settings-block--sandbox-disconnected'; - - return ( - - { settings.sandboxConnected && ( - - } - > -
- - - -
-
- ) } - { ! settings.sandboxConnected && ( - - updateFormValue( - 'sandboxConnected', - true - ) - } - > - { __( - 'Connect Sandbox Account', - 'woocommerce-paypal-payments' - ) } - - ), - }, - { - id: 'manual_connect', - value: 'manual_connect', - label: __( - 'Manual Connect', - 'woocommerce-paypal-payments' - ), - description: sprintf( - __( - 'For advanced users: Connect a custom PayPal REST app for full control over your integration. For more information on creating a PayPal REST application, click here.', - 'woocommerce-paypal-payments' - ), - '#' - ), - additionalContent: ( - <> - - - - - ), - }, - ] } - actionProps={ { - name: 'paypal_connect_sandbox', - key: 'sandboxMode', - currentValue: settings.sandboxMode, - callback: updateFormValue, - } } - /> - ) } -
- ); -}; - -export default Sandbox;