"use client"; /** * SignUpForm — paired with LoginForm. Same callback contract: * `onSuccess` fires once the new account is logged in; callers decide * what to do next. */ import { useState } from "react"; import { useAuth } from "@/components/auth/auth-provider"; import { AuthError } from "@/lib/auth"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; export function SignUpForm({ onSuccess }: { onSuccess?: () => void }) { const { signUp } = useAuth(); const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [submitting, setSubmitting] = useState(false); async function onSubmit(e: React.SyntheticEvent) { e.preventDefault(); setError(null); setSubmitting(true); try { await signUp(email, password, name); onSuccess?.(); } catch (err) { setError(err instanceof AuthError ? err.message : "Sign-up failed."); } finally { setSubmitting(false); } } return (
setName(e.target.value)} />
setEmail(e.target.value)} />
setPassword(e.target.value)} />

At least 8 characters.

{error ?

{error}

: null}
); }