'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import Link from 'next/link' import Image from 'next/image' import { authAPI } from '@/lib/api' import { saveAuth } from '@/lib/auth' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card' export default function RegisterPage() { const router = useRouter() const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('') const [error, setError] = useState('') const [loading, setLoading] = useState(false) 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 data = await authAPI.register(email, password) saveAuth(data.token, data.user) router.push('/dashboard') } catch (err: any) { const message = err.response?.data?.message || 'Failed to register' const details = err.response?.data?.details if (details && Array.isArray(details)) { setError(details.join(', ')) } else { setError(message) } } finally { setLoading(false) } } return (
{/* Subtle Background Pattern */}
SiteChangeMonitor Logo
Create account Start monitoring your websites for changes
{error && (
{error}
)}
setEmail(e.target.value)} placeholder="you@example.com" required /> setPassword(e.target.value)} placeholder="••••••••" hint="At least 8 characters with uppercase, lowercase, and number" required /> setConfirmPassword(e.target.value)} placeholder="••••••••" required />

Already have an account?{' '} Sign in

) }