/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { useSelect, useDispatch } from '@wordpress/data'; import { Button, ExternalLink } from '@wordpress/components'; import { Pill } from '@woocommerce/components'; import { PLUGINS_STORE_NAME } from '@woocommerce/data'; import { getAdminLink } from '@woocommerce/settings'; /** * Internal dependencies */ import './woocommerce-services-item.scss'; import WooIcon from './woo-icon.svg'; import { getAdminSetting } from '../utils/admin-settings'; const WooCommerceServicesItem: React.FC< { pluginsBeingSetup: Array< string >; onSetupClick: ( slugs: string[] ) => PromiseLike< void >; } > = ( { onSetupClick, pluginsBeingSetup } ) => { const wcAdminAssetUrl = getAdminSetting( 'wcAdminAssetUrl', '' ); const { createSuccessNotice } = useDispatch( 'core/notices' ); const isSiteConnectedToJetpack = useSelect( ( select ) => select( PLUGINS_STORE_NAME ).isJetpackConnected() ); const handleSetupClick = () => { onSetupClick( [ 'woocommerce-services' ] ).then( () => { const actions = []; if ( ! isSiteConnectedToJetpack ) { actions.push( { url: getAdminLink( 'plugins.php' ), label: __( 'Finish the setup by connecting your store to Jetpack.', 'woocommerce-admin' ), } ); } createSuccessNotice( __( '🎉 WooCommerce Shipping is installed!', 'woocommerce-admin' ), { actions, } ); } ); }; return (