'use client' import { Suspense, useState } from 'react' import { useRouter, useSearchParams } from 'next/navigation' import Link from 'next/link' import { Heart } from 'lucide-react' import { Button, Input, Card, showToast } from '@/components/ui' function RegisterForm() { const router = useRouter() const searchParams = useSearchParams() const redirectTo = searchParams.get('redirect') const [name, setName] = useState('') const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('') const [loading, setLoading] = useState(false) const [error, setError] = useState('') const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError('') if (password !== confirmPassword) { setError('Passwords do not match') return } if (password.length < 8) { setError('Password must be at least 8 characters') return } setLoading(true) try { const response = await fetch('/api/auth/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, email, password }), }) const data = await response.json() if (!response.ok) { setError(data.error || 'Registration failed') return } showToast('Account created! Let\'s get started.', 'success') // If there's a redirect param (e.g., from invite link), go there instead of onboarding router.push(redirectTo || '/onboarding') router.refresh() } catch { setError('Something went wrong. Please try again.') } finally { setLoading(false) } } return (
{/* Logo */}

Create Account

Join Next Step to get started

setName(e.target.value)} placeholder="e.g., Grace" required autoComplete="name" /> setEmail(e.target.value)} placeholder="you@example.com" required autoComplete="email" /> setPassword(e.target.value)} placeholder="At least 8 characters" required autoComplete="new-password" /> setConfirmPassword(e.target.value)} placeholder="Confirm your password" required autoComplete="new-password" /> {error && (

{error}

)}

Already have an account?{' '} Sign in

) } export default function RegisterPage() { return (
}>
) }