-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate accounts onboarding: Merge the store address setting in Step 3 into Step 1 and remove Step 3 along with the phone verification #2653
Changes from 7 commits
6817cc6
26ec20d
bd6c4fe
8dc6740
55b95fb
e0b7df9
850944e
4ca1f95
5b81e15
123925d
b3a9ff9
ac7918c
fe7d565
41f5513
babf4d6
1f18092
bfcc39b
d2b2a38
a49f43f
1e0ed3b
f76a955
a9f5530
a98a698
7e87761
852dfde
ec43e8f
4905228
c024b95
5098fe8
c1d0c25
49c26f0
afdb054
d772944
921cd2c
30ac53a
53bab84
f9ea219
8b141d1
428738c
5c129a4
d4c0daa
059fd99
49f8f82
1372d3e
e49ca66
299fad7
6ad177b
c0d25ec
eeb596b
a1360bf
e55f65e
ddbb900
866e7b6
7d49d69
6fff925
c77748c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import StoreAddressCard from '.~/components/contact-information/store-address-card'; | ||
import useStoreAddressSynced from '.~/hooks/useStoreAddressSynced'; | ||
|
||
/* | ||
* Renders StoreAddressCard to sync the store address if we have a connected MC account and the address needs to be synced. | ||
* If there's no connected account or the store address has been synced, it will return null. | ||
*/ | ||
const SyncStoreAddress = () => { | ||
const storeAddressSynced = useStoreAddressSynced(); | ||
|
||
if ( storeAddressSynced === null || storeAddressSynced ) { | ||
return null; | ||
} | ||
|
||
return <StoreAddressCard />; | ||
}; | ||
|
||
export default SyncStoreAddress; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import useGoogleMCAccount from '.~/hooks/useGoogleMCAccount'; | ||
import { STORE_KEY } from '.~/data/constants'; | ||
|
||
/** | ||
* Checks if the store address is synchronized with the Merchant Center (GMC) account address. | ||
* | ||
* @return {boolean|null} Returns `true` if the store address matches the GMC account address, otherwise, returns `false`. If the MC account is not connected or if the state is not yet determined, returns `null`. | ||
*/ | ||
export default function useStoreAddressSynced() { | ||
const { isReady } = useGoogleMCAccount(); | ||
|
||
return useSelect( | ||
( select ) => { | ||
if ( ! isReady ) { | ||
return null; | ||
} | ||
|
||
const { getGoogleMCContactInformation } = select( STORE_KEY ); | ||
const contact = getGoogleMCContactInformation(); | ||
|
||
if ( ! contact ) { | ||
return null; | ||
} | ||
|
||
const { | ||
is_mc_address_different: isMCAddressDifferent, | ||
wc_address_errors: missingRequiredFields, | ||
} = contact; | ||
|
||
return ( | ||
! Boolean( isMCAddressDifferent ) && | ||
! missingRequiredFields.length | ||
); | ||
}, | ||
[ isReady ] | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import Faqs from './faqs'; | |
import './index.scss'; | ||
import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount'; | ||
import useGoogleAdsAccountReady from '.~/hooks/useGoogleAdsAccountReady'; | ||
import useStoreAddressSynced from '.~/hooks/useStoreAddressSynced'; | ||
|
||
/** | ||
* Renders the disclaimer of Comparison Shopping Service (CSS). | ||
|
@@ -89,6 +90,7 @@ const SetupAccounts = ( props ) => { | |
isReady: isGoogleMCReady, | ||
} = useGoogleMCAccount(); | ||
const { hasFinishedResolution } = useGoogleAdsAccount(); | ||
const storeAddressSynced = useStoreAddressSynced(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This hook cannot be used here until after the MC account is connected. Otherwise it will send an API request to Either we need to incorporate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @joemcgill . Completely missed that 🤦 . I've updated the |
||
const isGoogleAdsReady = useGoogleAdsAccountReady(); | ||
|
||
/** | ||
|
@@ -115,7 +117,8 @@ const SetupAccounts = ( props ) => { | |
const isContinueButtonDisabled = ! ( | ||
hasFinishedResolution && | ||
isGoogleAdsReady && | ||
isGoogleMCReady | ||
isGoogleMCReady && | ||
storeAddressSynced | ||
); | ||
|
||
return ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this refetch is unnecessary, because
updateGoogleMCContactInformation()
returns the new data and updates the data store.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍