-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrequest-full-access-google-account-card.js
80 lines (76 loc) · 2.51 KB
/
request-full-access-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
74
75
76
77
78
79
80
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
import { glaData } from '~/constants';
import AppButton from '~/components/app-button';
import AccountCard, { APPEARANCE } from '~/components/account-card';
import readMoreLink from './read-more-link';
import useGoogleConnectFlow from './useGoogleConnectFlow';
import './request-full-access-google-account-card.scss';
/**
* Renders an AccountCard based on Google appearance for requesting full access permission from user.
*
* @param {Object} props React props.
* @param {string} props.additionalScopeEmail Specify the email to be requested additional permission scopes to Google.
* @fires gla_google_account_connect_button_click with `{ action: 'scope', context: 'reconnect' }`
* @fires gla_google_account_connect_button_click with `{ action: 'scope', context: 'setup-mc' }`
* @fires gla_documentation_link_click with `{ context: 'setup-mc-accounts', link_id: 'required-google-permissions', href: 'https://woocommerce.com/document/google-for-woocommerce/get-started/setup-and-configuration/#required-google-permissions' }`
*/
const RequestFullAccessGoogleAccountCard = ( { additionalScopeEmail } ) => {
const pageName = glaData.mcSetupComplete ? 'reconnect' : 'setup-mc';
const [ handleConnect, { loading, data } ] = useGoogleConnectFlow(
pageName,
additionalScopeEmail
);
return (
<AccountCard
appearance={ APPEARANCE.GOOGLE }
alignIcon="top"
description={
<>
{ additionalScopeEmail }
<p>
<em>
{ createInterpolateElement(
__(
'<alert>Uh-oh!</alert> You did not allow WooCommerce sufficient access to your Google account. You must allow all required permissions in the Google authorization page to proceed. <link>Read more</link>',
'google-listings-and-ads'
),
{
alert: (
<span className="gla-authorize-google-account-card__error-text" />
),
link: readMoreLink,
}
) }
</em>
</p>
</>
}
alignIndicator="top"
indicator={
<AppButton
isSecondary
isDestructive
loading={ loading || data }
eventName="gla_google_account_connect_button_click"
eventProps={ {
context: pageName,
action: 'scope',
} }
text={ __(
'Allow full access',
'google-listings-and-ads'
) }
onClick={ handleConnect }
/>
}
/>
);
};
export default RequestFullAccessGoogleAccountCard;