🚸 Enhance manual connection UX and validation

This commit is contained in:
Philipp Stracker 2024-11-07 18:34:30 +01:00
parent e0fbaa7ad7
commit a91434951e
No known key found for this signature in database
2 changed files with 80 additions and 17 deletions

View file

@ -172,10 +172,10 @@ export const setProducts = ( products ) => {
* Attempts to establish a connection using client ID and secret via the server-side
* connection endpoint.
*
* @return {boolean} True if the connection was successful, false otherwise.
* @return {Object} The server response object
*/
export function* connectViaIdAndSecret() {
let error = null;
let result = null;
try {
const path = `${ NAMESPACE }/connect_manual`;
@ -184,7 +184,7 @@ export function* connectViaIdAndSecret() {
yield setManualConnectionIsBusy( true );
const result = yield apiFetch( {
result = yield apiFetch( {
path,
method: 'POST',
data: {
@ -193,16 +193,16 @@ export function* connectViaIdAndSecret() {
useSandbox,
},
} );
console.log( 'Manual connection result:', result );
} catch ( e ) {
error = e;
console.error( 'Manual connection failed:', e );
result = {
success: false,
error: e,
};
} finally {
yield setManualConnectionIsBusy( false );
}
return error === null;
return result;
}
/**