import React, { useRef, useState } from 'react' import { FaTimes, FaFile, FaEye, FaDownload, FaTrash } from 'react-icons/fa' import { ClassDocumentDto } from '@/proxy/classroom/models' interface DocumentsPanelProps { user: { role: string; name: string } documents: ClassDocumentDto[] onUpload: (file: File) => void onDelete: (id: string) => void onView: (doc: ClassDocumentDto) => void onClose: () => void formatFileSize: (bytes: number) => string getFileIcon: (type: string) => JSX.Element } const DocumentsPanel: React.FC = ({ user, documents, onUpload, onDelete, onView, onClose, formatFileSize, getFileIcon, }) => { const fileInputRef = useRef(null) const [dragOver, setDragOver] = useState(false) const handleDrop = (e: React.DragEvent) => { e.preventDefault() setDragOver(false) if (user.role !== 'teacher') return const files = Array.from(e.dataTransfer.files) files.forEach((file) => onUpload(file)) } const handleFileSelect = (e: React.ChangeEvent) => { if (user.role !== 'teacher') return const files = Array.from(e.target.files || []) files.forEach((file) => onUpload(file)) if (fileInputRef.current) fileInputRef.current.value = '' } return (
{/* Header */}

Sınıf Dokümanları

{/* Content */}
{/* Upload Area (Teacher Only) */} {user.role === 'teacher' && (
{ e.preventDefault() setDragOver(true) }} onDragLeave={() => setDragOver(false)} >

Doküman Yükle

Dosyaları buraya sürükleyin veya seçin

)} {/* Documents List */} {documents.length === 0 ? (

Henüz doküman yüklenmemiş.

) : (
{documents.map((doc) => (
{getFileIcon(doc.type)}

{doc.name}

{formatFileSize(doc.size)} •{' '} {new Date(doc.uploadedAt).toLocaleDateString('tr-TR')}

{doc.uploadedBy}

{user.role === 'teacher' && ( )}
))}
)}
) } export default DocumentsPanel