2022-04-13 14:20:26 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Badge } from '@woocommerce/components';
|
|
|
|
import { TaskListSection, TaskType } from '@woocommerce/data';
|
|
|
|
import { Icon, check } from '@wordpress/icons';
|
|
|
|
import { Text } from '@woocommerce/experimental';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import SectionHeader from './headers/section-header';
|
|
|
|
|
|
|
|
type SectionPanelTitleProps = {
|
|
|
|
section: TaskListSection;
|
|
|
|
active: boolean;
|
|
|
|
tasks: TaskType[];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const SectionPanelTitle: React.FC< SectionPanelTitleProps > = ( {
|
|
|
|
section,
|
|
|
|
active,
|
|
|
|
tasks,
|
|
|
|
} ) => {
|
|
|
|
if ( active ) {
|
|
|
|
return (
|
|
|
|
<div className="wooocommerce-task-card__header-container">
|
|
|
|
<div className="wooocommerce-task-card__header">
|
|
|
|
<SectionHeader { ...section } />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const uncompletedTasksCount = tasks.filter(
|
|
|
|
( task ) => ! task.isComplete && section.tasks.includes( task.id )
|
|
|
|
).length;
|
2022-04-13 15:15:05 +00:00
|
|
|
const isComplete = section.isComplete || uncompletedTasksCount === 0;
|
2022-04-13 14:20:26 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Text variant="title.small" size="20" lineHeight="28px">
|
|
|
|
{ section.title }
|
|
|
|
</Text>
|
2022-04-13 15:15:05 +00:00
|
|
|
{ ! isComplete && <Badge count={ uncompletedTasksCount } /> }
|
|
|
|
{ isComplete && (
|
2022-04-13 14:20:26 +00:00
|
|
|
<div className="woocommerce-task__icon">
|
|
|
|
<Icon icon={ check } />
|
|
|
|
</div>
|
|
|
|
) }
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|