import * as React from "react"; import { Flex, Icon } from "@siteground/styleguide"; import Text from "@siteground/styleguide/lib/components/text/text"; import { useGetImage } from "@/chat/hooks/use-get-image"; import { DeletedMediaChip } from "./deleted-media-chip"; import { getFileDisplayName } from "@/chat/utils/file-type-utils"; import { bytesToMegabytes } from "@/chat/components/chat-message-files/utils"; interface FileItemProps { fileUrl: string; fileName: string; mimeType: string; fileSize: number; renderDeleted?: boolean; } export const FileItem: React.FC = ({ fileUrl, fileName, mimeType, fileSize, renderDeleted = false }) => { const { image, isLoading } = useGetImage(fileUrl); if (isLoading) return null; if (!image) { return renderDeleted ? : null; } if (renderDeleted) { return null; } const fileType = getFileDisplayName(mimeType, fileName); const fileSizeMB = bytesToMegabytes(fileSize); return (
{fileName} {fileType} {fileSizeMB}MB
); };