"use client"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useTheme } from "next-themes"; import { BookOpen, Calendar, Package, ChefHat, User, Rss, FolderOpen, ShoppingCart, Shield, Search, Compass, Menu, Sun, Moon, Monitor, Apple } from "lucide-react"; import { cn } from "@/lib/utils"; import { Button, buttonVariants } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Sheet, SheetClose, SheetContent, SheetHeader, SheetTitle, SheetTrigger, } from "@/components/ui/sheet"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { NotificationBell } from "@/components/social/notification-bell"; import { MessagesNavLink } from "@/components/social/messages-nav-link"; import { authClient } from "@/lib/auth/client"; import { useTranslations } from "next-intl"; const NAV_ITEMS = [ { href: "/recipes", key: "recipes", icon: BookOpen }, { href: "/explore", key: "explore", icon: Search }, { href: "/feed", key: "feed", icon: Rss }, { href: "/collections", key: "collections", icon: FolderOpen }, { href: "/meal-plan", key: "mealPlan", icon: Calendar }, { href: "/nutrition", key: "nutrition", icon: Apple }, { href: "/pantry", key: "pantry", icon: Package }, { href: "/shopping-lists", key: "shopping", icon: ShoppingCart }, ] as const; export function Nav() { const pathname = usePathname(); const router = useRouter(); const { data: session } = authClient.useSession(); const isAdmin = (session?.user as { role?: string } | undefined)?.role === "admin"; const username = (session?.user as { username?: string } | undefined)?.username; const { theme, setTheme } = useTheme(); const t = useTranslations("nav"); const THEME_OPTIONS = [ { value: "light", icon: Sun, label: t("lightMode") }, { value: "dark", icon: Moon, label: t("darkMode") }, { value: "system", icon: Monitor, label: t("systemMode") }, ] as const; return (
} > {t("menu")} Epicure Epicure
{username && ( {t("viewProfile")} )} {t("settings")}
{THEME_OPTIONS.map(({ value, icon: Icon, label }) => ( ))}
{isAdmin && ( <> {t("admin")} )} { void authClient.signOut({ fetchOptions: { onSuccess: () => { router.push("/login"); router.refresh(); }, }, }); }} > {t("signOut")}
); }