"use client"; import { useSearchParams, useRouter } from "next/navigation"; import { authClient } from "@/lib/auth-client"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Suspense, useState } from "react"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import Link from "next/link"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; function SignUpForm() { const searchParams = useSearchParams(); const router = useRouter(); const redirectUrl = searchParams.get("redirect"); const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const handleSignUp = async () => { setError(null); const { error } = await authClient.signUp.email({ name, email, password, }); if (error) { setError(error.message || "An unexpected error occurred."); return; } router.push(redirectUrl || "/"); }; return (
{error && ( Error {error} )}
setName(e.target.value)} />
setEmail(e.target.value)} />
setPassword(e.target.value)} />
); } export default function SignUpPage() { return (
Sign Up Create an account to get started. Loading...
}>
Already have an account?{" "} Login
); }