"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { ErrorText } from "@/components/forms"; import { Button } from "@/components/ui/button"; import { Field, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; import { authClient } from "@/lib/auth-client"; export function SignUpForm() { const router = useRouter(); const [error, setError] = useState(""); const [pending, setPending] = useState(false); async function submit(form: FormData) { const username = String(form.get("username")); const password = String(form.get("password")); if (password !== form.get("password2")) { setError("The passwords don't match."); return; } setError(""); setPending(true); const { error } = await authClient.signUp.email({ username, name: username, email: String(form.get("email")), password, }); if (error) { setError(error.message ?? "That didn't work. Try again."); setPending(false); return; } router.push("/account?welcome=1"); router.refresh(); } return (
{ e.preventDefault(); void submit(new FormData(e.currentTarget)); }} > Username Email Password Password again Not your IMVU password: use a new one. {error && {error}} Have one? Sign in
); }