'use client'; import { LayoutDashboard, Wallet, CreditCard, PiggyBank, Bell, Lightbulb, Settings, TrendingUp, X, LogOut, } from 'lucide-react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { usePathname } from 'next/navigation'; import { Logo } from './Logo'; interface SidebarProps { isOpen: boolean; onClose: () => void; unreadAlertsCount?: number; } const navigationItems = [ { name: 'Dashboard', href: '/', icon: LayoutDashboard }, { name: 'Ingresos', href: '/incomes', icon: TrendingUp }, { name: 'Deudas', href: '/debts', icon: Wallet }, { name: 'Tarjetas', href: '/cards', icon: CreditCard }, { name: 'Presupuesto', href: '/budget', icon: PiggyBank }, { name: 'Servicios', href: '/services', icon: Lightbulb }, { name: 'Configuración', href: '/settings', icon: Settings }, { name: 'Alertas', href: '/alerts', icon: Bell, hasBadge: true }, ]; export function Sidebar({ isOpen, onClose, unreadAlertsCount = 0, }: SidebarProps) { const pathname = usePathname(); const router = useRouter(); const isActive = (href: string) => { if (href === '/') { return pathname === '/'; } return pathname.startsWith(href); }; const handleLogout = async () => { try { await fetch('/api/auth/logout', { method: 'POST' }); // Clear local data to avoid leaking to other users localStorage.removeItem('finanzas-storage'); router.push('/login'); router.refresh(); } catch (e) { console.error('Logout failed', e); } }; return ( <> {/* Mobile overlay */} {isOpen && (