mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-23 23:22:15 +03:00
bd0aa01ba1
* feat: add redirectToLogin helper * feat: use redirectToLogin instead of redirect('login') * feat: redirect to initial targeted page after login
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
/* eslint-disable */
|
|
"use client";
|
|
import { AnimatePresence, motion } from "framer-motion";
|
|
import Link from "next/link";
|
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
import Spinner from "@/lib/components/ui/Spinner";
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
|
|
|
import { redirectToLogin } from "@/lib/router/redirectToLogin";
|
|
import DocumentItem from "./DocumentItem";
|
|
import { useExplore } from "./hooks/useExplore";
|
|
|
|
const ExplorePage = (): JSX.Element => {
|
|
const { session } = useSupabase();
|
|
const { documents, setDocuments, isPending } = useExplore();
|
|
if (session === null) {
|
|
redirectToLogin();
|
|
}
|
|
|
|
return (
|
|
<main>
|
|
<section className="w-full outline-none pt-10 flex flex-col gap-5 items-center justify-center p-6">
|
|
<div className="flex flex-col items-center justify-center">
|
|
<h1 className="text-3xl font-bold text-center">
|
|
Explore uploaded data
|
|
</h1>
|
|
<h2 className="opacity-50">
|
|
View or delete stored data used by your brain
|
|
</h2>
|
|
</div>
|
|
{isPending ? (
|
|
<Spinner />
|
|
) : (
|
|
<motion.div layout className="w-full max-w-xl flex flex-col gap-5">
|
|
{documents.length !== 0 ? (
|
|
<AnimatePresence mode="popLayout">
|
|
{documents.map((document) => (
|
|
<DocumentItem
|
|
key={document.name}
|
|
document={document}
|
|
setDocuments={setDocuments}
|
|
/>
|
|
))}
|
|
</AnimatePresence>
|
|
) : (
|
|
<div className="flex flex-col items-center justify-center mt-10 gap-1">
|
|
<p className="text-center">Oh No, Your Brain is empty.</p>
|
|
<Link href="/upload">
|
|
<Button>Upload</Button>
|
|
</Link>
|
|
</div>
|
|
)}
|
|
</motion.div>
|
|
)}
|
|
</section>
|
|
</main>
|
|
);
|
|
};
|
|
|
|
export default ExplorePage;
|