import Link from 'next/link'; import { DragEvent, useState } from 'react'; import { useRouter } from 'next/navigation'; import { Button } from '@headlessui/react'; import { PDFIcon, EPUBIcon, FileIcon } from '@/components/icons/Icons'; import { DocumentListDocument } from '@/types/documents'; import { DocumentPreview } from '@/components/doclist/DocumentPreview'; interface DocumentListItemProps { doc: DocumentListDocument; onDelete: (doc: DocumentListDocument) => void; dragEnabled?: boolean; onDragStart?: (doc: DocumentListDocument) => void; onDragEnd?: () => void; onDragOver?: (e: DragEvent, doc: DocumentListDocument) => void; onDragLeave?: () => void; onDrop?: (e: DragEvent, doc: DocumentListDocument) => void; isDropTarget?: boolean; viewMode: 'list' | 'grid'; } export function DocumentListItem({ doc, onDelete, dragEnabled = true, onDragStart, onDragEnd, onDragOver, onDragLeave, onDrop, isDropTarget = false, viewMode, }: DocumentListItemProps) { const [loading, setLoading] = useState(false); const router = useRouter(); // Only allow drag and drop interactions for documents not in folders const isDraggable = dragEnabled && !doc.folderId; const allowDropTarget = !doc.folderId; const handleDocumentClick = (e: React.MouseEvent) => { e.preventDefault(); setLoading(true); router.push(`/${doc.type}/${encodeURIComponent(doc.id)}`); }; return (
{doc.name}
{(doc.size / 1024 / 1024).toFixed(2)} MB
{doc.name}
{(doc.size / 1024 / 1024).toFixed(2)} MB