Add logout functionality to Sidebar and remove duplicate logic from Header
Integrated logout logic into the Sidebar component, enabling session termination and page reload. Removed redundant logout implementation from the Header to streamline functionality. Updated styles for the logout action in the Sidebar.
This commit is contained in:
@@ -2,6 +2,13 @@ import React from 'react';
|
||||
import '../../styles/components.css';
|
||||
|
||||
const Sidebar = ({ isMobileMenuOpen, onToggleMobileMenu, activeView = 'dashboard', onNavigate }) => {
|
||||
const handleLogout = () => {
|
||||
try {
|
||||
localStorage.setItem('auth', 'false');
|
||||
} catch (e) {}
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const navItems = [
|
||||
{ key: 'dashboard', icon: 'fas fa-tachometer-alt', label: 'Dashboard', badge: null },
|
||||
{ key: 'scheduled', icon: 'fas fa-list', label: 'Solicitudes Programadas', badge: null },
|
||||
@@ -61,7 +68,7 @@ const Sidebar = ({ isMobileMenuOpen, onToggleMobileMenu, activeView = 'dashboard
|
||||
<div className="user-name">Juan Pérez</div>
|
||||
<div className="user-role">Administrador</div>
|
||||
</div>
|
||||
<a href="#" style={{color: 'white'}}>
|
||||
<a href="#" style={{color: 'white'}} onClick={(e) => { e.preventDefault(); handleLogout(); }} title="Cerrar sesión">
|
||||
<i className="fas fa-sign-out-alt"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user