Files
descrybe/apps/web/src/lib/admin-nav.ts
T
greeneclipse 8580c996c3 Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
2026-08-09 22:47:43 +02:00

92 lines
2.9 KiB
TypeScript

/** Admin nav IA — single source for shell chrome labels (mobile bar, docs). */
export type AdminNavGroupId =
| "overview"
| "directory"
| "support"
| "ops"
| "commerce"
| "system";
export type AdminNavRoute = {
/** i18n key under `admin.nav.*` */
titleKey: string;
href: string;
group: AdminNavGroupId;
fullAdminOnly?: boolean;
};
export const ADMIN_NAV_ROUTES: readonly AdminNavRoute[] = [
{ titleKey: "admin.nav.commandCenter", href: "/admin", group: "overview" },
{ titleKey: "admin.nav.analytics", href: "/admin/analytics", group: "overview", fullAdminOnly: true },
{ titleKey: "admin.nav.usersOrgs", href: "/admin/users", group: "directory", fullAdminOnly: true },
{ titleKey: "admin.nav.tickets", href: "/admin/support", group: "support" },
{
titleKey: "admin.nav.knowledge",
href: "/admin/support/knowledge",
group: "support",
fullAdminOnly: true
},
{
titleKey: "admin.nav.diagnostics",
href: "/admin/diagnostics",
group: "ops",
fullAdminOnly: true
},
{
titleKey: "admin.nav.stuckProducts",
href: "/admin/stuck-products",
group: "ops",
fullAdminOnly: true
},
{
titleKey: "admin.nav.orphanProcessed",
href: "/admin/orphan-processed",
group: "ops",
fullAdminOnly: true
},
{
titleKey: "admin.nav.storeReconnect",
href: "/admin/store-reconnect",
group: "ops",
fullAdminOnly: true
},
{ titleKey: "admin.nav.billing", href: "/admin/billing", group: "commerce", fullAdminOnly: true },
{ titleKey: "admin.nav.sales", href: "/admin/sales", group: "commerce", fullAdminOnly: true },
{
titleKey: "admin.nav.translations",
href: "/admin/translations",
group: "system",
fullAdminOnly: true
},
{ titleKey: "admin.nav.settings", href: "/admin/settings", group: "system", fullAdminOnly: true }
] as const;
/** Matches AdminNav aside width (`w-[15.5rem]`). */
export const ADMIN_SIDEBAR_WIDTH_CLASS = "lg:ml-[15.5rem]";
export const ADMIN_NAV_SECTIONS: { id: AdminNavGroupId; labelKey: string }[] = [
{ id: "overview", labelKey: "admin.nav.section.overview" },
{ id: "directory", labelKey: "admin.nav.section.directory" },
{ id: "support", labelKey: "admin.nav.section.support" },
{ id: "ops", labelKey: "admin.nav.section.ops" },
{ id: "commerce", labelKey: "admin.nav.section.commerce" },
{ id: "system", labelKey: "admin.nav.section.system" }
];
export function adminNavIsActive(href: string, pathname: string): boolean {
if (href === "/admin") return pathname === "/admin";
if (href === "/admin/support") {
return (
pathname === "/admin/support" ||
(pathname.startsWith("/admin/support/") && !pathname.startsWith("/admin/support/knowledge"))
);
}
return pathname === href || pathname.startsWith(`${href}/`);
}
/** Message key for the current admin page title (resolve with i18n.t). */
export function adminPageTitleKey(pathname: string): string {
const match = ADMIN_NAV_ROUTES.find((item) => adminNavIsActive(item.href, pathname));
return match?.titleKey ?? "admin.chrome.platformOps";
}