/* global React */ const { useState: useStateAuth, useEffect: useEffectAuth } = React; window.LoginScreen = function LoginScreen({ onAuthed }) { const [mode, setMode] = useStateAuth('login'); // 'login' | 'forgot' | 'sent' const [email, setEmail] = useStateAuth(''); const [password, setPassword] = useStateAuth(''); const [busy, setBusy] = useStateAuth(false); const [error, setError] = useStateAuth(''); async function submitLogin(e) { e.preventDefault(); setError(''); setBusy(true); try { const user = await window.LQ.login(email.trim().toLowerCase(), password); onAuthed && onAuthed(user); } catch (err) { setError(err.message || 'Login failed.'); } finally { setBusy(false); } } async function submitForgot(e) { e.preventDefault(); setError(''); setBusy(true); try { await window.LQ.requestReset(email.trim().toLowerCase()); setMode('sent'); } catch (err) { setError(err.message || 'Request failed.'); } finally { setBusy(false); } } return (
Lacquery Nails
{mode === 'login' && ( <>

Admin Login

setEmail(e.target.value)} autoFocus autoComplete="email" /> setPassword(e.target.value)} autoComplete="current-password" /> {error &&
{error}
}
)} {mode === 'forgot' && ( <>

Forgot Password

Enter your email to receive a reset link.

setEmail(e.target.value)} autoFocus /> {error &&
{error}
}
)} {mode === 'sent' && ( <>

Check your inbox

If {email} matches an admin account, a reset link has been sent. The link expires in 30 minutes.

)}
); };