diff --git a/apps/web-client/src/app/(auth)/register/page.tsx b/apps/web-client/src/app/(auth)/register/page.tsx index aa7b51b6..40d8c2a1 100644 --- a/apps/web-client/src/app/(auth)/register/page.tsx +++ b/apps/web-client/src/app/(auth)/register/page.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useForm } from 'react-hook-form'; +import { useForm, Controller } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import { z } from 'zod'; import { useRouter } from 'next/navigation'; @@ -12,6 +12,7 @@ import { Input } from '@/features/shared/components/ui/input'; import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/features/shared/components/ui/card'; import { useTranslations } from 'next-intl'; import { AuthControls } from '@/features/shared/components/layout/auth-controls'; +import { cn } from '@/shared/utils'; /** * EN: Create register schema with translated messages @@ -151,10 +152,9 @@ export default function RegisterPage() { // EN: React Hook Form setup with Zod resolver // VI: Setup React Hook Form với Zod resolver const { - register, + control, handleSubmit, watch, - setValue, formState: { errors, isSubmitting }, } = useForm({ resolver: zodResolver(registerSchema), @@ -291,52 +291,64 @@ export default function RegisterPage() {
{/* EN: Full name input field / VI: Trường nhập họ tên */} - { - register('fullName').onChange(e); - setValue('fullName', e.target.value); - }} - autoComplete="name" - aria-required="true" + ( + + )} /> {/* EN: Email input field / VI: Trường nhập email */} - { - register('email').onChange(e); - setValue('email', e.target.value); - }} - autoComplete="email" - aria-required="true" + ( + + )} /> {/* EN: Password input field / VI: Trường nhập mật khẩu */}
- { - register('password').onChange(e); - setValue('password', e.target.value); - }} - autoComplete="new-password" - aria-required="true" + ( + + )} /> {/* EN: Password strength indicator / VI: Chỉ báo độ mạnh mật khẩu */} @@ -372,52 +384,64 @@ export default function RegisterPage() {
{/* EN: Confirm password input field / VI: Trường xác nhận mật khẩu */} - { - register('confirmPassword').onChange(e); - setValue('confirmPassword', e.target.value); - }} - autoComplete="new-password" - aria-required="true" + ( + + )} /> {/* EN: Terms and conditions checkbox / VI: Checkbox điều khoản và điều kiện */} -
- - {errors.terms && ( -

- {errors.terms.message} -

+ ( +
+ + {errors.terms && ( +

+ {errors.terms.message} +

+ )} +
)} -
+ />
{/* EN: Submit button with loading state / VI: Nút submit với trạng thái loading */}