From 63306aa0526a24c2f93bf8a01fc1a5c8c3b66221 Mon Sep 17 00:00:00 2001 From: Yan Luiz Date: Wed, 18 Sep 2024 22:48:05 -0300 Subject: [PATCH] fix: svg path and email regex --- pages/auth/index.js | 21 +++++++++++++-------- public/assets/img/eye.svg | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 public/assets/img/eye.svg diff --git a/pages/auth/index.js b/pages/auth/index.js index 548f4062..0318276b 100644 --- a/pages/auth/index.js +++ b/pages/auth/index.js @@ -18,15 +18,15 @@ function authPage() { const [showpass, setShowPass] = useState(false) const { t } = useTranslation() - const [isSignUp, setIsSignUp] = useState(false) // Toggle for sign-up + const [isSignUp, setIsSignUp] = useState(false) const [email, setEmail] = useState('') const { register, handleSubmit } = useForm() const onSubmit = (data) => { if (isSignUp) { - signup(data) // Handle sign-up + signup(data) } else { - login(data) // Handle login + login(data) } } @@ -70,7 +70,7 @@ function authPage() { > {isSignUp ? t('form.already_have_account') : t('form.no_account')}{' '} setIsSignUp(!isSignUp)} // Toggle between sign-in and sign-up + onClick={() => setIsSignUp(!isSignUp)} className="cursor-pointer text-sm font-medium leading-none text-primary-300 hover:text-gray-500" > {isSignUp ? t('buttons.sign_in') : t('buttons.register_now')} @@ -93,7 +93,8 @@ function authPage() { {...register('email', { required: t('form.enter_email'), message: t('form.invalid_email'), - pattern: /.../, // Your email regex pattern + pattern: + /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/i, })} /> @@ -109,6 +110,7 @@ function authPage() { id="password" type={showpass ? 'text' : 'password'} className="mt-2 w-full rounded border bg-gray-200 py-3 pl-3 text-xs font-medium leading-none text-gray-800" + placeholder="" {...register('password', { required: t('form.enter_password'), message: t('form.verify_password'), @@ -119,8 +121,11 @@ function authPage() { onClick={() => setShowPass(!showpass)} className="absolute right-0 mt-2 mr-3 cursor-pointer" > - {showpass ? Hide : Show}{' '} - {/* Ensure the text is displayed */} + {showpass @@ -142,7 +147,7 @@ function authPage() { >

)} - {!isSignUp && ( // Ensure this shows only during login + {!isSignUp && (

+ \ No newline at end of file