/* global React */ const { useState } = React; function RegisterPage({ onLogin }) { const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [confirm, setConfirm] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const submit = async (e) => { e.preventDefault(); setError(""); if (password !== confirm) { setError("Passwords do not match"); return; } if (password.length < 8) { setError("Password must be at least 8 characters"); return; } setLoading(true); try { const res = await window.api.register(name, email, password); if (res && res.access_token) { window.Auth.setToken(res.access_token); const user = await window.api.me(); if (user) window.Auth.setUser(user); onLogin(); } } catch (err) { setError(err.message || "Registration failed"); } finally { setLoading(false); } }; return (
AURA
Free forever — no credit card required