Skip to content

Commit

Permalink
Stop requesting to Reconnect to Square
Browse files Browse the repository at this point in the history
  • Loading branch information
faisal-alvi committed Sep 3, 2024
1 parent 0dedd98 commit af00e3b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/new-user-experience/settings/settings-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const SettingsApp = () => {

const [ initialState, setInitialState ] = useState( false );
const [ isFormDirty, setIsFormDirty ] = useState( false );
const [ envUpdated, setEnvUpdated ] = useState( false );

const {
enable_sandbox = 'no',
Expand All @@ -51,6 +50,13 @@ export const SettingsApp = () => {
return;
}

// Store the initially saved environment in local storage.
if ( enable_sandbox === 'yes' ) {
localStorage.setItem( 'wc_square_env', 'sandbox' );
} else {
localStorage.setItem( 'wc_square_env', 'production' );
}

setInitialState( settings );
}, [ squareSettingsLoaded ] );

Expand Down Expand Up @@ -102,7 +108,6 @@ export const SettingsApp = () => {
required
value={ enable_sandbox }
onChange={ ( value ) => {
setEnvUpdated( true );
setSquareSettingData( { enable_sandbox: value } );
} }
options={ [
Expand Down Expand Up @@ -140,14 +145,17 @@ export const SettingsApp = () => {
variant="button-primary"
className="button-primary"
href={
is_connected && ! envUpdated
is_connected &&
localStorage.getItem( 'wc_square_env' ) ===
'production'
? disconnection_url
: connection_url
}
isBusy={ isSquareSettingsSaving }
disabled={ ! wcSquareSettings.depsCheck }
>
{ is_connected && ! envUpdated
{ is_connected &&
localStorage.getItem( 'wc_square_env' ) === 'production'
? __(
'Disconnect from Square',
'woocommerce-square'
Expand Down

0 comments on commit af00e3b

Please sign in to comment.