-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSetupPins.js
327 lines (321 loc) · 9.33 KB
/
SetupPins.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
/**
* External dependencies
*/
import classnames from 'classnames';
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
import {
Tooltip,
ExternalLink,
Card,
CardBody,
CheckboxControl,
Icon,
Spinner,
__experimentalText as Text, // eslint-disable-line @wordpress/no-unsafe-wp-apis --- _experimentalText unlikely to change/disappear and also used by WC Core
} from '@wordpress/components';
/**
* Internal dependencies
*/
import StepOverview from '../components/StepOverview';
import documentationLinkProps from '../helpers/documentation-link-props';
import {
useSettingsSelect,
useSettingsDispatch,
useCreateNotice,
} from '../helpers/effects';
function HelpTooltip( { text } ) {
return (
<Tooltip position="top center" text={ text }>
<Icon icon="editor-help" />
</Tooltip>
);
}
/**
* Tracking setup component.
*
* To be used in onboarding stepper.
*
* @fires wcadmin_pfw_documentation_link_click with `{ link_id: 'ads-manager', context: 'settings' }`
* @fires wcadmin_pfw_documentation_link_click with `{ link_id: 'enhanced-match', context: 'settings' }`
*
* @return {JSX.Element} rendered component
*/
const SetupPins = ( {} ) => {
const appSettings = useSettingsSelect();
const setAppSettings = useSettingsDispatch( false );
const createNotice = useCreateNotice();
const handleOptionChange = async ( name, value ) => {
try {
await setAppSettings( {
[ name ]: value ?? ! appSettings[ name ],
} );
} catch ( error ) {
createNotice(
'error',
__(
'There was a problem saving your settings.',
'pinterest-for-woocommerce'
)
);
}
};
return (
<div className="woocommerce-setup-guide__setup-pins">
<div className="woocommerce-setup-guide__step-columns">
<div className="woocommerce-setup-guide__step-column">
<StepOverview
title={ __(
'Publish Pins and Rich Pins',
'pinterest-for-woocommerce'
) }
description={ __(
'Rich Pins are a type of organic Pin that automatically sync information from your website to your Pins. You can identify Rich Pins by the extra information above and below the image on closeup and the bold title in your feed. If something changes on the original website, the Rich Pin updates to reflect that change.',
'pinterest-for-woocommerce'
) }
/>
</div>
<div className="woocommerce-setup-guide__step-column">
<Card>
<CardBody size="large">
{ undefined !== appSettings &&
Object.keys( appSettings ).length > 0 ? (
<>
<Text
className="woocommerce-setup-guide__checkbox-heading"
variant="subtitle"
>
{ __(
'Tracking',
'pinterest-for-woocommerce'
) }
</Text>
<CheckboxControl
label={ __(
'Track conversions',
'pinterest-for-woocommerce'
) }
help={
<HelpTooltip
text={ __(
'Gather analytics for Pins you publish and Pins users create from your site.',
'pinterest-for-woocommerce'
) }
/>
}
checked={
appSettings.track_conversions
}
className="woocommerce-setup-guide__checkbox-group"
onChange={ () =>
handleOptionChange(
'track_conversions'
)
}
/>
<CheckboxControl
label={ __(
'Enhanced Match support',
'pinterest-for-woocommerce'
) }
help={
<HelpTooltip
text={ createInterpolateElement(
__(
'Matches conversion data with the person responsible for the conversion and lets you track cross-device checkouts. Requires Track Conversion option to be enabled. <link>See more</link>',
'pinterest-for-woocommerce'
),
{
link: (
// eslint-disable-next-line jsx-a11y/anchor-has-content -- context passed via documentationLinkProps
<a
className="pinterest-tooltip-link"
{ ...documentationLinkProps(
{
href: wcSettings
.pinterest_for_woocommerce
.pinterestLinks
.enhancedMatch,
linkId: 'enhanced-match',
context:
'settings',
}
) }
/>
),
}
) }
/>
}
checked={
appSettings.enhanced_match_support
}
className={ classnames(
'woocommerce-setup-guide__checkbox-group',
{
'pinterest-for-woocommerce-settings-checkbox-disabled':
! appSettings.track_conversions,
}
) }
disabled={
! appSettings.track_conversions
}
onChange={ () =>
handleOptionChange(
'enhanced_match_support'
)
}
/>
<CheckboxControl
label={ __(
'Automatic Enhanced Match support',
'pinterest-for-woocommerce'
) }
help={
<HelpTooltip
text={ __(
'Uses hashed information that your customers have already provided to your business to help match more of your website visitors and conversions to people on Pinterest. Enabling it may improve the performance of your campaigns and can help increase the size of your Pinterest tag audiences.',
'pinterest-for-woocommerce'
) }
/>
}
checked={
appSettings.automatic_enhanced_match_support
}
className={ classnames(
'woocommerce-setup-guide__checkbox-group woocommerce-setup-guide__checkbox-readonly woocommerce-setup-guide__with-help-description'
) }
disabled={ true }
onChange={ () =>
handleOptionChange(
'automatic_enhanced_match_support'
)
}
/>
<Text
className="woocommerce-setup-guide__help-description"
variant="caption"
>
{ createInterpolateElement(
__(
'Manage information shared on <linkAdsManager>Pinterest Ads Manager </linkAdsManager>',
'pinterest-for-woocommerce'
),
{
linkAdsManager: (
<ExternalLink
{ ...documentationLinkProps(
{
href: wcSettings
.pinterest_for_woocommerce
.pinterestLinks
.tagManager,
linkId: 'ads-manager',
context:
'settings',
}
) }
/>
),
}
) }
</Text>
<Text
className="woocommerce-setup-guide__checkbox-heading"
variant="subtitle"
>
{ __(
'Rich Pins',
'pinterest-for-woocommerce'
) }
</Text>
<CheckboxControl
label={ __(
'Add Rich Pins for Products',
'pinterest-for-woocommerce'
) }
help={
<HelpTooltip
text={ __(
'Automatically create and update rich pins on Pinterest for all synced products.',
'pinterest-for-woocommerce'
) }
/>
}
checked={
appSettings.rich_pins_on_products
}
className="woocommerce-setup-guide__checkbox-group"
onChange={ () =>
handleOptionChange(
'rich_pins_on_products'
)
}
/>
<CheckboxControl
label={ __(
'Add Rich Pins for Posts',
'pinterest-for-woocommerce'
) }
help={
<HelpTooltip
text={ __(
'Automatically create and update rich pins on Pinterest for posts.',
'pinterest-for-woocommerce'
) }
/>
}
checked={
appSettings.rich_pins_on_posts
}
className="woocommerce-setup-guide__checkbox-group"
onChange={ () =>
handleOptionChange(
'rich_pins_on_posts'
)
}
/>
<Text
className="woocommerce-setup-guide__checkbox-heading"
variant="subtitle"
>
{ __(
'Save to Pinterest',
'pinterest-for-woocommerce'
) }
</Text>
<CheckboxControl
label={ __(
'Save to Pinterest',
'pinterest-for-woocommerce'
) }
help={
<HelpTooltip
text={ __(
'Adds a ‘Save’ button on images allowing customers to save things straight from your website to Pinterest.',
'pinterest-for-woocommerce'
) }
/>
}
checked={
appSettings.save_to_pinterest
}
className="woocommerce-setup-guide__checkbox-group"
onChange={ () =>
handleOptionChange(
'save_to_pinterest'
)
}
/>
</>
) : (
<Spinner />
) }
</CardBody>
</Card>
</div>
</div>
</div>
);
};
export default SetupPins;