Files
flatrender/src/app/[locale]/admin/layout.tsx
T

57 lines
1.9 KiB
TypeScript
Raw Normal View History

import { redirect } from "next/navigation";
import { getTranslations } from "next-intl/server";
import { getCurrentUser } from "@/lib/auth/session";
export const dynamic = "force-dynamic";
export default async function AdminLayout({
children,
}: {
children: React.ReactNode;
}) {
const user = await getCurrentUser();
if (!user || !user.is_admin) {
redirect("/dashboard");
}
const t = await getTranslations("auto.appAdminLayout");
const links: { href: string; label: string }[] = [
{ href: "/admin/categories", label: t("categories") },
{ href: "/admin/templates", label: t("templates") },
{ href: "/admin/tags", label: t("tags") },
{ href: "/admin/fonts", label: t("fonts") },
{ href: "/admin/blogs", label: t("blogs") },
{ href: "/admin/slides", label: t("slides") },
{ href: "/admin/ai", label: t("aiContent") },
{ href: "/admin/users", label: t("users") },
{ href: "/admin/plans", label: t("plans") },
{ href: "/admin/nodes", label: t("nodes") },
{ href: "/admin/renders", label: t("renderQueue") },
];
return (
<div className="min-h-screen bg-[#0c0e1a] text-gray-200">
<nav className="border-b border-[#1e2235] bg-[#0f1120] px-6 py-3">
<div className="mx-auto flex max-w-7xl flex-wrap items-center gap-x-5 gap-y-2">
<span className="text-sm font-semibold text-white">{t("brand")}</span>
{links.map((l) => (
<a
key={l.href}
href={l.href}
className="text-sm text-gray-400 transition-colors hover:text-white"
>
{l.label}
</a>
))}
<a
href="/dashboard"
className="ml-auto text-xs text-gray-500 transition-colors hover:text-gray-300"
>
{t("backToDashboard")}
</a>
</div>
</nav>
<main className="mx-auto max-w-7xl px-6 py-8">{children}</main>
</div>
);
}