"use client"; import React, { useState, useRef } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { FileInfo, FileUploadConfig } from "./types"; import { Upload, Download, Trash2, Eye, File, FileText, Image as ImageIcon, Video, Music, Archive, Presentation, X, Star } from "lucide-react"; import { formatFileSize } from "@/lib/utils"; import { FileViewerModal } from "./FileViewerModal"; interface FileManagerModalProps { isOpen: boolean; onClose: () => void; uploadedFiles: FileInfo[]; onFileUpload: (files: File[]) => Promise; onFileDownload: (file: FileInfo) => void; onFileDelete: (file: FileInfo) => void; onFileView: (file: FileInfo) => void; onSetRepresentative?: (file: FileInfo) => void; // 대표 이미지 설정 콜백 config: FileUploadConfig; isDesignMode?: boolean; } export const FileManagerModal: React.FC = ({ isOpen, onClose, uploadedFiles, onFileUpload, onFileDownload, onFileDelete, onFileView, onSetRepresentative, config, isDesignMode = false, }) => { const [dragOver, setDragOver] = useState(false); const [uploading, setUploading] = useState(false); const [viewerFile, setViewerFile] = useState(null); const [isViewerOpen, setIsViewerOpen] = useState(false); const [selectedFile, setSelectedFile] = useState(null); // 선택된 파일 (좌측 미리보기용) const [previewImageUrl, setPreviewImageUrl] = useState(null); // 이미지 미리보기 URL const fileInputRef = useRef(null); // 파일 아이콘 가져오기 const getFileIcon = (fileExt: string) => { const ext = fileExt.toLowerCase(); if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'].includes(ext)) { return ; } else if (['pdf', 'doc', 'docx', 'txt', 'rtf'].includes(ext)) { return ; } else if (['xls', 'xlsx', 'csv'].includes(ext)) { return ; } else if (['ppt', 'pptx'].includes(ext)) { return ; } else if (['mp4', 'avi', 'mov', 'webm'].includes(ext)) { return