const { useState } = React; window.LoginView = function({ setView, setProfile, hasUsers }) { const [email, setEmail] = useState(''); const [pass, setPass] = useState(''); const [name, setName] = useState(''); const [error, setError] = useState(''); const handleLogin = async (e) => { e.preventDefault(); setError(''); // Llamada a la API unificada para login (soporta Alias, Email o Código de trabajador) const res = await window.apiCall('login', { email_or_alias: email, password: pass }); if (res.success) { const found = res.profile; setProfile(found); localStorage.setItem('shift_active_session', JSON.stringify({ profile: found, expiresAt: Date.now() + (9 * 60 * 60 * 1000) })); setView(found.role === 'admin' || found.role === 'dueño' || found.role === 'propietario' ? 'admin' : 'dashboard'); } else { setError(res.error || "Credenciales incorrectas."); } }; return (

{(window.SHIFT_CONFIG ? window.SHIFT_CONFIG.companyName : "Shift Marcas")}

Acceso a Portal de Asistencia

setEmail(e.target.value)} className="w-full p-4 bg-slate-50 border-2 border-slate-100 rounded-2xl outline-none text-slate-800 font-bold" required /> setPass(e.target.value)} className="w-full p-4 bg-slate-50 border-2 border-slate-100 rounded-2xl outline-none text-slate-800 font-bold" required /> {error &&
{error}
}
); };