'use client'; import { useState, useEffect } from 'react'; import axios from 'axios'; import DocumentItem from './documentItem'; interface Document { name: string; size: string; } export default function ExplorePage() { const [documents, setDocuments] = useState([]); const [selectedDocument, setSelectedDocument] = useState(null); useEffect(() => { fetchDocuments(); }, []); const fetchDocuments = async () => { try { const response = await axios.get<{ documents: Document[] }>('http://localhost:5000/explore'); setDocuments(response.data.documents); } catch (error) { console.error('Error fetching documents', error); setDocuments([]); } }; const viewDocument = (document: Document) => { setSelectedDocument(document); }; return (

Explore Files

{documents.map((document, index) => ( ))}
{selectedDocument && (

{selectedDocument.name}

{JSON.stringify(selectedDocument, null, 2)}
)}
); }