quivr/frontend/app/explore/page.tsx

58 lines
2.1 KiB
TypeScript
Raw Normal View History

New Webapp migration (#56) * feat(v2): loaders added * feature: Add scroll animations * feature: upload ui * feature: upload multiple files * fix: Same file name and size remove * feat(crawler): added * feat(parsers): v2 added more * feat(v2): audio now working * feat(v2): all loaders * feat(v2): explorer * chore: add links * feat(api): added status in return message * refactor(website): remove old code * feat(upload): return type for messages * feature: redirect to upload if ENV=local * fix(chat): fixed some issues * feature: respect response type * loading state * feature: Loading stat * feat(v2): added explore and chat pages * feature: modal settings * style: Chat UI * feature: scroll to bottom when chatting * feature: smooth scroll in chat * feature(anim): Slide chat in * feature: markdown chat * feat(explorer): list * feat(doc): added document item * feat(explore): added modal * Add clarification on Project API keys and web interface for migration scripts to Readme (#58) * fix(demo): changed link * add support to uploading zip file (#62) * Catch UnicodeEncodeError exception (#64) * feature: fixed chatbar * fix(loaders): missing argument * fix: layout * fix: One whole chatbox * fix: Scroll into view * fix(build): vercel issues * chore(streamlit): moved to own file * refactor(api): moved to backend folder * feat(docker): added docker compose * Fix a bug where langchain memories were not being cleaned (#71) * Update README.md (#70) * chore(streamlit): moved to own file * refactor(api): moved to backend folder * docs(readme): updated for new version * docs(readme): added old readme * docs(readme): update copy dot env file * docs(readme): cleanup --------- Co-authored-by: iMADi-ARCH <nandanaditya985@gmail.com> Co-authored-by: Matt LeBel <github@lebel.io> Co-authored-by: Evan Carlson <45178375+EvanCarlson@users.noreply.github.com> Co-authored-by: Mustafa Hasan Khan <65130881+mustafahasankhan@users.noreply.github.com> Co-authored-by: zhulixi <48713110+zlxxlz1026@users.noreply.github.com> Co-authored-by: Stanisław Tuszyński <stanislaw@tuszynski.me>
2023-05-21 02:20:55 +03:00
'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<Document[]>([]);
const [selectedDocument, setSelectedDocument] = useState<Document | null>(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 (
<div className="pt-20 flex flex-col items-center justify-center p-6">
<h1 className="text-4xl mb-6">Explore Files</h1>
<div className="overflow-y-auto h-[50vh] w-full max-w-xl">
{documents.map((document, index) => (
<DocumentItem key={index} document={document} viewDocument={viewDocument} />
))}
</div>
{selectedDocument && (
<div className="fixed inset-0 flex items-center justify-center z-10 bg-black bg-opacity-50">
<div className="bg-white p-6 w-1/2 h-1/2 overflow-auto rounded-lg">
<h2 className="text-2xl mb-4">{selectedDocument.name}</h2>
<pre>{JSON.stringify(selectedDocument, null, 2)}</pre>
<button
onClick={() => setSelectedDocument(null)}
className="mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-200"
>
Close
</button>
</div>
</div>
)}
</div>
);
}