import { useState } from "react"; import { ThemeToggle } from "../components/ThemeToggle"; import { authClient } from "../lib/auth-client"; interface SignupPageProps { navigate: ( route: | "/" | "/login" | "/signup" | "/pricing" | "/dashboard" | "/forgot-password" | "/reset-password", ) => void; } export default function SignupPage({ navigate }: SignupPageProps) { const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [isLoading, setIsLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(null); setIsLoading(true); // Basic password validation if (password.length < 8) { setError("Password must be at least 8 characters long."); setIsLoading(false); return; } try { const result = await authClient.signUp.email({ email, password, name, }); if (result.error) { setError(result.error.message || "Failed to create account. Please try again."); setIsLoading(false); return; } navigate("/dashboard"); } catch (err) { setError("An unexpected error occurred. Please try again."); setIsLoading(false); } }; return (
{/* Navigation */} {/* Signup Form */}

Create your account

Get started for free. No credit card required.

{error && (

{error}

)}
setName(e.target.value)} placeholder="Your name" required disabled={isLoading} className="w-full px-3 py-2 border border-input rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed" />
setEmail(e.target.value)} placeholder="you@example.com" required disabled={isLoading} className="w-full px-3 py-2 border border-input rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed" />
setPassword(e.target.value)} placeholder="At least 8 characters" required disabled={isLoading} className="w-full px-3 py-2 border border-input rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed" />

Must be at least 8 characters long

By creating an account, you agree to our Terms of Service and Privacy Policy.

Already have an account?{" "}

); }