forked from woocommerce/google-listings-and-ads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
105 lines (99 loc) · 2.99 KB
/
index.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* External dependencies
*/
import { CheckboxControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { createInterpolateElement, useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import AppModal from '.~/components/app-modal';
import AppDocumentationLink from '.~/components/app-documentation-link';
import AppButton from '.~/components/app-button';
import './index.scss';
/**
* Clicking on the button to create a new Google Ads account, after agreeing to the terms and conditions.
*
* @event gla_ads_account_create_button_click
*/
/**
* Terms and conditions agreement modal.
*
* @fires gla_ads_account_create_button_click When agreed by clicking "Create account".
* @fires gla_documentation_link_click with `{ context: 'setup-ads', link_id: 'shopping-ads-policies', href: 'https://support.google.com/merchants/answer/6149970' }`
* @fires gla_documentation_link_click with `{ context: 'setup-ads', link_id: 'google-ads-terms-of-service', href: 'https://support.google.com/adspolicy/answer/54818' }`
* @param {Object} props React props
* @param {Function} [props.onCreateAccount] Callback function when account is created
* @param {Function} [props.onRequestClose] Callback function when the modal is closed
*/
const TermsModal = ( {
onCreateAccount = () => {},
onRequestClose = () => {},
} ) => {
const [ agree, setAgree ] = useState( false );
const handleCreateAccountClick = () => {
onCreateAccount();
onRequestClose();
};
return (
<AppModal
className="gla-ads-terms-modal"
title={ __(
'Create Google Ads Account',
'google-listings-and-ads'
) }
buttons={ [
<AppButton
key="1"
isPrimary
disabled={ ! agree }
eventName="gla_ads_account_create_button_click"
onClick={ handleCreateAccountClick }
>
{ __( 'Create account', 'google-listings-and-ads' ) }
</AppButton>,
] }
onRequestClose={ onRequestClose }
>
<p className="main">
{ __(
'By creating a Google Ads account, you agree to the following terms and conditions:',
'google-listings-and-ads'
) }
</p>
<p>
{ createInterpolateElement(
__(
'You agree to comply with Google’s terms and policies, including <policylink>Shopping ads policies</policylink> and <termslink>Google Ads Terms and Conditions</termslink>.',
'google-listings-and-ads'
),
{
policylink: (
<AppDocumentationLink
context="setup-ads"
linkId="shopping-ads-policies"
href="https://support.google.com/merchants/answer/6149970"
/>
),
termslink: (
<AppDocumentationLink
context="setup-ads"
linkId="google-ads-terms-of-service"
href="https://support.google.com/adspolicy/answer/54818"
/>
),
}
) }
</p>
<CheckboxControl
label={ __(
'I have read and accept these terms',
'google-listings-and-ads'
) }
checked={ agree }
onChange={ setAgree }
/>
</AppModal>
);
};
export default TermsModal;