'use client'; import { useState } from 'react'; export default function SignUp() { const [formData, setFormData] = useState({ name: '', email: '', password: '', confirmPassword: '' }); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [success, setSuccess] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(''); if (formData.password !== formData.confirmPassword) { setError('Passwords do not match'); setLoading(false); return; } try { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/auth/register`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: formData.name, email: formData.email, password: formData.password }) }); const data = await response.json(); if (!response.ok) { setError(data.error || 'Registration failed'); } else { setSuccess(true); setTimeout(() => { window.location.href = '/auth/signin'; }, 2000); } } catch (err) { setError('Registration failed'); } finally { setLoading(false); } }; if (success) { return (

Account Created!

Redirecting to sign in...

); } return (

Fiscal Clone

Create your account

{error && (
{error}
)}
setFormData({...formData, name: e.target.value})} className="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-4 py-3 text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="John Doe" required />
setFormData({...formData, email: e.target.value})} className="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-4 py-3 text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="you@example.com" required />
setFormData({...formData, password: e.target.value})} className="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-4 py-3 text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="•••••••••" required minLength={8} />
setFormData({...formData, confirmPassword: e.target.value})} className="w-full bg-slate-700/50 border border-slate-600 rounded-lg px-4 py-3 text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="•••••••••" required minLength={8} />

Already have an account?{' '} Sign in

); }