/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { useState } from '@wordpress/element'; import { Button, Modal, Icon, Flex, FlexBlock, FlexItem, } from '@wordpress/components'; import { chevronUp, chevronDown, external } from '@wordpress/icons'; import classnames from 'classnames'; /** * Internal dependencies */ import { useRecommendedChannels, useCampaignTypes, useRegisteredChannels, } from '~/marketing/hooks'; import { SmartPluginCardBody } from '~/marketing/components'; import './CreateNewCampaignModal.scss'; const isExternalURL = ( url: string ) => new URL( url ).origin !== location.origin; /** * Props for CreateNewCampaignModal, which is based on Modal.Props. * * Modal's title and children props are omitted because they are specified within the component * and not needed to be specified by the consumer. */ type CreateCampaignModalProps = Omit< Modal.Props, 'title' | 'children' >; export const CreateNewCampaignModal = ( props: CreateCampaignModalProps ) => { const { className, ...restProps } = props; const [ collapsed, setCollapsed ] = useState( true ); const { data: campaignTypes, refetch: refetchCampaignTypes } = useCampaignTypes(); const { refetch: refetchRegisteredChannels } = useRegisteredChannels(); const { data: recommendedChannels } = useRecommendedChannels(); const refetch = () => { refetchCampaignTypes(); refetchRegisteredChannels(); }; return (
{ !! campaignTypes?.length ? __( 'Where would you like to promote your products?', 'woocommerce' ) : __( 'No campaign types found.', 'woocommerce' ) }
{ campaignTypes?.map( ( el ) => ( { { el.name } { el.description } ) ) }
{ !! recommendedChannels?.length && (
{ ! collapsed && ( { recommendedChannels.map( ( el ) => ( ) ) } ) }
) }
); };