Fix: Sidebar navigation issue

The sidebar navigation incorrectly highlights the "Dashboard" menu item when the "Transações" menu item is selected, preventing access to the dashboard.
This commit is contained in:
gpt-engineer-app[bot] 2025-05-19 01:37:43 +00:00
parent 75e54b23c2
commit e70b9ce00b
3 changed files with 16 additions and 58 deletions

View File

@ -1,3 +1,4 @@
import React, { useEffect, useState } from "react";
import { Toaster } from "@/components/ui/toaster";
import { Toaster as Sonner } from "@/components/ui/sonner";
@ -98,10 +99,20 @@ const App = () => {
<Sonner />
<BrowserRouter>
<Routes>
{/* Always redirect to dashboard since we're using RLS disabled mode */}
{/* Root path redirects to dashboard */}
<Route
path="/"
element={<Navigate to="/transacoes" replace />}
element={<Navigate to="/dashboard" replace />}
/>
{/* Dashboard route using Index component */}
<Route
path="/dashboard"
element={
<ProtectedRoute>
<Index />
</ProtectedRoute>
}
/>
{/* Auth page is still available, but we should never need to redirect here */}
@ -133,14 +144,6 @@ const App = () => {
}
/>
{/* Redirect /dashboard to /transacoes */}
<Route
path="/dashboard"
element={
<Navigate to="/transacoes" replace />
}
/>
{/* 404 route */}
<Route path="*" element={<NotFound />} />
</Routes>

View File

@ -5,11 +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
// Updated navItems with correct paths
const navItems = [
{
name: 'Dashboard',
path: '/', // Caminho separado para o Dashboard
path: '/dashboard', // Changed path to '/dashboard' to be distinct from root path
icon: <Home className="mr-2 h-5 w-5" />
},
{
@ -37,9 +37,8 @@ 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
// Improved function to verify if the item is active based on exact path
const isItemActive = (path: string) => {
// Verificação exata do caminho
return location.pathname === path;
};

View File

@ -156,50 +156,6 @@ export type Database = {
}
Relationships: []
}
"transacoes_21f0ba76-bc06-4428-a80a-2229205fba58": {
Row: {
categoria: string | null
created_at: string
detalhes: string | null
estabelecimento: string | null
id: number
quando: string | null
tipo: string | null
usuario_id: string | null
valor: number | null
}
Insert: {
categoria?: string | null
created_at?: string
detalhes?: string | null
estabelecimento?: string | null
id?: number
quando?: string | null
tipo?: string | null
usuario_id?: string | null
valor?: number | null
}
Update: {
categoria?: string | null
created_at?: string
detalhes?: string | null
estabelecimento?: string | null
id?: number
quando?: string | null
tipo?: string | null
usuario_id?: string | null
valor?: number | null
}
Relationships: [
{
foreignKeyName: "transacoes_21f0ba76-bc06-4428-a80a-2229205fba58_usuario_id_fkey"
columns: ["usuario_id"]
isOneToOne: false
referencedRelation: "usuarios"
referencedColumns: ["id"]
},
]
}
"transacoes_9f267008-9128-4a2f-b730-de0a0b5602a9": {
Row: {
categoria: string | null