mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-17 03:19:59 +03:00
d311a53b6f
# Description - add crown on premium user - link to manage plan in page `/user` ## ⚠️ Before merging Setup env variable: ```env NEXT_PUBLIC_STRIPE_MANAGE_PLAN_URL=<ignore-me-or-change-me> ``` ## Screenshots (if appropriate): <img width="290" alt="image" src="https://github.com/StanGirard/quivr/assets/67386567/a87b0f7e-b07c-4f4e-b9d2-515ac25ebf05"> <img width="318" alt="image" src="https://github.com/StanGirard/quivr/assets/67386567/6a4f4f72-8c75-45da-9468-cae1a8d28935">
89 lines
2.5 KiB
TypeScript
89 lines
2.5 KiB
TypeScript
"use client";
|
|
import Link from "next/link";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import Button from "@/lib/components/ui/Button";
|
|
import Card, { CardBody, CardHeader } from "@/lib/components/ui/Card";
|
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
|
import { redirectToLogin } from "@/lib/router/redirectToLogin";
|
|
|
|
import { StripePricingOrManageButton, UserStatistics } from "./components";
|
|
import { ApiKeyConfig } from "./components/ApiKeyConfig";
|
|
import LanguageSelect from "./components/LanguageDropDown/LanguageSelect";
|
|
import ThemeSelect from "./components/ThemeSelect/ThemeSelect";
|
|
|
|
const UserPage = (): JSX.Element => {
|
|
const { session } = useSupabase();
|
|
|
|
if (!session) {
|
|
redirectToLogin();
|
|
}
|
|
|
|
const { user } = session;
|
|
const { t } = useTranslation(["translation", "user", "config"]);
|
|
|
|
return (
|
|
<main className="container lg:w-2/3 mx-auto py-10 px-5">
|
|
<Card className="mb-5 shadow-sm hover:shadow-none">
|
|
<CardHeader>
|
|
<h2 className="font-bold text-xl">
|
|
{t("accountSection", { ns: "config" })}
|
|
</h2>
|
|
</CardHeader>
|
|
|
|
<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>
|
|
<Link href={"/logout"}>
|
|
<Button className="px-3 py-2" variant="secondary">
|
|
{t("logoutButton")}
|
|
</Button>
|
|
</Link>
|
|
</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>
|
|
|
|
<CardBody>
|
|
<LanguageSelect />
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<CardBody className="p-3 flex flex-col">
|
|
<ApiKeyConfig />
|
|
</CardBody>
|
|
</Card>
|
|
</main>
|
|
);
|
|
};
|
|
|
|
export default UserPage;
|