Add new “reset” flag to the JS-logic

This commit is contained in:
Philipp Stracker 2025-02-12 16:32:52 +01:00
parent 921546953e
commit da80defa93
No known key found for this signature in database
2 changed files with 7 additions and 3 deletions

View file

@ -19,9 +19,9 @@ const DisconnectButton = () => {
}, [] ); }, [] );
const handleConfirm = useCallback( async () => { const handleConfirm = useCallback( async () => {
await disconnectMerchant(); await disconnectMerchant( resetFlag );
window.location.reload(); window.location.reload();
}, [ disconnectMerchant ] ); }, [ disconnectMerchant, resetFlag ] );
const confirmationTitle = __( const confirmationTitle = __(
'Disconnect from PayPal?', 'Disconnect from PayPal?',

View file

@ -153,13 +153,17 @@ export function authenticateWithOAuth( sharedId, authCode, useSandbox ) {
/** /**
* Side effect. Checks webhook simulation. * Side effect. Checks webhook simulation.
* *
* @param {boolean} fullReset When true, all plugin settings are reset to initial values.
* @return {Function} The thunk function. * @return {Function} The thunk function.
*/ */
export function disconnectMerchant() { export function disconnectMerchant( fullReset = false ) {
return async () => { return async () => {
return await apiFetch( { return await apiFetch( {
path: REST_DISCONNECT_MERCHANT_PATH, path: REST_DISCONNECT_MERCHANT_PATH,
method: 'POST', method: 'POST',
data: {
reset: fullReset,
},
} ); } );
}; };
} }