🐛 Fix the manual connection confirmation logic

This commit is contained in:
Philipp Stracker 2025-02-12 13:25:11 +01:00
parent 67522b9557
commit 93f517e50f
No known key found for this signature in database

View file

@ -145,18 +145,27 @@ export const useWebhooks = () => {
export const useMerchantInfo = () => {
const { isReady, merchant, features } = useHooks();
const { refreshMerchantData } = useDispatch( STORE_NAME );
const { refreshMerchantData, setMerchant } = useDispatch( STORE_NAME );
const verifyLoginStatus = useCallback( async () => {
const result = await refreshMerchantData();
if ( ! result.success ) {
if ( ! result.success || ! result.merchant ) {
throw new Error( result?.message || result?.error?.message );
}
const newMerchant = result.merchant;
// Verify if the server state is "connected" and we have a merchant ID.
return merchant?.isConnected && merchant?.id;
}, [ refreshMerchantData, merchant ] );
if ( newMerchant?.isConnected && newMerchant?.id ) {
// Update the verified merchant details in Redux.
setMerchant( newMerchant );
return true;
}
return false;
}, [ refreshMerchantData, setMerchant ] );
return {
isReady,