Skip to content

Commit

Permalink
222
Browse files Browse the repository at this point in the history
  • Loading branch information
JMarcosMoura committed Jan 19, 2025
1 parent 872b81a commit bea60e1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion js/menu-lateral.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
document.getElementById('open_btn').addEventListener('click', function () {
document.getElementById('sidebar').classList.toggle('open-sidebar');
const sidebar = document.getElementById('sidebar');

// Alterna a classe 'open-sidebar' para abrir/fechar a sidebar
sidebar.classList.toggle('open-sidebar');

// Verifica se a sidebar está aberta
if (sidebar.classList.contains('open-sidebar')) {
const loggedUser = JSON.parse(localStorage.getItem('loggedUser'));

if (loggedUser) {
// Atualiza o nome e o email do usuário na sidebar
document.getElementById('user.name').textContent = loggedUser.name;
document.getElementById('user.email').textContent = loggedUser.email;
} else {
// Redireciona para a página de login se não houver usuário logado
window.location.href = 'https://ifpi-picos.github.io/projeto-integrador-redatorpro/login';
}
}
});


// Seleciona todos os elementos que possuem a classe "side-item"
const sideItems = document.querySelectorAll('.side-item');

Expand Down

0 comments on commit bea60e1

Please sign in to comment.