"use client"; import type { ReactNode } from "react"; import { useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { AnimatePresence, motion } from "motion/react"; import { Logomark } from "@/components/logomark"; import { useI18n } from "@/i18n/i18n-provider"; import type { Dictionary } from "@/i18n/dictionary-type"; function getAdminNav(t: Dictionary) { return [ { href: "/admin", label: t.adminShell.navDashboard }, { href: "/admin/bestellungen", label: t.adminShell.navOrders }, { href: "/admin/retouren", label: t.adminShell.navReturns }, { href: "/admin/produkte", label: t.adminShell.navProducts }, { href: "/admin/ernten", label: t.adminShell.navHarvests }, { href: "/admin/chargen", label: t.adminShell.navBatches }, { href: "/admin/anfragen", label: t.adminShell.navBusinessInquiries }, { href: "/admin/benutzer", label: t.adminShell.navUsers }, { href: "/admin/versand", label: t.adminShell.navShipping }, { href: "/admin/gutscheine", label: t.adminShell.navVouchers }, { href: "/admin/bewertungen", label: t.adminShell.navReviews }, { href: "/admin/inhalte", label: t.adminShell.navContent }, { href: "/admin/audit-log", label: t.adminShell.navAuditLog }, ]; } function isActiveHref(pathname: string, href: string): boolean { if (href === "/admin") return pathname === "/admin"; return pathname === href || pathname.startsWith(`${href}/`); } function NavLinks({ pathname, adminNav, onNavigate, }: { pathname: string; adminNav: ReturnType; onNavigate?: () => void; }) { return ( <> {adminNav.map((item) => { const active = isActiveHref(pathname, item.href); return ( {item.label} ); })} ); } function Wordmark() { return ( WABENHAIN ADMIN ); } interface AdminShellProps { adminName: string; logoutAction: () => void | Promise; children: ReactNode; } /** * Sidebar-Layout fuer den Admin-Bereich statt der frueheren einzeiligen, * horizontal scrollenden Navigation (11 Punkte passten auf typischen * Bildschirmbreiten nicht nebeneinander). Ab lg persistente Sidebar links, * darunter ein Vollbild-Overlay-Menue nach demselben Muster wie die mobile * Hauptnavigation in site-chrome.tsx. */ export function AdminShell({ adminName, logoutAction, children }: AdminShellProps) { const { t } = useI18n(); const adminNav = getAdminNav(t); const pathname = usePathname(); const [mobileOpen, setMobileOpen] = useState(false); return (
{children}
{mobileOpen ? (

{t.adminShell.loggedInAs(adminName)}

) : null}
); }