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:
parent
75e54b23c2
commit
e70b9ce00b
23
src/App.tsx
23
src/App.tsx
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Toaster } from "@/components/ui/toaster";
|
import { Toaster } from "@/components/ui/toaster";
|
||||||
import { Toaster as Sonner } from "@/components/ui/sonner";
|
import { Toaster as Sonner } from "@/components/ui/sonner";
|
||||||
@ -98,10 +99,20 @@ const App = () => {
|
|||||||
<Sonner />
|
<Sonner />
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routes>
|
<Routes>
|
||||||
{/* Always redirect to dashboard since we're using RLS disabled mode */}
|
{/* Root path redirects to dashboard */}
|
||||||
<Route
|
<Route
|
||||||
path="/"
|
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 */}
|
{/* 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 */}
|
{/* 404 route */}
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|||||||
@ -5,11 +5,11 @@ import { cn } from '@/lib/utils';
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ChevronLeft, ChevronRight, Home, CalendarDays, DollarSign, PieChart } from 'lucide-react';
|
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 = [
|
const navItems = [
|
||||||
{
|
{
|
||||||
name: 'Dashboard',
|
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" />
|
icon: <Home className="mr-2 h-5 w-5" />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -37,9 +37,8 @@ const Sidebar = ({ className }: SidebarProps) => {
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [collapsed, setCollapsed] = React.useState(false);
|
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) => {
|
const isItemActive = (path: string) => {
|
||||||
// Verificação exata do caminho
|
|
||||||
return location.pathname === path;
|
return location.pathname === path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -156,50 +156,6 @@ export type Database = {
|
|||||||
}
|
}
|
||||||
Relationships: []
|
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": {
|
"transacoes_9f267008-9128-4a2f-b730-de0a0b5602a9": {
|
||||||
Row: {
|
Row: {
|
||||||
categoria: string | null
|
categoria: string | null
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user