import { FC } from "react"; import { observer } from "mobx-react"; import Link from "next/link"; import { AlertCircle, X } from "lucide-react"; // ui import { Tooltip } from "@plane/ui"; // icons import { getFileIcon } from "@/components/icons"; // components import { IssueAttachmentDeleteModal } from "@/components/issues"; // helpers import { convertBytesToSize, getFileExtension, getFileName } from "@/helpers/attachment.helper"; import { renderFormattedDate } from "@/helpers/date-time.helper"; import { truncateText } from "@/helpers/string.helper"; // hooks import { useIssueDetail, useMember } from "@/hooks/store"; import { usePlatformOS } from "@/hooks/use-platform-os"; // types import { TAttachmentOperations } from "./root"; type TAttachmentOperationsRemoveModal = Exclude; type TIssueAttachmentsDetail = { attachmentId: string; handleAttachmentOperations: TAttachmentOperationsRemoveModal; disabled?: boolean; }; export const IssueAttachmentsDetail: FC = observer((props) => { // props const { attachmentId, handleAttachmentOperations, disabled } = props; // store hooks const { getUserDetails } = useMember(); const { attachment: { getAttachmentById }, isDeleteAttachmentModalOpen, toggleDeleteAttachmentModal, } = useIssueDetail(); // derived values const attachment = attachmentId ? getAttachmentById(attachmentId) : undefined; // hooks const { isMobile } = usePlatformOS(); if (!attachment) return <>; return ( <> {isDeleteAttachmentModalOpen === attachment.id && ( toggleDeleteAttachmentModal(null)} handleAttachmentOperations={handleAttachmentOperations} data={attachment} /> )}
{getFileIcon(getFileExtension(attachment.asset))}
{truncateText(`${getFileName(attachment.attributes.name)}`, 10)}
{getFileExtension(attachment.asset).toUpperCase()} {convertBytesToSize(attachment.attributes.size)}
{!disabled && ( )}
); });