const { useState } = React; window.LoginView = function({ setView, setProfile, hasUsers, allUsers }) { const [email, setEmail] = useState(''); const [pass, setPass] = useState(''); const [name, setName] = useState(''); const [error, setError] = useState(''); const isSetup = !hasUsers; const handleLogin = async (e) => { e.preventDefault(); if (isSetup) { const admin = { name, email: email.toLowerCase().trim(), password: pass, role: 'admin', status: 'activo', hiringDate: window.getNICDate(), vacationDaysUsed: 0, overrideCheckOut: false }; const ref = await db.collection('artifacts').doc(appId).collection('public').doc('data').collection('users').add(admin); const p = { id: ref.id, ...admin }; setProfile(p); localStorage.setItem('shift_v6', JSON.stringify(p)); setView('admin'); } else { const found = allUsers.find(u => u.email === email.toLowerCase().trim() && u.password === pass); if (found) { if (found.status === 'baja') return setError("Cuenta desactivada por administración."); setProfile(found); localStorage.setItem('shift_v6', JSON.stringify(found)); setView(found.role === 'admin' ? 'admin' : 'dashboard'); } else setError("Credenciales incorrectas."); } }; return (

{isSetup ? "Setup Maestro" : "Shift Marcas"}

Nicaragua (UTC-6)

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