From 74ee3d19c472f6f4d870d605d0f605d0af7a5bff Mon Sep 17 00:00:00 2001 From: rafael Date: Thu, 20 Nov 2025 20:43:29 -0400 Subject: [PATCH] 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. --- src/components/Layout/Header.js | 14 -------------- src/components/Layout/Sidebar.js | 9 ++++++++- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/Layout/Header.js b/src/components/Layout/Header.js index 71cb7c6..3ed9740 100644 --- a/src/components/Layout/Header.js +++ b/src/components/Layout/Header.js @@ -2,14 +2,6 @@ import React from 'react'; import '../../styles/components.css'; const Header = ({ title = 'Dashboard', credits = 0, onReloadCredits }) => { - const handleLogout = () => { - try { - localStorage.setItem('auth', 'false'); - } catch (e) {} - // Aseguramos volver al login - window.location.reload(); - }; - const iconClass = title === 'Solicitudes Programadas' ? 'fas fa-calendar-alt' : 'fas fa-tachometer-alt'; return ( @@ -36,12 +28,6 @@ const Header = ({ title = 'Dashboard', credits = 0, onReloadCredits }) => { Recargar - - ); diff --git a/src/components/Layout/Sidebar.js b/src/components/Layout/Sidebar.js index 475cb4b..139c426 100644 --- a/src/components/Layout/Sidebar.js +++ b/src/components/Layout/Sidebar.js @@ -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
Juan Pérez
Administrador
- + { e.preventDefault(); handleLogout(); }} title="Cerrar sesión">