"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { useAuth } from "@/lib/auth"; export default function RegisterPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const { register, login } = useAuth(); const router = useRouter(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setLoading(true); try { await register(email, password); // Auto-login after registration (works when Confirm Email is OFF) try { await login(email, password); router.push("/"); return; } catch { // If auto-login fails, Confirm Email might be ON — show message } // Fallback: show confirmation message setError(""); router.push("/login"); } catch (err: unknown) { setError(err instanceof Error ? err.message : "Registration failed"); } finally { setLoading(false); } }; return (
{/* Background mesh */}
{/* Logo */}

Create your account

Start compiling your company brain

setEmail(e.target.value)} required />
setPassword(e.target.value)} required minLength={6} />

Minimum 6 characters

{error && (
{error}
)}

Already have an account?{" "} Sign In

); }