From 73d1ad34922c0bb1f83613d2137bee472908c428 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Wed, 17 Jun 2026 16:33:01 +0330 Subject: [PATCH] attachments list --- .prettierrc | 4 + src/langs/fa.json | 2 + .../task-detail/TaskDetailModal.tsx | 3 + .../task-detail/attachment/AttachmentItem.tsx | 54 +++++++++++++ .../task-detail/attachment/List.tsx | 75 +++++++++++++++++++ .../task-detail/attachment/types.ts | 4 +- 6 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 .prettierrc create mode 100644 src/pages/taskmanager/components/task-detail/attachment/AttachmentItem.tsx create mode 100644 src/pages/taskmanager/components/task-detail/attachment/List.tsx diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..cdb5e5f --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "printWidth": 200, + "singleAttributePerLine": true +} diff --git a/src/langs/fa.json b/src/langs/fa.json index 9e7dbd0..9c4c615 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -1005,6 +1005,8 @@ "copy_from": "کپی از", "none": "هیچ کدام", "link": "لینک", + "files": "فایل ها", + "links": "لینک ها", "or": "یا", "insert": "درج", "start_date": "تاریخ شروع", diff --git a/src/pages/taskmanager/components/task-detail/TaskDetailModal.tsx b/src/pages/taskmanager/components/task-detail/TaskDetailModal.tsx index bc1e80c..eb39974 100644 --- a/src/pages/taskmanager/components/task-detail/TaskDetailModal.tsx +++ b/src/pages/taskmanager/components/task-detail/TaskDetailModal.tsx @@ -1,6 +1,7 @@ import { type FC, useEffect, useState } from "react"; import DefaulModal from "../../../../components/DefaulModal"; import type { Task } from "../../types"; +import AttachmentList from "./attachment/List"; import CheckLists from "./checklist/List"; import TaskDetailDescription from "./TaskDetailDescription"; import TaskDetailHeader from "./TaskDetailHeader"; @@ -43,6 +44,8 @@ const TaskDetailModal: FC = ({ open, task, statusLabel, onClose }) => { + + ); diff --git a/src/pages/taskmanager/components/task-detail/attachment/AttachmentItem.tsx b/src/pages/taskmanager/components/task-detail/attachment/AttachmentItem.tsx new file mode 100644 index 0000000..9e68fe1 --- /dev/null +++ b/src/pages/taskmanager/components/task-detail/attachment/AttachmentItem.tsx @@ -0,0 +1,54 @@ +import { Popover, PopoverButton, PopoverPanel } from "@headlessui/react"; +import { Document, Link2, More } from "iconsax-react"; +import { type FC } from "react"; +import { timeAgo } from "../../../../../config/func"; + +type Props = { + title: string; + createdAt: string; + type: "file" | "link"; + url?: string; + onEdit: () => void; + onDelete: () => void; +}; + +const AttachmentItem: FC = ({ title, createdAt, type, url, onEdit, onDelete }) => { + return ( +
+
+
+ {type === "file" ? : } +
+ +
+ {type === "link" && url ? ( + + {title} + + ) : ( +
{title}
+ )} +
{timeAgo(createdAt)}
+
+
+ + + + + + + + + + + + +
+ ); +}; + +export default AttachmentItem; diff --git a/src/pages/taskmanager/components/task-detail/attachment/List.tsx b/src/pages/taskmanager/components/task-detail/attachment/List.tsx new file mode 100644 index 0000000..bac3c21 --- /dev/null +++ b/src/pages/taskmanager/components/task-detail/attachment/List.tsx @@ -0,0 +1,75 @@ +import { type FC } from "react"; +import { useTranslation } from "react-i18next"; +import AttachmentItem from "./AttachmentItem"; +import type { TaskAttachment } from "./types"; + +const AttachmentList: FC = () => { + const { t } = useTranslation("global"); + + const attachments: TaskAttachment[] = [ + { + id: "1", + title: "file.pdf", + fileName: "file.pdf", + createdAt: new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString(), + }, + { + id: "2", + title: "لینک طرح", + url: "https://example.com", + createdAt: new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString(), + }, + ]; + + const files = attachments.filter((item) => item.fileName); + const links = attachments.filter((item) => item.url); + + if (attachments.length === 0) return null; + + return ( +
+
{t("taskmanager.task_detail.attachment")}
+ + {files.length > 0 && ( +
+
{t("taskmanager.task_detail.files")}
+ +
+ {files.map((item) => ( + {}} + onDelete={() => {}} + /> + ))} +
+
+ )} + + {links.length > 0 && ( +
+
{t("taskmanager.task_detail.links")}
+ +
+ {links.map((item) => ( + {}} + onDelete={() => {}} + /> + ))} +
+
+ )} +
+ ); +}; + +export default AttachmentList; diff --git a/src/pages/taskmanager/components/task-detail/attachment/types.ts b/src/pages/taskmanager/components/task-detail/attachment/types.ts index ca85638..44c5a16 100644 --- a/src/pages/taskmanager/components/task-detail/attachment/types.ts +++ b/src/pages/taskmanager/components/task-detail/attachment/types.ts @@ -1,6 +1,8 @@ export type TaskAttachment = { id: string; title: string; - linkId: string; + createdAt: string; + linkId?: string; fileName?: string; + url?: string; };