mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-16 18:52:12 +03:00
b0514d6149
* add libraries for traslation purposes * Add button and service for language selection * add spanish translation on login page * add spanish translation on upload page * Add spanish translations for explore page * Add translations on user page * Add translations for config page * Add spanish translations on chat page * add translations for brain page * fix GUI and save on local storage * fix (i18n) init and types * fix (i18n): typos * add translation on new brain modal * add translations on metadata * Add translations on home page * fixes types * fix(frontend-tests): use get by id instead of text --------- Co-authored-by: Gustavo Maciel <gustavo_m13@outlook.com>
74 lines
2.4 KiB
TypeScript
74 lines
2.4 KiB
TypeScript
"use client";
|
|
import { AnimatePresence, motion } from "framer-motion";
|
|
import Link from "next/link";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
import Spinner from "@/lib/components/ui/Spinner";
|
|
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
|
|
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 {t} = useTranslation(["translation","explore"]);
|
|
const { session } = useSupabase();
|
|
const { documents, setDocuments, isPending } = useExplore();
|
|
const { currentBrain } = useBrainContext();
|
|
if (session === null) {
|
|
redirectToLogin();
|
|
}
|
|
if (currentBrain === undefined) {
|
|
return (
|
|
<div className="flex flex-col items-center justify-center mt-10 gap-1">
|
|
<p className="text-center">
|
|
{"You need to select a brain first. 🧠💡🥲"}
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
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">
|
|
{t("title",{ns:"explore"})}
|
|
</h1>
|
|
<h2 className="opacity-50">
|
|
{t("subtitle",{ns:"explore"})}
|
|
</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">{t("empty",{ns:"explore"})}</p>
|
|
<Link href="/upload">
|
|
<Button>{t("uploadButton")}</Button>
|
|
</Link>
|
|
</div>
|
|
)}
|
|
</motion.div>
|
|
)}
|
|
</section>
|
|
</main>
|
|
);
|
|
};
|
|
|
|
export default ExplorePage;
|