import { FC } from "react"; import { observer } from "mobx-react"; import Link from "next/link"; import { AlertCircle, X } from "lucide-react"; import { Tooltip } from "@plane/ui"; import { getFileIcon } from "@/components/icons"; import { convertBytesToSize, getFileExtension, getFileName } from "@/helpers/attachment.helper"; import { renderFormattedDate } from "@/helpers/date-time.helper"; import { truncateText } from "@/helpers/string.helper"; import { useIssueDetail, useMember } from "@/hooks/store"; import { usePlatformOS } from "@/hooks/use-platform-os"; // hooks // ui // components // icons // helper import { IssueAttachmentDeleteModal } from "./delete-attachment-confirmation-modal"; // 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(); // states const { isMobile } = usePlatformOS(); const attachment = attachmentId && getAttachmentById(attachmentId); if (!attachment) return <>; return ( <> toggleDeleteAttachmentModal(false)} handleAttachmentOperations={handleAttachmentOperations} data={attachment} />
{getFileIcon(getFileExtension(attachment.asset))}
{truncateText(`${getFileName(attachment.attributes.name)}`, 10)}
{getFileExtension(attachment.asset).toUpperCase()} {convertBytesToSize(attachment.attributes.size)}
{!disabled && ( )}
); });