-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.js
122 lines (112 loc) · 3.31 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { Notice, Icon } from '@wordpress/components';
import { external as externalIcon } from '@wordpress/icons';
import { Link } from '@woocommerce/components';
import { createInterpolateElement } from '@wordpress/element';
/**
* Internal dependencies
*/
import useTargetAudience from '~/hooks/useTargetAudience';
import useStoreCountry from '~/hooks/useStoreCountry';
import AppDocumentationLink from '~/components/app-documentation-link';
import { glaData } from '~/constants';
import './index.scss';
const ExternalIcon = () => (
<Icon
className="gla-get-started-notice__icon"
icon={ externalIcon }
size={ 18 }
/>
);
/**
* @fires gla_documentation_link_click with `{ context: 'get-started', link_id: 'supported-languages', href: 'https://support.google.com/merchants/answer/160637' }`
*/
const UnsupportedLanguage = () => {
const { data } = useTargetAudience();
if ( ! data ) {
return null;
}
return (
<Notice
className="gla-get-started-notice"
status="error"
isDismissible={ false }
>
{ createInterpolateElement(
__(
'Your site language is <language />. This language is currently not supported by Google for WooCommerce. <settingsLink>You can change your site language here</settingsLink>. <supportedLanguagesLink>Read more about supported languages</supportedLanguagesLink>',
'google-listings-and-ads'
),
{
language: <strong>{ data.language }</strong>,
settingsLink: (
<Link
type="wp-admin"
href="/wp-admin/options-general.php"
/>
),
supportedLanguagesLink: (
<AppDocumentationLink
href="https://support.google.com/merchants/answer/160637"
context="get-started"
linkId="supported-languages"
/>
),
}
) }
<ExternalIcon />
</Notice>
);
};
/**
* @fires gla_documentation_link_click with `{ context: "get-started", link_id: "supported-countries" }`
*/
const UnsupportedCountry = () => {
const { name: countryName } = useStoreCountry();
if ( ! countryName ) {
return null;
}
return (
<Notice
className="gla-get-started-notice"
status="warning"
isDismissible={ false }
>
{ createInterpolateElement(
__(
'Your store’s country is <country />. This country is currently not supported by Google for WooCommerce. However, you can still choose to list your products in another supported country, if you are able to sell your products to customers there. <settingsLink>Change your store’s country here</settingsLink>. <supportedCountriesLink>Read more about supported countries</supportedCountriesLink>',
'google-listings-and-ads'
),
{
country: <strong>{ countryName }</strong>,
settingsLink: (
<Link
type="wp-admin"
href="/wp-admin/admin.php?page=wc-settings"
/>
),
supportedCountriesLink: (
<AppDocumentationLink
href="https://support.google.com/merchants/answer/160637"
context="get-started"
linkId="supported-countries"
/>
),
}
) }
<ExternalIcon />
</Notice>
);
};
export default function UnsupportedNotices() {
const { mcSupportedLanguage, mcSupportedCountry } = glaData;
return (
<>
{ ! mcSupportedLanguage && <UnsupportedLanguage /> }
{ ! mcSupportedCountry && <UnsupportedCountry /> }
</>
);
}