import { usePDF } from '@/contexts/PDFContext'; import Link from 'next/link'; import { Button, Dialog } from '@headlessui/react'; import { Transition, TransitionChild, DialogPanel, DialogTitle } from '@headlessui/react'; import { Fragment, useState } from 'react'; export function DocumentList() { const { documents, removeDocument, isDocsLoading } = usePDF(); const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); const [documentToDelete, setDocumentToDelete] = useState<{ id: string; name: string } | null>(null); const handleDelete = async () => { if (documentToDelete) { try { await removeDocument(documentToDelete.id); setIsDeleteDialogOpen(false); setDocumentToDelete(null); } catch (err) { console.error('Failed to remove document:', err); } } }; if (isDocsLoading) { return (
Loading documents...
); } if (documents.length === 0) { return (
No documents uploaded yet
); } return (

Your Documents

{documents.map((doc) => (

{doc.name}

{(doc.size / 1024 / 1024).toFixed(2)} MB

))}
setIsDeleteDialogOpen(false)} >
Delete Document

Are you sure you want to delete {documentToDelete?.name}? This action cannot be undone.

); }