Use SmartPluginCardBody in Channels component.
This commit is contained in:
parent
5da2385d41
commit
7852448a7a
|
@ -1,8 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* External dependencies
|
* External dependencies
|
||||||
*/
|
*/
|
||||||
|
import { Fragment } from '@wordpress/element';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { Card, CardHeader, CardBody } from '@wordpress/components';
|
import { Card, CardHeader, CardBody, CardDivider } from '@wordpress/components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -11,6 +12,7 @@ import {
|
||||||
CardHeaderTitle,
|
CardHeaderTitle,
|
||||||
CardHeaderDescription,
|
CardHeaderDescription,
|
||||||
CenteredSpinner,
|
CenteredSpinner,
|
||||||
|
SmartPluginCardBody,
|
||||||
} from '~/marketing/components';
|
} from '~/marketing/components';
|
||||||
import { useChannels } from './useChannels';
|
import { useChannels } from './useChannels';
|
||||||
import './Channels.scss';
|
import './Channels.scss';
|
||||||
|
@ -21,6 +23,11 @@ export const Channels = () => {
|
||||||
data: { registeredChannels, recommendedChannels },
|
data: { registeredChannels, recommendedChannels },
|
||||||
} = useChannels();
|
} = useChannels();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: we may need to filter the channels against
|
||||||
|
* `@woocommerce/data` installed plugins.
|
||||||
|
*/
|
||||||
|
|
||||||
if ( loading ) {
|
if ( loading ) {
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
|
@ -36,21 +43,58 @@ export const Channels = () => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const description =
|
/*
|
||||||
registeredChannels.length === 0 &&
|
* If users have no registered channels,
|
||||||
recommendedChannels.length > 0 &&
|
* we display recommended channels without collapsible list.
|
||||||
__( 'Start by adding a channel to your store', 'woocommerce' );
|
*/
|
||||||
|
if ( registeredChannels.length === 0 && recommendedChannels.length > 0 ) {
|
||||||
|
return (
|
||||||
|
<Card className="woocommerce-marketing-channels-card">
|
||||||
|
<CardHeader>
|
||||||
|
<CardHeaderTitle>
|
||||||
|
{ __( 'Channels', 'woocommerce' ) }
|
||||||
|
</CardHeaderTitle>
|
||||||
|
<CardHeaderDescription>
|
||||||
|
{ __(
|
||||||
|
'Start by adding a channel to your store',
|
||||||
|
'woocommerce'
|
||||||
|
) }
|
||||||
|
</CardHeaderDescription>
|
||||||
|
</CardHeader>
|
||||||
|
{ recommendedChannels.map( ( el, idx ) => {
|
||||||
|
return (
|
||||||
|
<Fragment key={ el.plugin }>
|
||||||
|
<SmartPluginCardBody plugin={ el } />
|
||||||
|
{ idx < recommendedChannels.length - 1 && (
|
||||||
|
<CardDivider />
|
||||||
|
) }
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
} ) }
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Users have registered channels,
|
||||||
|
* display the registered channels.
|
||||||
|
* If there are recommended channels,
|
||||||
|
* display them in a collapsible list.
|
||||||
|
*/
|
||||||
return (
|
return (
|
||||||
<Card className="woocommerce-marketing-channels-card">
|
<Card className="woocommerce-marketing-channels-card">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardHeaderTitle>
|
<CardHeaderTitle>
|
||||||
{ __( 'Channels', 'woocommerce' ) }
|
{ __( 'Channels', 'woocommerce' ) }
|
||||||
</CardHeaderTitle>
|
</CardHeaderTitle>
|
||||||
<CardHeaderDescription>{ description }</CardHeaderDescription>
|
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
{ /* TODO: */ }
|
|
||||||
<CardBody>Body</CardBody>
|
{ /* TODO: registered channels here. */ }
|
||||||
|
|
||||||
|
{ /* TODO: recommended channels here. */ }
|
||||||
|
{ recommendedChannels.length > 0 && (
|
||||||
|
<CardBody>recommended</CardBody>
|
||||||
|
) }
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue