/**
* External dependencies
*/
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Card, CardHeader, CardDivider } from '@wordpress/components';
/**
* Internal dependencies
*/
import { CardHeaderTitle, CardHeaderDescription } from '~/marketing/components';
import { InstalledChannel, RecommendedChannel } from '~/marketing/types';
import { InstalledChannelCardBody } from './InstalledChannelCardBody';
import { RecommendedChannels } from './RecommendedChannels';
import { RecommendedChannelsList } from './RecommendedChannelsList';
import './Channels.scss';
type ChannelsProps = {
registeredChannels: Array< InstalledChannel >;
recommendedChannels: Array< RecommendedChannel >;
};
export const Channels: React.FC< ChannelsProps > = ( {
registeredChannels,
recommendedChannels,
} ) => {
/*
* If users have no registered channels,
* we should display recommended channels without collapsible list
* and with a description in the card header.
*/
if ( registeredChannels.length === 0 ) {
return (
{ __( 'Channels', 'woocommerce' ) }
{ __(
'Start by adding a channel to your store',
'woocommerce'
) }
);
}
/*
* Users have registered channels,
* so here we display the registered channels first.
* If there are recommended channels,
* we display them next in a collapsible list.
*/
return (
{ __( 'Channels', 'woocommerce' ) }
{ /* Registered channels section. */ }
{ registeredChannels.map( ( el, idx ) => {
return (
{ idx < registeredChannels.length - 1 && (
) }
);
} ) }
{ /* Recommended channels section. */ }
{ recommendedChannels.length >= 1 && (
) }
);
};