♻️ Move sandbox & manual-connect to common store

This commit is contained in:
Philipp Stracker 2024-11-21 16:16:20 +01:00
parent 2b2b24e434
commit faff0baa43
No known key found for this signature in database
10 changed files with 169 additions and 146 deletions

View file

@ -9,7 +9,7 @@
import apiFetch from '@wordpress/api-fetch';
import { REST_PERSIST_PATH } from './constants';
import { REST_PERSIST_PATH, REST_MANUAL_CONNECTION_PATH } from './constants';
import ACTION_TYPES from './action-types';
export const controls = {
@ -24,4 +24,31 @@ export const controls = {
console.error( 'Error saving data.', error );
}
},
async [ ACTION_TYPES.DO_MANUAL_CONNECTION ]( {
clientId,
clientSecret,
useSandbox,
} ) {
let result = null;
try {
result = await apiFetch( {
path: REST_MANUAL_CONNECTION_PATH,
method: 'POST',
data: {
clientId,
clientSecret,
useSandbox,
},
} );
} catch ( e ) {
result = {
success: false,
error: e,
};
}
return result;
},
};