"use client"; import { ReactNode, useEffect } from "react"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { Hexagon, MoreHorizontal } from "lucide-react"; import { useAuth } from "@/lib/auth/auth-context"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { BottomNav } from "./bottom-nav"; import { QuickAddMenu } from "./quick-add-menu"; const NAV_LINK_CLASS = "shrink-0 rounded-md px-2.5 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground aria-[current=page]:bg-primary/10 aria-[current=page]:text-primary"; const PRIMARY_LINKS = [ { label: "Dashboard", href: "/dashboard" }, { label: "Bienenstände", href: "/apiaries" }, { label: "Völker", href: "/colonies" }, { label: "Königinnen", href: "/queens" }, { label: "Aufgaben", href: "/tasks" }, { label: "Honigchargen", href: "/honey-batches" }, { label: "Lager", href: "/storage" }, { label: "Suche", href: "/search" }, ]; const MORE_LINKS = [ { label: "Produkte", href: "/products" }, { label: "Abfüllungen", href: "/bottling/new" }, ]; const ADMIN_LINKS = [ { label: "Benutzer", href: "/settings/users" }, { label: "Audit-Log", href: "/settings/audit-log" }, ]; function NavLink({ href, label, pathname }: { href: string; label: string; pathname: string }) { return ( {label} ); } export default function AppLayout({ children }: { children: ReactNode }) { const router = useRouter(); const pathname = usePathname(); const { user, isLoading, logout } = useAuth(); useEffect(() => { if (!isLoading && !user) { router.replace("/login"); } }, [isLoading, user, router]); if (isLoading || !user) { return null; } return (
{user.email}
{children}
); }