forked from woocommerce/google-listings-and-ads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchoose-audience-section.js
138 lines (134 loc) · 4.03 KB
/
choose-audience-section.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/**
* External dependencies
*/
import { RadioControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useAdaptiveFormContext } from '.~/components/adaptive-form';
import AppRadioContentControl from '.~/components/app-radio-content-control';
import AppDocumentationLink from '.~/components/app-documentation-link';
import Section from '.~/wcdl/section';
import Subsection from '.~/wcdl/subsection';
import RadioHelperText from '.~/wcdl/radio-helper-text';
import SupportedCountrySelect from '.~/components/supported-country-select';
import VerticalGapLayout from '.~/components/vertical-gap-layout';
import './choose-audience-section.scss';
/**
* Section form to choose audience.
*
* To be used in onboarding and further editing.
* Does not provide any save strategy, this is to be bound externaly.
*
* @fires gla_documentation_link_click with `{ context: 'setup-mc-audience', link_id: 'site-language', href: 'https://support.google.com/merchants/answer/160637' }`
*/
const ChooseAudienceSection = () => {
const {
values,
getInputProps,
adapter: { renderRequestedValidation },
} = useAdaptiveFormContext();
const { locale, language } = values;
return (
<>
<Section
className="gla-choose-audience-section"
title={ __( 'Audience', 'google-listings-and-ads' ) }
description={
<p>
{ __(
'Where do you want to sell your products?',
'google-listings-and-ads'
) }
</p>
}
>
<Section.Card>
<Section.Card.Body>
<Subsection>
<Subsection.Title>
{ __( 'Language', 'google-listings-and-ads' ) }
</Subsection.Title>
<Subsection.HelperText className="gla-choose-audience-section__language-helper">
{ createInterpolateElement(
__(
'Listings can only be displayed in your site language. <link>Read more</link>',
'google-listings-and-ads'
),
{
link: (
<AppDocumentationLink
context="setup-mc-audience"
linkId="site-language"
href="https://support.google.com/merchants/answer/160637"
/>
),
}
) }
</Subsection.HelperText>
<RadioControl
selected={ locale }
options={ [
{
label: language,
value: locale,
},
] }
/>
</Subsection>
<Subsection>
<Subsection.Title>
{ __( 'Location', 'google-listings-and-ads' ) }
</Subsection.Title>
<Subsection.HelperText>
{ __(
'Your store should already have the appropriate shipping and tax rates (if required) for potential customers in your selected location(s).',
'google-listings-and-ads'
) }
</Subsection.HelperText>
<VerticalGapLayout size="medium">
<AppRadioContentControl
{ ...getInputProps( 'location' ) }
collapsible={ true }
label={ __(
'Selected countries only',
'google-listings-and-ads'
) }
value="selected"
>
<SupportedCountrySelect
multiple
{ ...getInputProps( 'countries' ) }
help={ __(
'Can’t find a country? Only supported countries can be selected.',
'google-listings-and-ads'
) }
/>
{ renderRequestedValidation( 'countries' ) }
</AppRadioContentControl>
<AppRadioContentControl
{ ...getInputProps( 'location' ) }
label={ __(
'All countries',
'google-listings-and-ads'
) }
value="all"
>
<RadioHelperText>
{ __(
'Your listings will be shown in all supported countries.',
'google-listings-and-ads'
) }
</RadioHelperText>
</AppRadioContentControl>
</VerticalGapLayout>
</Subsection>
</Section.Card.Body>
</Section.Card>
</Section>
</>
);
};
export default ChooseAudienceSection;