-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
81 lines (76 loc) · 3.02 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
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { createInterpolateElement } from '@wordpress/element';
import { Notice, ExternalLink } from '@wordpress/components';
import { Link } from '@woocommerce/components';
import { getSetting } from '@woocommerce/settings'; // eslint-disable-line import/no-unresolved
// The above is an unpublished package, delivered with WC, we use Dependency Extraction Webpack Plugin to import it.
// See https://github.com/woocommerce/woocommerce-admin/issues/7781,
// https://github.com/woocommerce/woocommerce-admin/issues/7810
// Please note, that this is NOT https://www.npmjs.com/package/@woocommerce/settings,
// or https://github.com/woocommerce/woocommerce-admin/tree/main/packages/wc-admin-settings
// but https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/assets/js/settings/shared/index.ts
// (at an unknown version).
/**
* Internal dependencies
*/
import './style.scss';
import documentationLinkProps from '../../helpers/documentation-link-props';
/**
* Renders an unsupported country <Notice> with warning appearance.
*
* @fires wcadmin_pfw_get_started_notice_link_click with `{ context: 'pinterest-landing', linkId: 'ads-availability' | 'unsupported-country-link' }`
*
* @param {Object} props React props.
* @param {string} props.countryCode The alpha-2 country code to map the country name.
*/
function UnsupportedCountryNotice( { countryCode } ) {
const countryName = getSetting( 'countries', {} )[ countryCode ];
if ( ! countryName ) {
return null;
}
return (
<Notice
className="pins-for-woo-unsupported-country-notice"
status="warning"
isDismissible={ false }
>
{ createInterpolateElement(
__(
'Your store’s country is <country />. This country is currently not supported by Pinterest for WooCommerce. However, you can still choose to list your products in supported countries, 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>',
'pinterest-for-woocommerce'
),
{
country: <strong>{ countryName }</strong>,
settingsLink: (
<Link
{ ...documentationLinkProps( {
href: '/wp-admin/admin.php?page=wc-settings',
eventName: 'pfw_get_started_notice_link_click',
linkId: 'unsupported-country-link',
context: 'pinterest-landing',
} ) }
className="pins-for-woo-unsupported-country-notice__link"
type="wp-admin"
/>
),
supportedCountriesLink: (
<ExternalLink
{ ...documentationLinkProps( {
href: wcSettings.pinterest_for_woocommerce
.pinterestLinks.adsAvailability,
eventName: 'pfw_get_started_notice_link_click',
linkId: 'ads-availability',
context: 'pinterest-landing',
} ) }
className="pins-for-woo-unsupported-country-notice__link"
/>
),
}
) }
</Notice>
);
}
export default UnsupportedCountryNotice;