mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
♻️ Rename callback methods, minor
This commit is contained in:
parent
4e9d588058
commit
0502c25ddf
1 changed files with 8 additions and 8 deletions
|
@ -65,11 +65,11 @@ const useConnectionBase = () => {
|
|||
useDispatch( noticesStore );
|
||||
|
||||
return {
|
||||
handleError: ( res, genericMessage ) => {
|
||||
handleFailed: ( res, genericMessage ) => {
|
||||
console.error( 'Connection error', res );
|
||||
createErrorNotice( res?.message ?? genericMessage );
|
||||
},
|
||||
handleSuccess: async () => {
|
||||
handleCompleted: async () => {
|
||||
createSuccessNotice( MESSAGES.CONNECTED );
|
||||
|
||||
// TODO: Contact the plugin to confirm onboarding is completed.
|
||||
|
@ -80,14 +80,14 @@ const useConnectionBase = () => {
|
|||
};
|
||||
|
||||
const useConnectionAttempt = ( connectFn, errorMessage ) => {
|
||||
const { handleError, createErrorNotice, handleSuccess } =
|
||||
const { handleFailed, createErrorNotice, handleCompleted } =
|
||||
useConnectionBase();
|
||||
|
||||
return async ( ...args ) => {
|
||||
const res = await connectFn( ...args );
|
||||
|
||||
if ( ! res.success || ! res.data ) {
|
||||
handleError( res, errorMessage );
|
||||
handleFailed( res, errorMessage );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ const useConnectionAttempt = ( connectFn, errorMessage ) => {
|
|||
);
|
||||
|
||||
if ( popupClosed ) {
|
||||
await handleSuccess();
|
||||
await handleCompleted();
|
||||
}
|
||||
|
||||
return popupClosed;
|
||||
|
@ -149,7 +149,7 @@ export const useProductionConnection = () => {
|
|||
};
|
||||
|
||||
export const useManualConnection = () => {
|
||||
const { handleError, handleSuccess, createErrorNotice } =
|
||||
const { handleFailed, handleCompleted, createErrorNotice } =
|
||||
useConnectionBase();
|
||||
const { withActivity } = CommonHooks.useBusyState();
|
||||
const {
|
||||
|
@ -179,9 +179,9 @@ export const useManualConnection = () => {
|
|||
const res = await connectViaIdAndSecret();
|
||||
|
||||
if ( res.success ) {
|
||||
await handleSuccess();
|
||||
await handleCompleted();
|
||||
} else {
|
||||
handleError( res, MESSAGES.MANUAL_ERROR );
|
||||
handleFailed( res, MESSAGES.MANUAL_ERROR );
|
||||
}
|
||||
|
||||
return res.success;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue