Files
sass-mohfarawati/lib/admin-navigation.ts
T

150 lines
3.9 KiB
TypeScript

import {
FolderKanban,
Globe2,
ImageIcon,
Languages,
LayoutDashboard,
Mail,
Palette,
PlusSquare,
ShieldAlert,
SwatchBook,
Tags,
Type,
type LucideIcon,
} from "lucide-react";
import { getAdminAppPath } from "@/lib/admin-routing";
type AdminNavigationCopy = {
overview: string;
maintenance: string;
uiKit: string;
portfolio: string;
media: string;
siteSettings: string;
brandSettings?: string;
localizationSettings?: string;
marquee?: string;
smtp?: string;
contactProtection?: string;
};
export type AdminNavItem = {
label: string;
href: string;
icon: LucideIcon;
active?: boolean;
expanded?: boolean;
children?: AdminNavItem[];
};
export function getAdminNavigation(
copy: AdminNavigationCopy,
active: "overview" | "maintenance" | "ui-kit" | "portfolio" | "media" | "site-settings" | "smtp" | "marquee",
smtpChild?: "settings" | "contact-protection",
portfolioChild?: "overview" | "projects" | "new-project" | "categories",
siteSettingsChild?: "brand" | "localization",
): AdminNavItem[] {
return [
{
label: copy.overview,
href: getAdminAppPath("/"),
icon: LayoutDashboard,
active: active === "overview",
},
{
label: copy.maintenance,
href: getAdminAppPath("/maintenance"),
icon: ShieldAlert,
active: active === "maintenance",
},
{
label: copy.uiKit,
href: getAdminAppPath("/ui-kit"),
icon: SwatchBook,
active: active === "ui-kit",
},
{
label: copy.media,
href: getAdminAppPath("/media"),
icon: ImageIcon,
active: active === "media",
},
{
label: copy.siteSettings,
href: getAdminAppPath("/site-settings/brand"),
icon: Globe2,
active: active === "site-settings" && !siteSettingsChild,
expanded: active === "site-settings",
children: [
{
label: copy.brandSettings ?? "Brand",
href: getAdminAppPath("/site-settings/brand"),
icon: Palette,
active: siteSettingsChild === "brand",
},
{
label: copy.localizationSettings ?? "Localization",
href: getAdminAppPath("/site-settings/localization"),
icon: Languages,
active: siteSettingsChild === "localization",
},
],
},
{
label: copy.marquee ?? "Marquee",
href: getAdminAppPath("/marquee"),
icon: Type,
active: active === "marquee",
},
{
label: copy.smtp ?? "SMTP",
href: getAdminAppPath("/smtp"),
icon: Mail,
active: active === "smtp" && !smtpChild,
expanded: active === "smtp",
children: [
{
label: copy.smtp ?? "SMTP",
href: getAdminAppPath("/smtp"),
icon: Mail,
active: smtpChild === "settings" || (!smtpChild && active === "smtp"),
},
{
label: copy.contactProtection ?? "Contact Protection",
href: getAdminAppPath("/smtp/contact-protection"),
icon: ShieldAlert,
active: smtpChild === "contact-protection",
},
],
},
{
label: copy.portfolio,
href: getAdminAppPath("/portfolio"),
icon: FolderKanban,
active: active === "portfolio" && !portfolioChild,
expanded: active === "portfolio",
children: [
{
label: "Projects",
href: getAdminAppPath("/portfolio"),
icon: FolderKanban,
active: portfolioChild === "overview" || portfolioChild === "projects",
},
{
label: "Add Project",
href: getAdminAppPath("/portfolio/projects/new"),
icon: PlusSquare,
active: portfolioChild === "new-project",
},
{
label: "Add Category",
href: getAdminAppPath("/portfolio/categories"),
icon: Tags,
active: portfolioChild === "categories",
},
].filter((item, index, array) => array.findIndex((entry) => entry.href === item.href) === index),
},
];
}