54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { CabinetNav } from "@/components/cabinet/CabinetNav";
|
|
import { namedPageMetadata } from "@/lib/page-metadata";
|
|
import { me } from "@/lib/api";
|
|
import { Link } from "@/i18n/routing";
|
|
import { getTranslations, setRequestLocale } from "next-intl/server";
|
|
import type { ReactNode } from "react";
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
}: {
|
|
params: Promise<{ locale: string }>;
|
|
}) {
|
|
const { locale } = await params;
|
|
return namedPageMetadata(locale, "cabinet");
|
|
}
|
|
|
|
export default async function CabinetLayout({
|
|
children,
|
|
params,
|
|
}: {
|
|
children: ReactNode;
|
|
params: Promise<{ locale: string }>;
|
|
}) {
|
|
const { locale } = await params;
|
|
setRequestLocale(locale);
|
|
const t = await getTranslations("cabinet");
|
|
const auth = await getTranslations("auth");
|
|
const user = await me();
|
|
|
|
if (!user) {
|
|
return (
|
|
<div className="mx-auto max-w-xl px-4 py-12 sm:px-6">
|
|
<h1 className="text-3xl font-bold text-[var(--neutral-900)]">{t("title")}</h1>
|
|
<p className="mt-4 text-[var(--text-muted)]">{t("loginHint")}</p>
|
|
<Link href="/login" className="mt-4 inline-block font-semibold text-[var(--brand-700)]">
|
|
{auth("login")}
|
|
</Link>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="mx-auto max-w-6xl px-4 py-12 sm:px-6">
|
|
<h1 className="text-3xl font-bold text-[var(--neutral-900)]">{t("title")}</h1>
|
|
<div className="mt-8 grid gap-8 md:grid-cols-[220px_1fr]">
|
|
<aside>
|
|
<CabinetNav />
|
|
</aside>
|
|
<div>{children}</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|