'use client'; import { zodResolver } from '@hookform/resolvers/zod'; import { Loader2 } from 'lucide-react'; import { useRouter } from 'next/navigation'; import { useTranslations } from 'next-intl'; import { useState } from 'react'; import { useForm } from 'react-hook-form'; import { OAuthButtons } from '@/components/auth/oauth-buttons'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Link } from '@/i18n/navigation'; import { useAuthStore } from '@/lib/auth-store'; import { registerSchema, type RegisterFormData } from '@/lib/validations/auth'; export default function RegisterPage() { const router = useRouter(); const { register: registerUser, isLoading, error, clearError } = useAuthStore(); const [showPassword, setShowPassword] = useState(false); const t = useTranslations('auth'); const { register, handleSubmit, formState: { errors }, } = useForm({ resolver: zodResolver(registerSchema), }); const onSubmit = async (data: RegisterFormData) => { try { await registerUser({ phone: data.phone, password: data.password, fullName: data.fullName, email: data.email || undefined, }); router.push('/'); } catch { // Error is handled by the store } }; return ( {t('registerTitle')} {t('registerDescription')}
{error && (
{error}
)}
{errors.fullName && ( )}
{errors.phone && ( )}
{errors.email && ( )}
{errors.password && ( )}
{errors.confirmPassword && ( )}
{t('orRegisterWith')}

{t('hasAccount')}{' '} {t('loginLink')}

); }