From 7852448a7a090b11dbac1dbfceac8416940b6956 Mon Sep 17 00:00:00 2001 From: Gan Eng Chin Date: Sat, 10 Dec 2022 00:51:57 +0800 Subject: [PATCH] Use SmartPluginCardBody in Channels component. --- .../Channels/Channels.tsx | 60 ++++++++++++++++--- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/Channels.tsx b/plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/Channels.tsx index 927fd7c5d3d..c9f33c4c3eb 100644 --- a/plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/Channels.tsx +++ b/plugins/woocommerce-admin/client/marketing/overview-multichannel/Channels/Channels.tsx @@ -1,8 +1,9 @@ /** * External dependencies */ +import { Fragment } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { Card, CardHeader, CardBody } from '@wordpress/components'; +import { Card, CardHeader, CardBody, CardDivider } from '@wordpress/components'; /** * Internal dependencies @@ -11,6 +12,7 @@ import { CardHeaderTitle, CardHeaderDescription, CenteredSpinner, + SmartPluginCardBody, } from '~/marketing/components'; import { useChannels } from './useChannels'; import './Channels.scss'; @@ -21,6 +23,11 @@ export const Channels = () => { data: { registeredChannels, recommendedChannels }, } = useChannels(); + /** + * TODO: we may need to filter the channels against + * `@woocommerce/data` installed plugins. + */ + if ( loading ) { return ( @@ -36,21 +43,58 @@ export const Channels = () => { ); } - const description = - registeredChannels.length === 0 && - recommendedChannels.length > 0 && - __( 'Start by adding a channel to your store', 'woocommerce' ); + /* + * If users have no registered channels, + * we display recommended channels without collapsible list. + */ + if ( registeredChannels.length === 0 && recommendedChannels.length > 0 ) { + return ( + + + + { __( 'Channels', 'woocommerce' ) } + + + { __( + 'Start by adding a channel to your store', + 'woocommerce' + ) } + + + { recommendedChannels.map( ( el, idx ) => { + return ( + + + { idx < recommendedChannels.length - 1 && ( + + ) } + + ); + } ) } + + ); + } + /* + * TODO: Users have registered channels, + * display the registered channels. + * If there are recommended channels, + * display them in a collapsible list. + */ return ( { __( 'Channels', 'woocommerce' ) } - { description } - { /* TODO: */ } - Body + + { /* TODO: registered channels here. */ } + + { /* TODO: recommended channels here. */ } + { recommendedChannels.length > 0 && ( + recommended + ) } ); };