mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
💄 Display loading spinners while authenticating
This commit is contained in:
parent
1f3a18a690
commit
2c4df18728
1 changed files with 19 additions and 10 deletions
|
@ -173,6 +173,7 @@ const useConnectionBase = () => {
|
|||
const { createSuccessNotice, createErrorNotice } =
|
||||
useDispatch( noticesStore );
|
||||
const { verifyLoginStatus } = CommonHooks.useMerchantInfo();
|
||||
const { withActivity } = CommonHooks.useBusyState();
|
||||
|
||||
return {
|
||||
handleFailed: ( res, genericMessage ) => {
|
||||
|
@ -180,18 +181,26 @@ const useConnectionBase = () => {
|
|||
createErrorNotice( res?.message ?? genericMessage );
|
||||
},
|
||||
handleCompleted: async () => {
|
||||
try {
|
||||
const loginSuccessful = await verifyLoginStatus();
|
||||
await withActivity(
|
||||
'auth',
|
||||
'Verifying Authentication',
|
||||
async () => {
|
||||
try {
|
||||
const loginSuccessful = await verifyLoginStatus();
|
||||
|
||||
if ( loginSuccessful ) {
|
||||
createSuccessNotice( MESSAGES.CONNECTED );
|
||||
await setCompleted( true );
|
||||
} else {
|
||||
createErrorNotice( MESSAGES.LOGIN_FAILED );
|
||||
if ( loginSuccessful ) {
|
||||
createSuccessNotice( MESSAGES.CONNECTED );
|
||||
await setCompleted( true );
|
||||
} else {
|
||||
createErrorNotice( MESSAGES.LOGIN_FAILED );
|
||||
}
|
||||
} catch ( error ) {
|
||||
createErrorNotice(
|
||||
error.message ?? MESSAGES.LOGIN_FAILED
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch ( error ) {
|
||||
createErrorNotice( error.message ?? MESSAGES.LOGIN_FAILED );
|
||||
}
|
||||
);
|
||||
},
|
||||
createErrorNotice,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue