check list
This commit is contained in:
@@ -1,26 +1,31 @@
|
||||
import { Edit } from "iconsax-react";
|
||||
import ProgressBar from "../../../../../components/ProgressBar";
|
||||
import TrashWithConfrim from "../../../../../components/TrashWithConfrim";
|
||||
import type { TaskChecklistType } from "../../../task/types/TaskTypes";
|
||||
import type { TaskChecklistItemType } from "../../../task/types/TaskTypes";
|
||||
import ChecklistItem from "./ChecklistItem";
|
||||
|
||||
type Props = {
|
||||
checklists?: TaskChecklistType[];
|
||||
checkListItems?: TaskChecklistItemType[];
|
||||
checkListItemCount?: number;
|
||||
completedCheckListItemCount?: number;
|
||||
};
|
||||
|
||||
const CheckLists = ({ checklists = [] }: Props) => {
|
||||
const items = checklists.flatMap((checklist) =>
|
||||
checklist.items.map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
checked: item.isDone,
|
||||
})),
|
||||
);
|
||||
const CheckLists = ({
|
||||
checkListItems = [],
|
||||
checkListItemCount,
|
||||
completedCheckListItemCount,
|
||||
}: Props) => {
|
||||
const items = checkListItems.map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
checked: item.isDone,
|
||||
}));
|
||||
|
||||
const doneCount = items.filter((item) => item.checked).length;
|
||||
const progress = items.length > 0 ? Math.round((doneCount / items.length) * 100) : 0;
|
||||
const totalCount = checkListItemCount ?? items.length;
|
||||
const doneCount = completedCheckListItemCount ?? items.filter((item) => item.checked).length;
|
||||
const progress = totalCount > 0 ? Math.round((doneCount / totalCount) * 100) : 0;
|
||||
|
||||
if (checklists.length === 0) return null;
|
||||
if (checkListItems.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div className="mt-6">
|
||||
|
||||
Reference in New Issue
Block a user