2022-12-26 18:05:58 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2023-03-07 16:37:55 +00:00
|
|
|
import { useState } from '@wordpress/element';
|
2022-12-27 12:47:14 +00:00
|
|
|
import { Card, Flex, FlexItem, FlexBlock, Button } from '@wordpress/components';
|
2022-12-27 13:06:26 +00:00
|
|
|
import { Icon, trendingUp, megaphone, closeSmall } from '@wordpress/icons';
|
2022-12-26 18:05:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2023-03-07 16:37:55 +00:00
|
|
|
import { CreateNewCampaignModal } from '~/marketing/components';
|
2023-03-07 18:54:43 +00:00
|
|
|
import {
|
|
|
|
useRegisteredChannels,
|
|
|
|
useRecommendedChannels,
|
|
|
|
} from '~/marketing/hooks';
|
2022-12-26 18:05:58 +00:00
|
|
|
import './IntroductionBanner.scss';
|
|
|
|
import wooIconUrl from './woo.svg';
|
2023-03-20 10:11:02 +00:00
|
|
|
import illustrationUrl from './illustration.svg';
|
2022-12-26 18:05:58 +00:00
|
|
|
|
2022-12-27 13:06:26 +00:00
|
|
|
type IntroductionBannerProps = {
|
2023-03-19 13:10:22 +00:00
|
|
|
onDismissClick: () => void;
|
|
|
|
onAddChannelsClick: () => void;
|
2022-12-27 13:06:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const IntroductionBanner = ( {
|
2023-03-19 13:10:22 +00:00
|
|
|
onDismissClick,
|
|
|
|
onAddChannelsClick,
|
2022-12-27 13:06:26 +00:00
|
|
|
}: IntroductionBannerProps ) => {
|
2023-03-19 12:58:54 +00:00
|
|
|
const [ isModalOpen, setModalOpen ] = useState( false );
|
2023-03-07 18:54:43 +00:00
|
|
|
const { data: dataRegistered } = useRegisteredChannels();
|
|
|
|
const { data: dataRecommended } = useRecommendedChannels();
|
|
|
|
|
|
|
|
const showCreateCampaignButton = !! dataRegistered?.length;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Boolean to display the "Add channels" button in the introduction banner.
|
|
|
|
*
|
|
|
|
* This depends on the number of registered channels,
|
|
|
|
* because if there are no registered channels,
|
|
|
|
* the Channels card will not have the "Add channels" toggle button,
|
|
|
|
* and it does not make sense to display the "Add channels" button in this introduction banner
|
|
|
|
* that will do nothing upon click.
|
|
|
|
*
|
|
|
|
* If there are registered channels and recommended channels,
|
|
|
|
* the Channels card will display the "Add channels" toggle button,
|
|
|
|
* and clicking on the "Add channels" button in this introduction banner
|
|
|
|
* will scroll to the button in Channels card.
|
|
|
|
*/
|
2023-03-27 13:55:42 +00:00
|
|
|
const showAddChannelsButton = !! (
|
|
|
|
dataRegistered?.length && dataRecommended?.length
|
|
|
|
);
|
2023-03-07 16:37:55 +00:00
|
|
|
|
2022-12-26 18:05:58 +00:00
|
|
|
return (
|
|
|
|
<Card className="woocommerce-marketing-introduction-banner">
|
|
|
|
<div className="woocommerce-marketing-introduction-banner-content">
|
|
|
|
<div className="woocommerce-marketing-introduction-banner-title">
|
|
|
|
{ __(
|
|
|
|
'Reach new customers and increase sales without leaving WooCommerce',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</div>
|
|
|
|
<Flex
|
|
|
|
className="woocommerce-marketing-introduction-banner-features"
|
|
|
|
direction="column"
|
|
|
|
gap={ 1 }
|
|
|
|
expanded={ false }
|
|
|
|
>
|
|
|
|
<FlexItem>
|
|
|
|
<Flex>
|
|
|
|
<Icon icon={ trendingUp } />
|
|
|
|
<FlexBlock>
|
|
|
|
{ __(
|
|
|
|
'Reach customers on other sales channels',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</FlexBlock>
|
|
|
|
</Flex>
|
|
|
|
</FlexItem>
|
|
|
|
<FlexItem>
|
|
|
|
<Flex>
|
|
|
|
<Icon icon={ megaphone } />
|
|
|
|
<FlexBlock>
|
|
|
|
{ __(
|
|
|
|
'Advertise with marketing campaigns',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
</FlexBlock>
|
|
|
|
</Flex>
|
|
|
|
</FlexItem>
|
|
|
|
<FlexItem>
|
|
|
|
<Flex>
|
2023-03-19 12:56:00 +00:00
|
|
|
<img
|
|
|
|
src={ wooIconUrl }
|
|
|
|
alt={ __( 'WooCommerce logo', 'woocommerce' ) }
|
|
|
|
width="24"
|
|
|
|
height="24"
|
2022-12-26 18:05:58 +00:00
|
|
|
/>
|
|
|
|
<FlexBlock>
|
|
|
|
{ __( 'Built by WooCommerce', 'woocommerce' ) }
|
|
|
|
</FlexBlock>
|
|
|
|
</Flex>
|
|
|
|
</FlexItem>
|
|
|
|
</Flex>
|
2023-03-07 18:54:43 +00:00
|
|
|
{ ( showCreateCampaignButton || showAddChannelsButton ) && (
|
2022-12-27 13:06:26 +00:00
|
|
|
<Flex
|
|
|
|
className="woocommerce-marketing-introduction-banner-buttons"
|
|
|
|
justify="flex-start"
|
|
|
|
>
|
2023-03-07 18:54:43 +00:00
|
|
|
{ showCreateCampaignButton && (
|
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
onClick={ () => {
|
2023-03-19 12:58:54 +00:00
|
|
|
setModalOpen( true );
|
2023-03-07 18:54:43 +00:00
|
|
|
} }
|
|
|
|
>
|
|
|
|
{ __( 'Create a campaign', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
) }
|
|
|
|
{ showAddChannelsButton && (
|
|
|
|
<Button
|
|
|
|
variant="secondary"
|
2023-03-19 13:10:22 +00:00
|
|
|
onClick={ onAddChannelsClick }
|
2023-03-07 18:54:43 +00:00
|
|
|
>
|
|
|
|
{ __( 'Add channels', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
) }
|
2022-12-27 13:06:26 +00:00
|
|
|
</Flex>
|
|
|
|
) }
|
2023-03-19 12:58:54 +00:00
|
|
|
{ isModalOpen && (
|
2023-03-07 16:37:55 +00:00
|
|
|
<CreateNewCampaignModal
|
2023-03-19 12:58:54 +00:00
|
|
|
onRequestClose={ () => setModalOpen( false ) }
|
2023-03-07 16:37:55 +00:00
|
|
|
/>
|
|
|
|
) }
|
2022-12-26 18:05:58 +00:00
|
|
|
</div>
|
|
|
|
<div className="woocommerce-marketing-introduction-banner-illustration">
|
2022-12-27 12:47:14 +00:00
|
|
|
<Button
|
|
|
|
isSmall
|
|
|
|
className="woocommerce-marketing-introduction-banner-close-button"
|
2023-03-19 13:10:22 +00:00
|
|
|
onClick={ onDismissClick }
|
2022-12-27 12:47:14 +00:00
|
|
|
>
|
|
|
|
<Icon icon={ closeSmall } />
|
|
|
|
</Button>
|
2023-03-20 10:07:30 +00:00
|
|
|
<div
|
|
|
|
className="woocommerce-marketing-introduction-banner-image-placeholder"
|
|
|
|
style={ {
|
2023-03-20 10:11:02 +00:00
|
|
|
backgroundImage: `url("${ illustrationUrl }")`,
|
2023-03-20 10:07:30 +00:00
|
|
|
} }
|
2022-12-26 18:05:58 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|