check list

This commit is contained in:
hamid zarghami
2026-07-12 11:56:46 +03:30
parent 61282e1d1b
commit 50d4ff9281
10 changed files with 97 additions and 71 deletions
@@ -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">