2023-06-05 18:58:59 +03:00
|
|
|
"use client";
|
2023-10-05 18:50:02 +03:00
|
|
|
import Link from "next/link";
|
2023-08-07 15:13:41 +03:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-06-15 12:52:46 +03:00
|
|
|
|
2023-10-05 18:50:02 +03:00
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
|
|
import Card, { CardBody, CardHeader } from "@/lib/components/ui/Card";
|
2023-06-20 17:17:13 +03:00
|
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
2023-07-13 19:05:08 +03:00
|
|
|
import { redirectToLogin } from "@/lib/router/redirectToLogin";
|
2023-09-26 19:26:19 +03:00
|
|
|
|
2023-10-25 17:11:17 +03:00
|
|
|
import { StripePricingOrManageButton, UserStatistics } from "./components";
|
2023-10-05 18:50:02 +03:00
|
|
|
import { ApiKeyConfig } from "./components/ApiKeyConfig";
|
2023-12-13 10:54:35 +03:00
|
|
|
import LanguageSelect from "./components/LanguageSelect/LanguageSelect";
|
2023-10-30 16:52:47 +03:00
|
|
|
import { LogoutModal } from "./components/LogoutCard/LogoutModal";
|
2023-10-05 18:50:02 +03:00
|
|
|
import ThemeSelect from "./components/ThemeSelect/ThemeSelect";
|
2023-06-05 18:58:59 +03:00
|
|
|
|
2023-06-15 12:52:46 +03:00
|
|
|
const UserPage = (): JSX.Element => {
|
2023-06-05 18:58:59 +03:00
|
|
|
const { session } = useSupabase();
|
2023-07-13 19:05:08 +03:00
|
|
|
|
2023-10-05 18:50:02 +03:00
|
|
|
if (!session) {
|
2023-07-13 19:05:08 +03:00
|
|
|
redirectToLogin();
|
2023-06-05 18:58:59 +03:00
|
|
|
}
|
|
|
|
|
2023-10-05 18:50:02 +03:00
|
|
|
const { user } = session;
|
2023-10-26 19:23:36 +03:00
|
|
|
const { t } = useTranslation(["translation", "user", "config", "chat"]);
|
2023-10-05 18:50:02 +03:00
|
|
|
|
2023-06-05 18:58:59 +03:00
|
|
|
return (
|
2023-10-26 19:23:36 +03:00
|
|
|
<>
|
|
|
|
<main className="container lg:w-2/3 mx-auto py-10 px-5">
|
2024-01-20 07:34:30 +03:00
|
|
|
<Link href="/search">
|
2023-10-26 19:23:36 +03:00
|
|
|
<Button className="mb-5" variant="primary">
|
2024-01-20 07:34:30 +03:00
|
|
|
{t("chat:back_to_search")}
|
2023-10-26 19:23:36 +03:00
|
|
|
</Button>
|
|
|
|
</Link>
|
|
|
|
<Card className="mb-5 shadow-sm hover:shadow-none">
|
|
|
|
<CardHeader>
|
|
|
|
<h2 className="font-bold text-xl">
|
|
|
|
{t("accountSection", { ns: "config" })}
|
|
|
|
</h2>
|
|
|
|
</CardHeader>
|
2023-10-05 18:50:02 +03:00
|
|
|
|
2023-10-26 19:23:36 +03:00
|
|
|
<CardBody className="flex flex-col items-stretch max-w-max gap-2">
|
|
|
|
<div className="flex gap-5 items-center">
|
|
|
|
<p>
|
|
|
|
<strong>{t("email")}:</strong> <span>{user.email}</span>
|
|
|
|
</p>
|
2023-10-30 16:52:47 +03:00
|
|
|
|
|
|
|
<LogoutModal />
|
2023-10-26 19:23:36 +03:00
|
|
|
</div>
|
|
|
|
<StripePricingOrManageButton />
|
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
<Card className="mb-5 shadow-sm hover:shadow-none">
|
|
|
|
<CardHeader>
|
|
|
|
<h2 className="font-bold text-xl">
|
|
|
|
{t("settings", { ns: "config" })}
|
|
|
|
</h2>
|
|
|
|
</CardHeader>
|
2023-10-05 18:50:02 +03:00
|
|
|
|
2023-10-26 19:23:36 +03:00
|
|
|
<CardBody>
|
|
|
|
<LanguageSelect />
|
2023-10-05 18:50:02 +03:00
|
|
|
|
2023-10-26 19:23:36 +03:00
|
|
|
<ThemeSelect />
|
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
<Card className="mb-5 shadow-sm hover:shadow-none">
|
|
|
|
<CardHeader>
|
|
|
|
<h2 className="font-bold text-xl">
|
|
|
|
{t("brainUsage", { ns: "user" })}
|
|
|
|
</h2>
|
|
|
|
</CardHeader>
|
2023-10-05 18:50:02 +03:00
|
|
|
|
2023-10-26 19:23:36 +03:00
|
|
|
<CardBody>
|
|
|
|
<UserStatistics />
|
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
<Card className="mb-5 shadow-sm hover:shadow-none">
|
|
|
|
<CardHeader>
|
|
|
|
<h2 className="font-bold text-xl">
|
|
|
|
{t("apiKey", { ns: "config" })}
|
|
|
|
</h2>
|
|
|
|
</CardHeader>
|
2023-10-05 18:50:02 +03:00
|
|
|
|
2023-10-26 19:23:36 +03:00
|
|
|
<CardBody className="p-3 flex flex-col">
|
|
|
|
<ApiKeyConfig />
|
|
|
|
</CardBody>
|
|
|
|
</Card>
|
|
|
|
</main>
|
|
|
|
</>
|
2023-06-05 18:58:59 +03:00
|
|
|
);
|
2023-06-15 12:52:46 +03:00
|
|
|
};
|
2023-10-05 18:50:02 +03:00
|
|
|
|
2023-06-15 12:52:46 +03:00
|
|
|
export default UserPage;
|