import { useRef, useState } from "react"; import { toast } from "sonner"; import { Eye, Download, Trash2, FileText, Image as ImageIcon } from "lucide-react"; import type { Attachment } from "../lib/types"; import { FilePreviewModal, isImageFile, isPdfFile } from "./FilePreviewModal"; export interface FileListProps { files: Attachment[]; onChange: (files: Attachment[]) => void; // آپلود واقعی هر فایل به سرور (باید Attachment با id برگرداند) upload: (file: File) => Promise; // حذف سمت سرور (اختیاری — بعد از حذف محلی صدا زده می‌شود) onDelete?: (a: Attachment) => void; // دانلود احراز هویت‌شده (توکن Bearer + blob — لینک خام توکن نمی‌فرستد) onDownload?: (a: Attachment) => void | Promise; // آدرس blob احراز هویت‌شده برای پیش‌نمایش. مودال پیش‌نمایش با objectURL // محلی کار می‌کند چون /