/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { useState } from '@wordpress/element'; import { Card, Flex, FlexItem, FlexBlock, Button } from '@wordpress/components'; import { Icon, trendingUp, megaphone, closeSmall } from '@wordpress/icons'; /** * Internal dependencies */ import { CreateNewCampaignModal } from '~/marketing/components'; import { useRegisteredChannels, useRecommendedChannels, } from '~/marketing/hooks'; import './IntroductionBanner.scss'; import wooIconUrl from './woo.svg'; import illustrationUrl from './illustration.svg'; import illustrationLargeUrl from './illustration-large.svg'; type IntroductionBannerProps = { onDismiss: () => void; onAddChannels: () => void; }; export const IntroductionBanner = ( { onDismiss, onAddChannels, }: IntroductionBannerProps ) => { const [ open, setOpen ] = useState( false ); 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. */ const showAddChannelsButton = !! dataRegistered?.length && !! dataRecommended?.length; return (
{ __( 'Reach new customers and increase sales without leaving WooCommerce', 'woocommerce' ) }
{ __( 'Reach customers on other sales channels', 'woocommerce' ) } { __( 'Advertise with marketing campaigns', 'woocommerce' ) } } /> { __( 'Built by WooCommerce', 'woocommerce' ) } { ( showCreateCampaignButton || showAddChannelsButton ) && ( { showCreateCampaignButton && ( ) } { showAddChannelsButton && ( ) } ) } { open && ( setOpen( false ) } /> ) }
{
); };