2021-08-11 22:09:32 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2022-04-19 17:45:10 +00:00
|
|
|
import {
|
|
|
|
useSelect,
|
|
|
|
useDispatch,
|
|
|
|
select as wpDataSelect,
|
|
|
|
} from '@wordpress/data';
|
2021-08-11 22:09:32 +00:00
|
|
|
import { Button, ExternalLink } from '@wordpress/components';
|
|
|
|
import { Pill } from '@woocommerce/components';
|
|
|
|
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
|
2022-01-06 12:53:30 +00:00
|
|
|
import { getAdminLink } from '@woocommerce/settings';
|
|
|
|
|
2021-08-11 22:09:32 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './woocommerce-services-item.scss';
|
|
|
|
import WooIcon from './woo-icon.svg';
|
2022-01-06 12:53:30 +00:00
|
|
|
import { getAdminSetting } from '../utils/admin-settings';
|
2021-08-11 22:09:32 +00:00
|
|
|
|
|
|
|
const WooCommerceServicesItem: React.FC< {
|
|
|
|
pluginsBeingSetup: Array< string >;
|
|
|
|
onSetupClick: ( slugs: string[] ) => PromiseLike< void >;
|
|
|
|
} > = ( { onSetupClick, pluginsBeingSetup } ) => {
|
2022-01-06 12:53:30 +00:00
|
|
|
const wcAdminAssetUrl = getAdminSetting( 'wcAdminAssetUrl', '' );
|
2021-08-11 22:09:32 +00:00
|
|
|
const { createSuccessNotice } = useDispatch( 'core/notices' );
|
|
|
|
|
2022-04-19 17:45:10 +00:00
|
|
|
const isSiteConnectedToJetpack = useSelect(
|
|
|
|
( select: typeof wpDataSelect ) =>
|
|
|
|
select( PLUGINS_STORE_NAME ).isJetpackConnected()
|
2021-08-11 22:09:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
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.',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-08-11 22:09:32 +00:00
|
|
|
),
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
createSuccessNotice(
|
2022-03-30 09:00:04 +00:00
|
|
|
__( '🎉 WooCommerce Shipping is installed!', 'woocommerce' ),
|
2021-08-11 22:09:32 +00:00
|
|
|
{
|
|
|
|
actions,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="woocommerce-list__item-inner woocommerce-services-item">
|
|
|
|
<div className="woocommerce-list__item-before">
|
|
|
|
<img
|
|
|
|
className="woocommerce-services-item__logo"
|
|
|
|
src={ WooIcon }
|
|
|
|
alt=""
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-list__item-text">
|
|
|
|
<span className="woocommerce-list__item-title">
|
2022-03-30 09:00:04 +00:00
|
|
|
{ __( 'Woocommerce Shipping', 'woocommerce' ) }
|
|
|
|
<Pill>{ __( 'Recommended', 'woocommerce' ) }</Pill>
|
2021-08-11 22:09:32 +00:00
|
|
|
</span>
|
|
|
|
<span className="woocommerce-list__item-content">
|
|
|
|
{ __(
|
|
|
|
'Print USPS and DHL Express labels straight from your WooCommerce dashboard and save on shipping.',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-08-11 22:09:32 +00:00
|
|
|
) }
|
|
|
|
<br />
|
|
|
|
<ExternalLink href="https://woocommerce.com/woocommerce-shipping/">
|
2022-03-30 09:00:04 +00:00
|
|
|
{ __( 'Learn more', 'woocommerce' ) }
|
2021-08-11 22:09:32 +00:00
|
|
|
</ExternalLink>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-list__item-after">
|
|
|
|
<Button
|
|
|
|
isSecondary
|
|
|
|
onClick={ handleSetupClick }
|
|
|
|
isBusy={ pluginsBeingSetup.includes(
|
|
|
|
'woocommerce-services'
|
|
|
|
) }
|
|
|
|
disabled={ pluginsBeingSetup.length > 0 }
|
|
|
|
>
|
2022-03-30 09:00:04 +00:00
|
|
|
{ __( 'Get started', 'woocommerce' ) }
|
2021-08-11 22:09:32 +00:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default WooCommerceServicesItem;
|