'use client'; import React, { useState, useEffect } from 'react'; import { usePathname } from 'next/navigation'; import Link from 'next/link'; import { MagnifyingGlassIcon, ChevronRightIcon, HomeIcon, BellIcon, Cog6ToothIcon } from '@heroicons/react/24/outline'; import CommandPalette from '@/components/ui/CommandPalette'; import { getUser } from '@/lib/auth'; export const TopBar: React.FC = () => { const pathname = usePathname(); const [isCommandPaletteOpen, setIsCommandPaletteOpen] = useState(false); const [user, setUser] = useState(null); useEffect(() => { const userData = getUser(); setUser(userData); }, []); const generateBreadcrumbs = () => { const paths = pathname?.split('/').filter(Boolean) || []; const breadcrumbs: Array<{ name: string; href: string; icon?: React.ComponentType<{ className?: string }> }> = [ { name: 'Home', href: '/dashboard', icon: HomeIcon } ]; let currentPath = ''; paths.forEach((path, index) => { currentPath += `/${path}`; // Mapeamento de nomes amigáveis const nameMap: Record = { 'dashboard': 'Dashboard', 'clientes': 'Clientes', 'projetos': 'Projetos', 'financeiro': 'Financeiro', 'configuracoes': 'Configurações', 'novo': 'Novo', }; if (path !== 'dashboard') { // Evita duplicar Home/Dashboard se a rota for /dashboard breadcrumbs.push({ name: nameMap[path] || path.charAt(0).toUpperCase() + path.slice(1), href: currentPath, }); } }); return breadcrumbs; }; const breadcrumbs = generateBreadcrumbs(); return ( <>
{/* Logo Mobile */}
{user?.logoUrl ? ( {user?.company ) : ( (user?.company?.charAt(0)?.toUpperCase() || 'A') )}
{/* Breadcrumbs Desktop */} {/* Search Bar Trigger */}
{/* Command Palette */} ); };