From 396523427ee43060d485d7b54a081029bf2421db Mon Sep 17 00:00:00 2001 From: asvinb Date: Mon, 7 Oct 2024 17:37:12 +0400 Subject: [PATCH] Check for non connected state. --- .../connect-mc/connect-mc.js | 20 +++++++++++++------ .../connected-google-combo-account-card.js | 1 - 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/js/src/components/google-combo-account-card/connect-mc/connect-mc.js b/js/src/components/google-combo-account-card/connect-mc/connect-mc.js index 607b37dd5e..8a75264d02 100644 --- a/js/src/components/google-combo-account-card/connect-mc/connect-mc.js +++ b/js/src/components/google-combo-account-card/connect-mc/connect-mc.js @@ -16,6 +16,7 @@ import useGoogleMCAccount from '.~/hooks/useGoogleMCAccount'; import ConnectAccountCard from '../connect-account-card'; import ConnectMCBody from './connect-mc-body'; import ConnectMCFooter from './connect-mc-footer'; +import SpinnerCard from '.~/components/spinner-card'; /** * Clicking on the "Switch account" button to select a different Google Merchant Center account to connect. @@ -25,7 +26,7 @@ import ConnectMCFooter from './connect-mc-footer'; */ const ConnectMC = () => { - const { googleMCAccount } = useGoogleMCAccount(); + const { googleMCAccount, hasFinishedResolution } = useGoogleMCAccount(); const [ value, setValue ] = useState(); const [ handleConnectMC, resultConnectMC ] = useConnectMCAccount( value ); const [ handleCreateAccount, resultCreateAccount ] = useCreateMCAccount(); @@ -34,11 +35,12 @@ const ConnectMC = () => { // The `link_ads` step will be resolved when the Ads account is connected // since these can be connected in any order. const isConnected = + googleMCAccount?.id || googleMCAccount?.status === 'connected' || ( googleMCAccount?.status === 'incomplete' && googleMCAccount?.step === 'link_ads' ); - if ( resultConnectMC.response?.status === 409 ) { + if ( ! isConnected && resultConnectMC.response?.status === 409 ) { return ( { } if ( - resultConnectMC.response?.status === 403 || - resultCreateAccount.response?.status === 403 + ! isConnected && + ( resultConnectMC.response?.status === 403 || + resultCreateAccount.response?.status === 403 ) ) { return ( { } if ( - resultCreateAccount.loading || - resultCreateAccount.response?.status === 503 + ! isConnected && + ( resultCreateAccount.loading || + resultCreateAccount.response?.status === 503 ) ) { return ( { ); } + if ( ! hasFinishedResolution ) { + return ; + } + return (