2026-06-01 13:42:30 +03:30
|
|
|
import { redirect } from "next/navigation";
|
2026-06-02 09:35:14 +03:30
|
|
|
import { getTranslations } from "next-intl/server";
|
2026-06-01 13:42:30 +03:30
|
|
|
|
2026-06-03 07:56:54 +03:30
|
|
|
import { AdminShell, type NavGroup } from "@/components/admin/AdminShell";
|
2026-06-01 13:42:30 +03:30
|
|
|
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");
|
|
|
|
|
}
|
2026-06-02 09:35:14 +03:30
|
|
|
const t = await getTranslations("auto.appAdminLayout");
|
2026-06-03 07:56:54 +03:30
|
|
|
|
|
|
|
|
const groups: NavGroup[] = [
|
|
|
|
|
{
|
|
|
|
|
title: "نمای کلی",
|
|
|
|
|
items: [{ href: "/admin/stats", label: t("stats") }],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "محتوا",
|
|
|
|
|
items: [
|
|
|
|
|
{ href: "/admin/categories", label: t("categories") },
|
|
|
|
|
{ href: "/admin/templates", label: t("templates") },
|
|
|
|
|
{ href: "/admin/projects", label: t("projects") },
|
|
|
|
|
{ href: "/admin/ranking", label: t("ranking") },
|
|
|
|
|
{ href: "/admin/tags", label: t("tags") },
|
|
|
|
|
{ href: "/admin/fonts", label: t("fonts") },
|
|
|
|
|
{ href: "/admin/music", label: t("music") },
|
|
|
|
|
{ href: "/admin/blogs", label: t("blogs") },
|
2026-06-11 22:43:25 +03:30
|
|
|
{ href: "/admin/learn", label: t("learn") },
|
|
|
|
|
{ href: "/admin/pages", label: t("pages") },
|
2026-06-03 07:56:54 +03:30
|
|
|
{ href: "/admin/slides", label: t("slides") },
|
|
|
|
|
{ href: "/admin/home-events", label: t("homeEvents") },
|
|
|
|
|
{ href: "/admin/routes", label: t("routes") },
|
|
|
|
|
{ href: "/admin/comments", label: t("comments") },
|
|
|
|
|
{ href: "/admin/files", label: t("media") },
|
|
|
|
|
{ href: "/admin/ai", label: t("aiContent") },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "رشد و ارتباطات",
|
|
|
|
|
items: [
|
|
|
|
|
{ href: "/admin/messaging", label: t("messaging") },
|
|
|
|
|
{ href: "/admin/integrations", label: t("integrations") },
|
|
|
|
|
{ href: "/admin/marketing", label: t("marketing") },
|
|
|
|
|
{ href: "/admin/crm", label: t("crm") },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "کاربران و مالی",
|
|
|
|
|
items: [
|
|
|
|
|
{ href: "/admin/users", label: t("users") },
|
|
|
|
|
{ href: "/admin/plans", label: t("plans") },
|
|
|
|
|
{ href: "/admin/discounts", label: t("discounts") },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "فارم رندر",
|
|
|
|
|
items: [
|
|
|
|
|
{ href: "/admin/nodes", label: t("nodes") },
|
|
|
|
|
{ href: "/admin/node-fonts", label: t("nodeFonts") },
|
|
|
|
|
{ href: "/admin/renders", label: t("renderQueue") },
|
|
|
|
|
{ href: "/admin/exports", label: t("exports") },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "سیستم",
|
|
|
|
|
items: [{ href: "/admin/settings", label: t("siteSettings") }],
|
|
|
|
|
},
|
2026-06-02 09:35:14 +03:30
|
|
|
];
|
2026-06-03 07:56:54 +03:30
|
|
|
|
2026-06-05 00:34:25 +03:30
|
|
|
const email = user.email ?? "";
|
|
|
|
|
const fullName = typeof user.full_name === "string" ? user.full_name.trim() : "";
|
|
|
|
|
|
2026-06-01 13:42:30 +03:30
|
|
|
return (
|
2026-06-05 00:34:25 +03:30
|
|
|
<AdminShell
|
|
|
|
|
groups={groups}
|
|
|
|
|
brand={t("brand")}
|
|
|
|
|
back={t("backToDashboard")}
|
|
|
|
|
user={{
|
|
|
|
|
name: fullName || (email ? email.split("@")[0] : "Admin"),
|
|
|
|
|
email,
|
|
|
|
|
avatarUrl: (user.avatar_url as string | null) ?? null,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-06-03 07:56:54 +03:30
|
|
|
{children}
|
|
|
|
|
</AdminShell>
|
2026-06-01 13:42:30 +03:30
|
|
|
);
|
|
|
|
|
}
|