import { useNavigate, useLocation } from "react-router-dom"; import { FaCode } from "react-icons/fa"; import { FaHome, FaServer, FaPalette, FaUser, FaUsers, FaRocket, FaKey, FaFileAlt, } from "react-icons/fa"; import { useAuthStore } from "@/modules/auth/store/useAuthStore"; export const Navigation = () => { const navigate = useNavigate(); const location = useLocation(); const { user, logout } = useAuthStore(); const navItems = [ { path: "/", label: "Главная", icon: FaHome }, { path: "/add-agents", label: "Агенты", icon: FaServer }, { path: "/templates", label: "Шаблоны", icon: FaCode }, { path: "/add-agents", label: "Деплой", icon: FaRocket }, { path: "/registration", label: "Регистрация", icon: FaKey }, { path: "/logs", label: "Логи", icon: FaFileAlt }, { path: "/admin", label: "Админка", icon: FaUsers, adminOnly: true }, { path: "/themes", label: "Темы", icon: FaPalette }, ]; const isActive = (path: string) => location.pathname === path; return (
{/* Навигация с горизонтальным скроллом */}
{navItems .filter((item) => { if (item.adminOnly && !user?.permission_admin) return false; return true; }) .map((item) => { const Icon = item.icon; const active = isActive(item.path); return ( ); })}
{/* Профиль пользователя */}
{user && (
{user.name}
)}
); };