"use client"; import { memo } from "react"; import { IconFile, IconX } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; import { formatBytes, type FileAttachment } from "./file-attachment"; type FileAttachmentPreviewProps = { attachments: FileAttachment[]; onRemove: (id: string) => void; disabled?: boolean; }; export const FileAttachmentPreview = memo(function FileAttachmentPreview({ attachments, onRemove, disabled = false, }: FileAttachmentPreviewProps) { if (attachments.length === 0) return null; return (
{attachments.map((attachment) => (
{attachment.isImage && attachment.preview ? ( /* eslint-disable-next-line @next/next/no-img-element -- base64/blob preview URLs are not compatible with next/image */ Attachment preview ) : (
{attachment.fileName} {formatBytes(attachment.size)}
)} {!disabled && ( )}
))}
); });