import React from "react"; import { useLocation, useNavigate } from "react-router-dom"; import { useTheme } from "@/contexts/ThemeContext"; import { useLanguage } from "@/contexts/LanguageContext"; import { LucideIcon } from "lucide-react"; interface MenuItemProps { id: string; path: string | null; icon: LucideIcon; translationKey: string; color: string; hasNavigation: boolean; collapsed: boolean; } export const MenuItem: React.FC = ({ id, path, icon: Icon, translationKey, color, hasNavigation, collapsed }) => { const { theme } = useTheme(); const { t } = useLanguage(); const location = useLocation(); const navigate = useNavigate(); const handleClick = (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); if (hasNavigation && path) { // Use navigate instead of window.location to prevent full page reload navigate(path, { replace: false }); } }; const isActive = path && location.pathname === path; const mainIconSize = "h-6 w-6"; return (
{!collapsed && {t(translationKey)}}
); };