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,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 }) => {
|
||||
<i className="fas fa-sync-alt"></i> Recargar
|
||||
</button>
|
||||
</div>
|
||||
<button className="btn btn-primary">
|
||||
<i className="fas fa-plus"></i> Nueva Solicitud
|
||||
</button>
|
||||
<button className="btn btn-outline" onClick={handleLogout} title="Cerrar sesión">
|
||||
<i className="fas fa-sign-out-alt"></i> Salir
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -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