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

121 lines
2.9 KiB
TypeScript

import {
FolderKanban,
Globe2,
ImageIcon,
LayoutDashboard,
Mail,
PlusSquare,
ShieldAlert,
SwatchBook,
Tags,
type LucideIcon,
} from "lucide-react";
type RootNavigationCopy = {
overview: string;
maintenance: string;
uiKit: string;
portfolio: string;
media: string;
siteSettings: string;
smtp?: string;
contactProtection?: string;
};
export type RootNavItem = {
label: string;
href: string;
icon: LucideIcon;
active?: boolean;
expanded?: boolean;
children?: RootNavItem[];
};
export function getRootNavigation(
copy: RootNavigationCopy,
active: "overview" | "maintenance" | "ui-kit" | "portfolio" | "media" | "site-settings" | "smtp",
smtpChild?: "settings" | "contact-protection",
portfolioChild?: "overview" | "projects" | "new-project" | "categories",
): RootNavItem[] {
return [
{
label: copy.overview,
href: "/root",
icon: LayoutDashboard,
active: active === "overview",
},
{
label: copy.maintenance,
href: "/root/maintenance",
icon: ShieldAlert,
active: active === "maintenance",
},
{
label: copy.uiKit,
href: "/root/ui-kit",
icon: SwatchBook,
active: active === "ui-kit",
},
{
label: copy.media,
href: "/root/media",
icon: ImageIcon,
active: active === "media",
},
{
label: copy.siteSettings,
href: "/root/site-settings",
icon: Globe2,
active: active === "site-settings",
},
{
label: copy.smtp ?? "SMTP",
href: "/root/smtp",
icon: Mail,
active: active === "smtp" && !smtpChild,
expanded: active === "smtp",
children: [
{
label: copy.smtp ?? "SMTP",
href: "/root/smtp",
icon: Mail,
active: smtpChild === "settings" || (!smtpChild && active === "smtp"),
},
{
label: copy.contactProtection ?? "Contact Protection",
href: "/root/smtp/contact-protection",
icon: ShieldAlert,
active: smtpChild === "contact-protection",
},
],
},
{
label: copy.portfolio,
href: "/root/portfolio",
icon: FolderKanban,
active: active === "portfolio" && !portfolioChild,
expanded: active === "portfolio",
children: [
{
label: "Projects",
href: "/root/portfolio",
icon: FolderKanban,
active: portfolioChild === "overview" || portfolioChild === "projects",
},
{
label: "Add Project",
href: "/root/portfolio/projects/new",
icon: PlusSquare,
active: portfolioChild === "new-project",
},
{
label: "Add Category",
href: "/root/portfolio/categories",
icon: Tags,
active: portfolioChild === "categories",
},
].filter((item, index, array) => array.findIndex((entry) => entry.href === item.href) === index),
},
];
}