/** * External dependencies */ import { Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import GridiconCheckmarkCircle from 'gridicons/dist/checkmark-circle'; import GridiconSync from 'gridicons/dist/sync'; import GridiconNotice from 'gridicons/dist/notice'; import classnames from 'classnames'; /** * Internal dependencies */ import { PluginCardBody } from '~/marketing/components'; import { InstalledChannel, SyncStatusType } from '~/marketing/types'; import './InstalledChannelCardBody.scss'; type InstalledChannelCardBodyProps = { installedChannel: InstalledChannel; }; type SyncStatusPropsType = { status: SyncStatusType; }; const iconSize = 18; const className = 'woocommerce-marketing-sync-status'; const SyncStatus: React.FC< SyncStatusPropsType > = ( { status } ) => { if ( status === 'failed' ) { return (
{ __( 'Sync failed', 'woocommerce' ) }
); } if ( status === 'syncing' ) { return (
{ __( 'Syncing', 'woocommerce' ) }
); } return (
{ __( 'Synced', 'woocommerce' ) }
); }; type IssueStatusPropsType = { installedChannel: InstalledChannel; }; const issueStatusClassName = 'woocommerce-marketing-issue-status'; const IssueStatus: React.FC< IssueStatusPropsType > = ( { installedChannel, } ) => { if ( installedChannel.issueType === 'error' ) { return (
{ installedChannel.issueText }
); } if ( installedChannel.issueType === 'warning' ) { return (
{ installedChannel.issueText }
); } return (
{ installedChannel.issueText }
); }; export const InstalledChannelCardBody: React.FC< InstalledChannelCardBodyProps > = ( { installedChannel } ) => { /** * The description section in the channel card. * * If setup is not completed, this would be the channel description. * * If setup is completed, this would be an element with sync status and issue status. */ const description = ! installedChannel.isSetupCompleted ? ( installedChannel.description ) : (
{ installedChannel.syncStatus && ( <>
) }
); /** * The action button in the channel card. * * If setup is not completed, this would be a "Finish setup" primary button. * * If setup is completed, this would be a "Manage" secondary button. */ const button = ! installedChannel.isSetupCompleted ? ( ) : ( ); return ( } name={ installedChannel.title } description={ description } button={ button } /> ); };