This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
import {
|
||||
FolderKanban,
|
||||
Globe2,
|
||||
ImageIcon,
|
||||
LayoutDashboard,
|
||||
Mail,
|
||||
PlusSquare,
|
||||
ShieldAlert,
|
||||
SwatchBook,
|
||||
Tags,
|
||||
Type,
|
||||
type LucideIcon,
|
||||
} from "lucide-react";
|
||||
|
||||
type AdminNavigationCopy = {
|
||||
overview: string;
|
||||
maintenance: string;
|
||||
uiKit: string;
|
||||
portfolio: string;
|
||||
media: string;
|
||||
siteSettings: 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",
|
||||
): AdminNavItem[] {
|
||||
return [
|
||||
{
|
||||
label: copy.overview,
|
||||
href: "/",
|
||||
icon: LayoutDashboard,
|
||||
active: active === "overview",
|
||||
},
|
||||
{
|
||||
label: copy.maintenance,
|
||||
href: "/maintenance",
|
||||
icon: ShieldAlert,
|
||||
active: active === "maintenance",
|
||||
},
|
||||
{
|
||||
label: copy.uiKit,
|
||||
href: "/ui-kit",
|
||||
icon: SwatchBook,
|
||||
active: active === "ui-kit",
|
||||
},
|
||||
{
|
||||
label: copy.media,
|
||||
href: "/media",
|
||||
icon: ImageIcon,
|
||||
active: active === "media",
|
||||
},
|
||||
{
|
||||
label: copy.siteSettings,
|
||||
href: "/site-settings",
|
||||
icon: Globe2,
|
||||
active: active === "site-settings",
|
||||
},
|
||||
{
|
||||
label: copy.marquee ?? "Marquee",
|
||||
href: "/marquee",
|
||||
icon: Type,
|
||||
active: active === "marquee",
|
||||
},
|
||||
{
|
||||
label: copy.smtp ?? "SMTP",
|
||||
href: "/smtp",
|
||||
icon: Mail,
|
||||
active: active === "smtp" && !smtpChild,
|
||||
expanded: active === "smtp",
|
||||
children: [
|
||||
{
|
||||
label: copy.smtp ?? "SMTP",
|
||||
href: "/smtp",
|
||||
icon: Mail,
|
||||
active: smtpChild === "settings" || (!smtpChild && active === "smtp"),
|
||||
},
|
||||
{
|
||||
label: copy.contactProtection ?? "Contact Protection",
|
||||
href: "/smtp/contact-protection",
|
||||
icon: ShieldAlert,
|
||||
active: smtpChild === "contact-protection",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: copy.portfolio,
|
||||
href: "/portfolio",
|
||||
icon: FolderKanban,
|
||||
active: active === "portfolio" && !portfolioChild,
|
||||
expanded: active === "portfolio",
|
||||
children: [
|
||||
{
|
||||
label: "Projects",
|
||||
href: "/portfolio",
|
||||
icon: FolderKanban,
|
||||
active: portfolioChild === "overview" || portfolioChild === "projects",
|
||||
},
|
||||
{
|
||||
label: "Add Project",
|
||||
href: "/portfolio/projects/new",
|
||||
icon: PlusSquare,
|
||||
active: portfolioChild === "new-project",
|
||||
},
|
||||
{
|
||||
label: "Add Category",
|
||||
href: "/portfolio/categories",
|
||||
icon: Tags,
|
||||
active: portfolioChild === "categories",
|
||||
},
|
||||
].filter((item, index, array) => array.findIndex((entry) => entry.href === item.href) === index),
|
||||
},
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user