diff --git a/src/web/src/components/layout/AppHeader.tsx b/src/web/src/components/layout/AppHeader.tsx index 77b27d3..895b285 100644 --- a/src/web/src/components/layout/AppHeader.tsx +++ b/src/web/src/components/layout/AppHeader.tsx @@ -57,7 +57,7 @@ export function AppHeader() { Navegación - + diff --git a/src/web/src/components/layout/AppSidebar.tsx b/src/web/src/components/layout/AppSidebar.tsx index a46ac66..a92e9d3 100644 --- a/src/web/src/components/layout/AppSidebar.tsx +++ b/src/web/src/components/layout/AppSidebar.tsx @@ -9,10 +9,14 @@ import { Users, ShieldCheck, KeyRound, + PanelLeftClose, + PanelLeftOpen, + Newspaper, } from 'lucide-react' import { cn } from '@/lib/utils' import { Badge } from '@/components/ui/badge' import { useAuthStore } from '@/stores/authStore' +import { useSidebar } from '@/hooks/useSidebar' interface NavItem { label: string @@ -25,127 +29,216 @@ const navItems: NavItem[] = [ { label: 'Dashboard', href: '/', icon: LayoutDashboard }, { label: 'Ventas', href: '/ventas', icon: ShoppingCart, disabled: true }, { label: 'Tasación', href: '/tasacion', icon: Calculator, disabled: true }, - { - label: 'Integraciones', - href: '/integraciones', - icon: Zap, - disabled: true, - }, - { - label: 'Administración', - href: '/administracion', - icon: Settings, - disabled: true, - }, + { label: 'Integraciones', href: '/integraciones', icon: Zap, disabled: true }, + { label: 'Administración', href: '/administracion', icon: Settings, disabled: true }, ] -export function SidebarNav() { +const adminItems: NavItem[] = [ + { label: 'Usuarios', href: '/usuarios', icon: Users }, + { label: 'Crear Usuario', href: '/usuarios/nuevo', icon: UserPlus }, + { label: 'Roles', href: '/admin/roles', icon: ShieldCheck }, + { label: 'Permisos', href: '/admin/permisos', icon: KeyRound }, +] + +interface SidebarNavProps { + /** When true forces expanded layout regardless of persisted state — used by mobile Sheet. */ + forceExpanded?: boolean +} + +export function SidebarNav({ forceExpanded = false }: SidebarNavProps) { const { pathname } = useLocation() const user = useAuthStore((s) => s.user) const isAdmin = user?.rol === 'admin' + const { collapsed: persisted, toggle } = useSidebar() + const collapsed = forceExpanded ? false : persisted + + function isItemActive(item: NavItem): boolean { + if (item.disabled) return false + if (item.href === '/') return pathname === '/' + if (item.href === '/usuarios') { + return pathname.startsWith('/usuarios') && pathname !== '/usuarios/nuevo' + } + if (item.href === '/usuarios/nuevo') return pathname === '/usuarios/nuevo' + return pathname.startsWith(item.href) + } return ( -