From 3c19aa94f2786aedf45cc52f4d02b47f22082bdc Mon Sep 17 00:00:00 2001 From: asvinb Date: Thu, 31 Oct 2024 20:38:57 +0400 Subject: [PATCH] Save WIP. --- .../claim-ads-account/claim-ads-account.js | 4 ---- .../google-combo-account-card/connect-ads/connect-ads.js | 1 + .../connected-accounts-actions.js | 6 ++++-- .../connected-google-combo-account-card.js | 8 +++++--- js/src/hooks/useAutoCreateAdsMCAccounts.js | 1 + 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/js/src/components/google-combo-account-card/claim-ads-account/claim-ads-account.js b/js/src/components/google-combo-account-card/claim-ads-account/claim-ads-account.js index c06d7b4587..50d5fb86e5 100644 --- a/js/src/components/google-combo-account-card/claim-ads-account/claim-ads-account.js +++ b/js/src/components/google-combo-account-card/claim-ads-account/claim-ads-account.js @@ -60,10 +60,6 @@ const ClaimAdsAccount = () => { setUpdating( true ); }; - if ( ! shouldClaimGoogleAdsAccount ) { - return null; - } - return (
diff --git a/js/src/components/google-combo-account-card/connect-ads/connect-ads.js b/js/src/components/google-combo-account-card/connect-ads/connect-ads.js index f8ce613403..e72ff1b7f6 100644 --- a/js/src/components/google-combo-account-card/connect-ads/connect-ads.js +++ b/js/src/components/google-combo-account-card/connect-ads/connect-ads.js @@ -57,6 +57,7 @@ const ConnectAds = () => { await upsertAdsAccount(); }; + console.log( accounts, googleAdsAccount, isConnected ); useEffect( () => { if ( isConnected ) { setValue( googleAdsAccount.id ); diff --git a/js/src/components/google-combo-account-card/connected-accounts-actions.js b/js/src/components/google-combo-account-card/connected-accounts-actions.js index 89ba883998..f8023c796e 100644 --- a/js/src/components/google-combo-account-card/connected-accounts-actions.js +++ b/js/src/components/google-combo-account-card/connected-accounts-actions.js @@ -12,14 +12,16 @@ import useGoogleAdsAccountReady from '.~/hooks/useGoogleAdsAccountReady'; /** * Renders the actionable components for connected accounts. + * @param {Object} props Component props. + * @param {boolean} props.claimGoogleAdsAccount Whether the user should claim the Google Ads account. * @return {JSX.Element} Connected accounts actions. */ -const ConnectedAccountsActions = () => { +const ConnectedAccountsActions = ( { claimGoogleAdsAccount } ) => { const isReady = useGoogleAdsAccountReady(); return (
- + { claimGoogleAdsAccount && } { isReady && ( { ); const hasExistingGoogleAdsAccounts = existingGoogleAdsAccounts?.length > 0; const showConnectAds = - ( editMode && hasExistingGoogleAdsAccounts ) || - ( ! isConnected && hasExistingGoogleAdsAccounts ) || + ( ( editMode && hasExistingGoogleAdsAccounts ) || + ( ! isConnected && hasExistingGoogleAdsAccounts ) ) && ! shouldClaimGoogleAdsAccount; return ( @@ -55,7 +55,9 @@ const ConnectedGoogleComboAccountCard = () => { } > - + { showConnectAds && } diff --git a/js/src/hooks/useAutoCreateAdsMCAccounts.js b/js/src/hooks/useAutoCreateAdsMCAccounts.js index e295f263bb..3cc0fb3296 100644 --- a/js/src/hooks/useAutoCreateAdsMCAccounts.js +++ b/js/src/hooks/useAutoCreateAdsMCAccounts.js @@ -28,6 +28,7 @@ const useShouldCreateAdsAccount = () => { hasFinishedResolution: hasResolvedExistingAccounts, existingAccounts: accounts, } = useExistingGoogleAdsAccounts(); + console.log( accounts, hasConnection ); // Return null if the account hasn't been resolved or the existing accounts haven't been resolved if ( ! hasResolvedAccount || ! hasResolvedExistingAccounts ) {