"use client"; import { useRouter } from "next/navigation"; import { signUp, signIn } 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 { Separator } from "@/components/ui/separator"; import Link from "next/link"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Loader2, ArrowLeft } from "lucide-react"; import { GoogleIcon } from "@/components/icons"; function SignUpForm() { const router = useRouter(); const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [isEmailLoading, setIsEmailLoading] = useState(false); const [isGoogleLoading, setIsGoogleLoading] = useState(false); const handleSignUp = async () => { setError(null); setIsEmailLoading(true); const { error } = await signUp.email({ name, email, password, }); if (error) { setError(error.message || "An unexpected error occurred."); setIsEmailLoading(false); return; } router.push("/auth/login"); }; const handleGoogleSignUp = async () => { setError(null); setIsGoogleLoading(true); try { await signIn.social({ provider: "google", }); router.push("/editor"); } catch (error) { setError("Failed to sign up with Google. Please try again."); setIsGoogleLoading(false); } }; const isAnyLoading = isEmailLoading || isGoogleLoading; return (
{error && ( Error {error} )}
Or continue with
setName(e.target.value)} disabled={isAnyLoading} className="h-11" />
setEmail(e.target.value)} disabled={isAnyLoading} className="h-11" />
setPassword(e.target.value)} disabled={isAnyLoading} className="h-11" />
); } export default function SignUpPage() { const router = useRouter(); return (
Create your account Get started with your free account today
}>
Already have an account?{" "} Sign in
); }