'use client' import { useState } from 'react' import { signIn } from 'next-auth/react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Link2, Mail, Lock, User } from 'lucide-react' import Link from 'next/link' import { toast } from 'sonner' import { useRouter } from 'next/navigation' export function SignupClient() { const [name, setName] = useState('') const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [loading, setLoading] = useState(false) const router = useRouter() const handleSignup = async (e: React.FormEvent) => { e.preventDefault() if (password.length < 6) { toast.error('Password must be at least 6 characters'); return } setLoading(true) try { const res = await fetch('/api/signup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, password, name }), }) const data = await res.json() if (res.ok) { // Auto sign in const result = await signIn('credentials', { email, password, redirect: false }) if (result?.ok) { router.push('/pages') } else { toast.success('Account created! Please sign in.') router.push('/login') } } else { toast.error(data?.error ?? 'Signup failed') } } catch { toast.error('Error creating account') } setLoading(false) } return (

Create Account

Join computer to start organizing your links

) => setName(e.target.value)} className="pl-10" />
) => setEmail(e.target.value)} className="pl-10" required />
) => setPassword(e.target.value)} className="pl-10" minLength={8} required />

Already have an account? Sign in

) }