// Tela: Auth (login / cadastro / esqueci a senha) const { useState: useStateAuth } = React; function Auth({ t, lang, setLang, mode = 'signin', onAuth, onBack, onToggle, onForgot }) { const [email, setEmail] = useStateAuth(''); const [password, setPassword] = useStateAuth(''); const [name, setName] = useStateAuth(''); const [err, setErr] = useStateAuth(''); const [loading, setLoading] = useStateAuth(false); const [showPw, setShowPw] = useStateAuth(false); const isSignup = mode === 'signup'; async function submit(e) { e.preventDefault(); setErr(''); setLoading(true); try { const res = isSignup ? await window.DB.signUp({ email, password, name }) : await window.DB.signIn({ email, password }); onAuth(res); } catch (e) { setErr(e.message || 'Erro ao autenticar.'); } finally { setLoading(false); } } return (

{isSignup ? t.auth_create : t.auth_welcome}

{isSignup && ( )} {!isSignup && (
)} {err &&
{err}
}

{isSignup ? t.auth_have : t.auth_no} {' '}

{t.auth_terms} {t.nav_terms} · {t.nav_privacy}

); } function ForgotPassword({ t, lang, setLang, onBack }) { const [email, setEmail] = useStateAuth(''); const [err, setErr] = useStateAuth(''); const [loading, setLoading] = useStateAuth(false); const [sent, setSent] = useStateAuth(false); async function submit(e) { e.preventDefault(); setErr(''); setLoading(true); try { await window.DB.resetPassword({ email }); setSent(true); } catch (e) { setErr(e.message || 'Erro ao enviar.'); } finally { setLoading(false); } } return (

{sent ? t.forgot_sent_title : t.forgot_title}

{sent ? t.forgot_sent_sub : t.forgot_sub}

{!sent ? (
{err &&
{err}
}
) : (
)}

); } Object.assign(window, { Auth, ForgotPassword });