mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-17 15:41:50 +03:00
9b163e5b65
* refactor: update uploadPage structure * feat: show upload component from chatbar * refactor: move <Feed/> from upload page to chat page
80 lines
2.4 KiB
TypeScript
80 lines
2.4 KiB
TypeScript
"use client";
|
|
import Link from "next/link";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
import { Divider } from "@/lib/components/ui/Divider";
|
|
import PageHeading from "@/lib/components/ui/PageHeading";
|
|
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
|
import { redirectToLogin } from "@/lib/router/redirectToLogin";
|
|
|
|
import { requiredRolesForUpload } from "./config";
|
|
import {
|
|
Crawler,
|
|
FileUploader,
|
|
} from "../chat/[chatId]/components/ActionsBar/components/Feed/components";
|
|
|
|
const UploadPage = (): JSX.Element => {
|
|
const { currentBrain } = useBrainContext();
|
|
const { session } = useSupabase();
|
|
const { t } = useTranslation(["translation", "upload"]);
|
|
|
|
if (session === null) {
|
|
redirectToLogin();
|
|
}
|
|
|
|
if (currentBrain === undefined) {
|
|
return (
|
|
<div className="flex justify-center items-center mt-5">
|
|
<div className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative max-w-md">
|
|
<strong className="font-bold mr-1">
|
|
{t("ohNo", { ns: "upload" })}
|
|
</strong>
|
|
<span className="block sm:inline">
|
|
{t("selectBrainFirst", { ns: "upload" })}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const hasUploadRights = requiredRolesForUpload.includes(currentBrain.role);
|
|
|
|
if (!hasUploadRights) {
|
|
return (
|
|
<div className="flex justify-center items-center mt-5">
|
|
<div className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative max-w-md">
|
|
<strong className="font-bold mr-1">
|
|
{t("ohNo", { ns: "upload" })}
|
|
</strong>
|
|
<span className="block sm:inline">
|
|
{t("missingNecessaryRole", { ns: "upload" })}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<main className="pt-10">
|
|
<PageHeading
|
|
title={t("title", { ns: "upload" })}
|
|
subtitle={t("subtitle", { ns: "upload" })}
|
|
/>
|
|
<FileUploader />
|
|
<Divider text={t("or")} className="m-5" />
|
|
<Crawler />
|
|
<div className="flex flex-col items-center justify-center gap-5 mt-5">
|
|
<Link href={"/chat"}>
|
|
<Button variant={"secondary"} className="py-3">
|
|
{t("chatButton")}
|
|
</Button>
|
|
</Link>
|
|
</div>
|
|
</main>
|
|
);
|
|
};
|
|
|
|
export default UploadPage;
|