diff --git a/src/app/layouts/DashboardLayout.tsx b/src/app/layouts/DashboardLayout.tsx
index 3ad45bd..698f28d 100644
--- a/src/app/layouts/DashboardLayout.tsx
+++ b/src/app/layouts/DashboardLayout.tsx
@@ -16,36 +16,73 @@ import {
ChevronDown,
LogOut,
Users2,
+ Search,
} from 'lucide-react';
import { cn } from '@utils/cn';
import { useUIStore } from '@stores/useUIStore';
import { useAuthStore } from '@stores/useAuthStore';
import { useIsMobile } from '@hooks/useMediaQuery';
+import { useFilteredNavigation, type NavigationItem } from '@hooks/useFilteredNavigation';
+import { ThemeToggle } from '@components/atoms/ThemeToggle';
+import { CommandPaletteWithRouter, useCommandPalette } from '@components/organisms/CommandPalette';
interface DashboardLayoutProps {
children: ReactNode;
}
-const navigation = [
+/**
+ * Search button component that opens the command palette
+ */
+function SearchButton() {
+ const { open } = useCommandPalette();
+ const isMac = typeof navigator !== 'undefined' && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
+
+ return (
+
+ );
+}
+
+const navigation: NavigationItem[] = [
{ name: 'Dashboard', href: '/dashboard', icon: Home },
- { name: 'Usuarios', href: '/users', icon: Users },
- { name: 'Empresas', href: '/companies', icon: Building2 },
- { name: 'Partners', href: '/partners', icon: Users2 },
- { name: 'Inventario', href: '/inventory', icon: Package },
- { name: 'Ventas', href: '/sales', icon: ShoppingCart },
- { name: 'Compras', href: '/purchases', icon: ShoppingCart },
- { name: 'Finanzas', href: '/financial', icon: Receipt },
- { name: 'Proyectos', href: '/projects', icon: FolderKanban },
- { name: 'CRM', href: '/crm', icon: UserCircle },
- { name: 'RRHH', href: '/hr', icon: Users },
- { name: 'Configuración', href: '/settings', icon: Settings },
+ { name: 'Usuarios', href: '/users', icon: Users, module: 'users' },
+ { name: 'Empresas', href: '/companies', icon: Building2, module: 'companies' },
+ { name: 'Partners', href: '/partners', icon: Users2, module: 'partners' },
+ { name: 'Inventario', href: '/inventory', icon: Package, module: 'inventory' },
+ { name: 'Ventas', href: '/sales', icon: ShoppingCart, module: 'sales' },
+ { name: 'Compras', href: '/purchases', icon: ShoppingCart, module: 'purchases' },
+ { name: 'Finanzas', href: '/financial', icon: Receipt, module: 'finance' },
+ { name: 'Proyectos', href: '/projects', icon: FolderKanban, module: 'projects' },
+ { name: 'CRM', href: '/crm', icon: UserCircle, module: 'crm' },
+ { name: 'RRHH', href: '/hr', icon: Users, module: 'hr' },
+ { name: 'Configuración', href: '/settings', icon: Settings, roles: ['admin', 'super_admin'] },
];
-export function DashboardLayout({ children }: DashboardLayoutProps) {
+/**
+ * Internal layout component (used inside CommandPaletteWithRouter)
+ */
+function DashboardLayoutInner({ children }: DashboardLayoutProps) {
const location = useLocation();
const isMobile = useIsMobile();
const { sidebarOpen, sidebarCollapsed, toggleSidebar, setSidebarOpen, setIsMobile } = useUIStore();
const { user, logout } = useAuthStore();
+ const { items: filteredNavigation, isLoading: isNavigationLoading } = useFilteredNavigation(navigation);
useEffect(() => {
setIsMobile(isMobile);
@@ -59,11 +96,11 @@ export function DashboardLayout({ children }: DashboardLayoutProps) {
}, [location.pathname, isMobile, setSidebarOpen]);
return (
-
+
{/* Mobile sidebar backdrop */}
{isMobile && sidebarOpen && (
setSidebarOpen(false)}
/>
)}
@@ -71,7 +108,7 @@ export function DashboardLayout({ children }: DashboardLayoutProps) {
{/* Sidebar */}