From 23ac89e1583bcf60a1e4033209532d7fac1d7345 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 18 May 2025 13:17:51 +0000 Subject: [PATCH] Fix: Dashboard and Transactions menu selection The dashboard menu item is selected when the user navigates to the transactions page. This commit ensures that the correct menu item is selected based on the current route. --- src/App.tsx | 8 +++++--- src/components/layout/Sidebar.tsx | 11 +++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 717b475..b2ad7bf 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -46,19 +46,21 @@ const App = () => { path="/" element={ isAutenticado ? ( - + + + ) : ( ) } /> - {/* Rota de autenticação - redireciona para transações se já estiver autenticado */} + {/* Rota de autenticação - redireciona para dashboard se já estiver autenticado */} + ) : ( ) diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index 8876016..6138a20 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -5,10 +5,11 @@ import { cn } from '@/lib/utils'; import { Button } from "@/components/ui/button"; import { ChevronLeft, ChevronRight, Home, CalendarDays, DollarSign, PieChart } from 'lucide-react'; +// Modificado para separar Dashboard e Transações como itens distintos const navItems = [ { name: 'Dashboard', - path: '/transacoes', // Alterado de '/' para '/transacoes' + path: '/', // Caminho separado para o Dashboard icon: }, { @@ -36,6 +37,12 @@ const Sidebar = ({ className }: SidebarProps) => { const location = useLocation(); const [collapsed, setCollapsed] = React.useState(false); + // Função para verificar se o item está ativo baseado no caminho atual + const isItemActive = (path: string) => { + // Verificação exata do caminho + return location.pathname === path; + }; + return (
{ to={item.path} className={cn( "flex items-center px-4 py-2 text-sm font-medium rounded-md transition-colors", - location.pathname === item.path + isItemActive(item.path) ? "bg-sidebar-accent text-sidebar-accent-foreground" : "text-sidebar-foreground hover:bg-sidebar-accent/50", collapsed ? "justify-center" : "justify-start"