import { useState } from "react"; import { Dialog } from "@headlessui/react"; import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline"; import { NavLink, Link, useNavigate } from "react-router-dom"; import { Button } from "../UI"; import { useAuth } from "../../hooks/useAuth"; const publicNavigation = [ { name: "Дома", href: "/" }, { name: "За нас", href: "/about" }, { name: "Галерија", href: "/gallery" }, { name: "Контакт", href: "/contact" }, { name: "Логин", href: "/login" }, ]; const basePrivateNavigation = [ { name: "Дома", href: "/" }, { name: "За нас", href: "/about" }, { name: "Галерија", href: "/gallery" }, { name: "Контакт", href: "/contact" }, ]; export default function Navbar() { const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const { user, logout } = useAuth(); const navigate = useNavigate(); const getNavigation = () => { if (!user) return publicNavigation; // Add appropriate dashboard link based on user role const privateNavigation = [...basePrivateNavigation]; if (user.isAdmin) { privateNavigation.push({ name: "Админ Панел", href: "/admin" }); } else { privateNavigation.push({ name: "Клиент Зона", href: "/dashboard" }); } return privateNavigation; }; const navigation = getNavigation(); const handleLogout = async () => { try { await logout(); navigate("/"); } catch (error) { console.error("Logout failed:", error); } }; return (