'use client';
import { useState } from 'react';
import { useRouter } from 'next/navigation';
import { useAuthStore } from '@/lib/store';
import { toast } from 'react-toastify';
import { UserPlus, ArrowLeft } from 'lucide-react';
import { AuthShell } from '@/components/auth/AuthShell';
import { AuthField } from '@/components/auth/AuthField';
export default function RegisterPage() {
const [form, setForm] = useState({ email: '', password: '', firstName: '', lastName: '' });
const [isLoading, setIsLoading] = useState(false);
const register = useAuthStore((s) => s.register);
const router = useRouter();
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setIsLoading(true);
try {
await register(form);
toast.success('حساب با موفقیت ساخته شد!');
router.push('/dashboard');
} catch (err: any) {
toast.error(err.response?.data?.message || 'ثبتنام ناموفق بود');
} finally {
setIsLoading(false);
}
};
return (