forked from woocommerce/google-listings-and-ads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect-google-account-card.js
73 lines (69 loc) · 2.16 KB
/
connect-google-account-card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
import { glaData } from '.~/constants';
import AccountCard, { APPEARANCE } from '.~/components/account-card';
import AppButton from '.~/components/app-button';
import readMoreLink from './read-more-link';
import useGoogleConnectFlow from './use-google-connect-flow';
/**
* @param {Object} props React props
* @param {boolean} props.disabled
* @fires gla_google_account_connect_button_click with `{ action: 'authorization', context: 'reconnect' }`
* @fires gla_google_account_connect_button_click with `{ action: 'authorization', context: 'setup-mc' }`
* @fires gla_documentation_link_click with `{ context: 'setup-mc-accounts', link_id: 'required-google-permissions', href: 'https://woo.com/document/google-listings-and-ads/#required-google-permissions' }`
*/
const ConnectGoogleAccountCard = ( { disabled } ) => {
const pageName = glaData.mcSetupComplete ? 'reconnect' : 'setup-mc';
const [ handleConnect, { loading, data } ] =
useGoogleConnectFlow( pageName );
return (
<AccountCard
appearance={ APPEARANCE.GOOGLE }
disabled={ disabled }
alignIcon="top"
description={
<>
{ __(
'Required to sync with Google Merchant Center and Google Ads.',
'google-listings-and-ads'
) }
<p>
<em>
{ createInterpolateElement(
__(
'You will be prompted to give WooCommerce access to your Google account. Please check all the checkboxes to give WooCommerce all required permissions. <link>Read more</link>',
'google-listings-and-ads'
),
{
link: readMoreLink,
}
) }
</em>
</p>
</>
}
alignIndicator="top"
indicator={
<AppButton
isSecondary
disabled={ disabled }
loading={ loading || data }
eventName="gla_google_account_connect_button_click"
eventProps={ {
context: pageName,
action: 'authorization',
} }
text={ __( 'Connect', 'google-listings-and-ads' ) }
onClick={ handleConnect }
/>
}
/>
);
};
export default ConnectGoogleAccountCard;