From f53373e9cf74829fb1745f0e4f2985273a28f27a Mon Sep 17 00:00:00 2001 From: marsalva Date: Wed, 25 Feb 2026 20:55:23 +0000 Subject: [PATCH] Actualizar index.html --- index.html | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 296ff3b..5e3147c 100644 --- a/index.html +++ b/index.html @@ -85,7 +85,7 @@ } }); - async function doLogin(e) { + async function doLogin(e) { e.preventDefault(); const btn = document.getElementById('btnSubmit'); const err = document.getElementById('errorMsg'); @@ -108,21 +108,18 @@ const data = await res.json(); if (res.ok && data.ok) { - // Guardamos la llave de acceso localStorage.setItem('token', data.token); localStorage.setItem('role', data.role); - localStorage.setItem('userName', data.name); // Guardamos el nombre para saludarle + localStorage.setItem('userName', data.name); - // Comprobamos que sea un operario - if(data.role === 'operario') { + // CORRECCIÓN: Aceptamos tanto al operario normal como al operario sin bolsa libre + if(data.role === 'operario' || data.role === 'operario_cerrado') { btn.innerHTML = ''; lucide.createIcons(); btn.classList.replace('bg-blue-600', 'bg-emerald-500'); - // Redirigimos al MENU - setTimeout(() => { window.location.href = "menu.html"; }, 800); + setTimeout(() => { window.location.href = "menu.html"; }, 500); } else { - // Si se cuela un administrador, le avisamos o lo mandamos a su panel err.querySelector('span').innerText = "Esta app es solo para operarios"; err.classList.remove('hidden'); localStorage.clear(); @@ -135,7 +132,7 @@ err.querySelector('span').innerText = "Error de conexión con el servidor"; err.classList.remove('hidden'); } finally { - if(!res?.ok || !data?.ok) { + if(!btn.classList.contains('bg-emerald-500')) { btn.disabled = false; btn.innerHTML = 'Entrar a mi Ruta '; lucide.createIcons();