2022-09-14 07:43:30 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2022-11-24 13:46:08 +00:00
|
|
|
import { Button } from '@wordpress/components';
|
2022-09-14 07:43:30 +00:00
|
|
|
import { Icon, trendingUp } from '@wordpress/icons';
|
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2022-12-08 18:19:36 +00:00
|
|
|
import {
|
|
|
|
CollapsibleCard,
|
|
|
|
CardBody,
|
|
|
|
CenteredSpinner,
|
|
|
|
} from '~/marketing/components';
|
2023-03-21 13:13:19 +00:00
|
|
|
import { useRecommendedPluginsWithoutChannels } from './useRecommendedPluginsWithoutChannels';
|
2022-11-24 13:46:08 +00:00
|
|
|
import { PluginsTabPanel } from './PluginsTabPanel';
|
2022-09-14 07:43:30 +00:00
|
|
|
import './DiscoverTools.scss';
|
|
|
|
|
|
|
|
export const DiscoverTools = () => {
|
2023-03-21 13:12:00 +00:00
|
|
|
const { isInitializing, isLoading, data, installAndActivate } =
|
|
|
|
useRecommendedPluginsWithoutChannels();
|
2022-09-14 07:43:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders card body.
|
|
|
|
*
|
|
|
|
* - If loading is in progress, it renders a loading indicator.
|
|
|
|
* - If there are zero plugins, it renders an empty content.
|
2022-11-24 13:46:08 +00:00
|
|
|
* - Otherwise, it renders PluginsTabPanel.
|
2022-09-14 07:43:30 +00:00
|
|
|
*/
|
|
|
|
const renderCardContent = () => {
|
2022-11-24 13:46:08 +00:00
|
|
|
if ( isInitializing ) {
|
2022-09-14 07:43:30 +00:00
|
|
|
return (
|
|
|
|
<CardBody>
|
2022-12-08 18:19:36 +00:00
|
|
|
<CenteredSpinner />
|
2022-09-14 07:43:30 +00:00
|
|
|
</CardBody>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-03-21 13:12:00 +00:00
|
|
|
if ( data.length === 0 ) {
|
2022-09-14 07:43:30 +00:00
|
|
|
return (
|
|
|
|
<CardBody className="woocommerce-marketing-discover-tools-card-body-empty-content">
|
|
|
|
<Icon icon={ trendingUp } size={ 32 } />
|
|
|
|
<div>
|
|
|
|
{ __(
|
|
|
|
'Continue to reach the right audiences and promote your products in ways that matter to them with our range of marketing solutions.',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</div>
|
|
|
|
<Button
|
|
|
|
variant="tertiary"
|
|
|
|
href="https://woocommerce.com/product-category/woocommerce-extensions/marketing-extensions/"
|
|
|
|
onClick={ () => {
|
|
|
|
recordEvent( 'marketing_explore_more_extensions' );
|
|
|
|
} }
|
|
|
|
>
|
|
|
|
{ __(
|
|
|
|
'Explore more marketing extensions',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</Button>
|
|
|
|
</CardBody>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-11-24 13:46:08 +00:00
|
|
|
<PluginsTabPanel
|
2023-03-21 13:12:00 +00:00
|
|
|
plugins={ data }
|
2022-11-24 13:46:08 +00:00
|
|
|
isLoading={ isLoading }
|
|
|
|
onInstallAndActivate={ installAndActivate }
|
|
|
|
/>
|
2022-09-14 07:43:30 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CollapsibleCard
|
|
|
|
header={ __( 'Discover more marketing tools', 'woocommerce' ) }
|
|
|
|
>
|
|
|
|
{ renderCardContent() }
|
|
|
|
</CollapsibleCard>
|
|
|
|
);
|
|
|
|
};
|