2022-06-23 01:54:38 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { Button, ExternalLink } from '@wordpress/components';
|
|
|
|
import { Pill } from '@woocommerce/components';
|
2022-06-28 05:53:03 +00:00
|
|
|
import { getNewPath, navigateTo } from '@woocommerce/navigation';
|
2022-07-06 12:00:08 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
|
|
|
import { useContext, useMemo } from '@wordpress/element';
|
2022-06-23 01:54:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './woocommerce-services-item.scss';
|
|
|
|
import WooIcon from './woo-icon.svg';
|
2022-07-06 12:00:08 +00:00
|
|
|
import { LayoutContext } from '~/layout';
|
2022-06-23 01:54:38 +00:00
|
|
|
|
|
|
|
const WooCommerceServicesItem: React.FC< {
|
|
|
|
isWCSInstalled: boolean | undefined;
|
|
|
|
} > = ( { isWCSInstalled } ) => {
|
2022-07-06 12:00:08 +00:00
|
|
|
const layoutContext = useContext( LayoutContext );
|
|
|
|
const updatedLayoutContext = useMemo(
|
|
|
|
() => layoutContext.getExtendedContext( 'wc-settings' ),
|
|
|
|
[ layoutContext ]
|
|
|
|
);
|
2022-06-23 01:54:38 +00:00
|
|
|
const handleSetupClick = () => {
|
2022-07-06 12:00:08 +00:00
|
|
|
recordEvent( 'tasklist_click', {
|
|
|
|
task_name: 'shipping-recommendation',
|
|
|
|
context: updatedLayoutContext.toString(),
|
|
|
|
} );
|
2022-06-28 05:53:03 +00:00
|
|
|
navigateTo( {
|
|
|
|
url: getNewPath( { task: 'shipping-recommendation' }, '/', {} ),
|
|
|
|
} );
|
2022-06-23 01:54:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="woocommerce-list__item-inner woocommerce-services-item">
|
|
|
|
<div className="woocommerce-list__item-before">
|
|
|
|
<img
|
|
|
|
className="woocommerce-services-item__logo"
|
|
|
|
src={ WooIcon }
|
2022-07-13 15:41:22 +00:00
|
|
|
alt="WooCommerce Service Logo"
|
2022-06-23 01:54:38 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-list__item-text">
|
|
|
|
<span className="woocommerce-list__item-title">
|
2022-07-13 15:41:22 +00:00
|
|
|
{ __( 'WooCommerce Shipping', 'woocommerce' ) }
|
2022-06-23 01:54:38 +00:00
|
|
|
<Pill>{ __( 'Recommended', 'woocommerce' ) }</Pill>
|
|
|
|
</span>
|
|
|
|
<span className="woocommerce-list__item-content">
|
|
|
|
{ __(
|
|
|
|
'Print USPS and DHL Express labels straight from your WooCommerce dashboard and save on shipping.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
<br />
|
|
|
|
<ExternalLink href="https://woocommerce.com/woocommerce-shipping/">
|
|
|
|
{ __( 'Learn more', 'woocommerce' ) }
|
|
|
|
</ExternalLink>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="woocommerce-list__item-after">
|
|
|
|
<Button isSecondary onClick={ handleSetupClick }>
|
|
|
|
{ isWCSInstalled
|
|
|
|
? __( 'Activate', 'woocommerce' )
|
|
|
|
: __( 'Get started', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default WooCommerceServicesItem;
|