quivr/frontend/app/explore/DocumentItem/DocumentData.tsx
!MAD! e4217fe15f
Mad/UI improvements in /explore (#127)
* feature: delete file

* feature: consume /explore/file_name to view details of an uploaded document

* feature: optimistic update when deleting file

* feature: Loading state for /explore

* style: Exit animation

* style: responsive card
2023-05-23 08:15:13 +02:00

38 lines
1.1 KiB
TypeScript

import axios from "axios";
import { Document } from "../types";
interface DocumentDataProps {
documentName: string;
}
const DocumentData = async ({ documentName }: DocumentDataProps) => {
const res = await axios.get(
`${process.env.NEXT_PUBLIC_BACKEND_URL}/explore/${documentName}`
);
const documents = res.data.documents as any[];
const doc = documents[0];
return (
<div className="prose">
<p>No. of documents: {documents.length}</p>
{/* {documents.map((doc) => (
<pre key={doc.name}>{JSON.stringify(doc)}</pre>
))} */}
<div className="flex flex-col gap-2">
{documents[0] &&
Object.keys(documents[0]).map((k) => {
return (
<div className="grid grid-cols-2 border-b py-2" key={k}>
<span className="capitalize font-bold">
{k.replaceAll("_", " ")}
</span>
<span className="">{documents[0][k] || "Not Available"}</span>
</div>
);
})}
</div>
</div>
);
};
export default DocumentData;