2022-12-09 17:37:21 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-12-13 13:36:09 +00:00
|
|
|
import { Button } from '@wordpress/components';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2022-12-09 17:37:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2022-12-13 13:36:09 +00:00
|
|
|
import { PluginCardBody } from '~/marketing/components';
|
2023-01-27 16:14:50 +00:00
|
|
|
import { RegisteredChannel } from '~/marketing/types';
|
|
|
|
import { SyncStatus } from './SyncStatus';
|
|
|
|
import { IssueStatus } from './IssueStatus';
|
2023-01-20 18:36:39 +00:00
|
|
|
import './RegisteredChannelCardBody.scss';
|
2022-12-09 17:37:21 +00:00
|
|
|
|
2023-01-20 18:36:39 +00:00
|
|
|
type RegisteredChannelCardBodyProps = {
|
|
|
|
registeredChannel: RegisteredChannel;
|
2022-12-09 17:37:21 +00:00
|
|
|
};
|
|
|
|
|
2023-01-20 18:36:39 +00:00
|
|
|
export const RegisteredChannelCardBody: React.FC<
|
|
|
|
RegisteredChannelCardBodyProps
|
|
|
|
> = ( { registeredChannel } ) => {
|
2022-12-13 15:23:13 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2023-01-20 18:36:39 +00:00
|
|
|
const description = ! registeredChannel.isSetupCompleted ? (
|
|
|
|
registeredChannel.description
|
2022-12-13 15:23:13 +00:00
|
|
|
) : (
|
2023-01-20 18:38:00 +00:00
|
|
|
<div className="woocommerce-marketing-registered-channel-description">
|
2023-03-15 00:24:00 +00:00
|
|
|
{ !! registeredChannel.syncStatus && (
|
2023-01-18 17:32:38 +00:00
|
|
|
<>
|
2023-01-20 18:36:39 +00:00
|
|
|
<SyncStatus status={ registeredChannel.syncStatus } />
|
2023-01-20 18:38:00 +00:00
|
|
|
<div className="woocommerce-marketing-registered-channel-description__separator" />
|
2023-01-18 17:32:38 +00:00
|
|
|
</>
|
|
|
|
) }
|
2023-01-20 18:36:39 +00:00
|
|
|
<IssueStatus registeredChannel={ registeredChannel } />
|
2022-12-13 15:23:13 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2023-01-20 18:36:39 +00:00
|
|
|
const button = ! registeredChannel.isSetupCompleted ? (
|
|
|
|
<Button variant="primary" href={ registeredChannel.setupUrl }>
|
2022-12-13 15:23:13 +00:00
|
|
|
{ __( 'Finish setup', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
) : (
|
2023-01-20 18:36:39 +00:00
|
|
|
<Button variant="secondary" href={ registeredChannel.manageUrl }>
|
2022-12-13 15:23:13 +00:00
|
|
|
{ __( 'Manage', 'woocommerce' ) }
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
|
2022-12-09 17:37:21 +00:00
|
|
|
return (
|
2022-12-13 13:36:09 +00:00
|
|
|
<PluginCardBody
|
2023-01-20 18:38:00 +00:00
|
|
|
className="woocommerce-marketing-registered-channel-card-body"
|
2022-12-13 13:36:09 +00:00
|
|
|
icon={
|
|
|
|
<img
|
2023-01-20 18:36:39 +00:00
|
|
|
src={ registeredChannel.icon }
|
|
|
|
alt={ registeredChannel.title }
|
2022-12-13 13:36:09 +00:00
|
|
|
/>
|
|
|
|
}
|
2023-01-20 18:36:39 +00:00
|
|
|
name={ registeredChannel.title }
|
2022-12-13 15:23:13 +00:00
|
|
|
description={ description }
|
|
|
|
button={ button }
|
2022-12-13 13:36:09 +00:00
|
|
|
/>
|
2022-12-09 17:37:21 +00:00
|
|
|
);
|
|
|
|
};
|