import { useState } from "react"; import { NavLink, Outlet, useNavigate } from "react-router-dom"; import { LayoutDashboard, ArrowLeftRight, Tag, Wallet, History, Menu, X, LogOut, ChevronRight, } from "lucide-react"; import { useAuthStore } from "../stores/auth"; import { logoutUser } from "../api/client"; import { useToast } from "../context/ToastContext"; const NAV_ITEMS = [ { to: "/", icon: LayoutDashboard, label: "Dashboard", end: true }, { to: "/transactions", icon: ArrowLeftRight, label: "Transactions", end: false }, { to: "/categories", icon: Tag, label: "Catégories", end: false }, { to: "/budgets", icon: Wallet, label: "Budgets", end: false }, { to: "/history", icon: History, label: "Historique", end: false }, ]; export default function Layout() { const [sidebarOpen, setSidebarOpen] = useState(false); const { user, refreshToken, logout } = useAuthStore(); const navigate = useNavigate(); const { addToast } = useToast(); const handleLogout = async () => { try { if (refreshToken) await logoutUser(refreshToken); } catch { // best-effort logout } finally { logout(); navigate("/login"); addToast({ type: "info", message: "Déconnecté avec succès" }); } }; const navLinkClass = ({ isActive }: { isActive: boolean }) => `flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors ${ isActive ? "bg-primary text-white" : "text-slate-300 hover:bg-slate-700 hover:text-white" }`; const SidebarContent = () => (