1- import { useEffect , useState } from "react" ;
21import { useLocation , useNavigate } from "react-router-dom" ;
32import { getUsuarioLogado , logout } from "../services/authService" ;
4- import { getNotificacoes } from "../services/NotificacoesService" ;
53
64const navItems = [
7- { icon : "📊" , label : "Dashboard" , path : "/dashboard" } ,
8- { icon : "👥" , label : "Clientes" , path : "/clientes" } ,
9- { icon : "💳" , label : "Empréstimos" , path : "/emprestimos" } ,
10- { icon : "📈" , label : "Relatórios" , path : "/relatorios" } ,
11- { icon : "🔔" , label : "Notificações" , path : "/notificacoes" } ,
5+ { icon : "📊" , label : "Dashboard" , path : "/dashboard" } ,
6+ { icon : "👥" , label : "Clientes" , path : "/clientes" } ,
7+ { icon : "💳" , label : "Empréstimos" , path : "/emprestimos" } ,
8+ { icon : "📈" , label : "Relatórios" , path : "/relatorios" } ,
129 { icon : "⚙️" , label : "Configurações" , path : "/configuracoes" } ,
1310] ;
1411
1512export default function Sidebar ( ) {
1613 const location = useLocation ( ) ;
1714 const navigate = useNavigate ( ) ;
18- const [ naoLidas , setNaoLidas ] = useState ( 0 ) ;
1915
2016 const usuario = getUsuarioLogado ( ) ;
2117 const user = {
@@ -24,13 +20,6 @@ export default function Sidebar() {
2420 email : usuario ?. email ?? "" ,
2521 } ;
2622
27- useEffect ( ( ) => {
28- if ( ! usuario ?. nome ) return ;
29- getNotificacoes ( usuario . nome )
30- . then ( ( lista ) => setNaoLidas ( Array . isArray ( lista ) ? lista . filter ( ( n ) => ! n . lida ) . length : 0 ) )
31- . catch ( ( ) => { } ) ;
32- } , [ usuario ?. nome ] ) ;
33-
3423 function handleLogout ( ) {
3524 logout ( ) ;
3625 navigate ( "/login" ) ;
@@ -64,9 +53,6 @@ export default function Sidebar() {
6453 } } >
6554 { item . label }
6655 </ span >
67- { item . path === "/notificacoes" && naoLidas > 0 && (
68- < span style = { styles . notifBadge } > { naoLidas } </ span >
69- ) }
7056 </ button >
7157 ) ;
7258 } ) }
@@ -211,15 +197,6 @@ const styles = {
211197 overflow : "hidden" ,
212198 textOverflow : "ellipsis" ,
213199 } ,
214- notifBadge : {
215- marginLeft : "auto" ,
216- background : "#7C3AED" ,
217- color : "#fff" ,
218- borderRadius : 20 ,
219- padding : "1px 7px" ,
220- fontSize : 11 ,
221- fontWeight : 700 ,
222- } ,
223200 logoutBtn : {
224201 width : "100%" ,
225202 padding : "8px" ,
0 commit comments