From e240160ee18c3029e9304aa7e373910524bbd86c Mon Sep 17 00:00:00 2001 From: sergiorodriguezgarcia <113514397+sergiorodriguezgarcia@users.noreply.github.com> Date: Sun, 28 Apr 2024 17:46:58 +0200 Subject: [PATCH] feat: Sending error when confirmPassword is blank --- webapp/public/locales/en/translation.json | 4 +++- webapp/public/locales/es/translation.json | 4 +++- webapp/src/pages/Signup.jsx | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/webapp/public/locales/en/translation.json b/webapp/public/locales/en/translation.json index 0894c3bd..9196de2f 100644 --- a/webapp/public/locales/en/translation.json +++ b/webapp/public/locales/en/translation.json @@ -53,7 +53,9 @@ "authorized": { "type": "Authorization Error: ", "message": "Invalid email or password, check for them to be correct" - } + }, + "empty_password": "The confirm password label can not be empty", + "password_mismatch": "The password and confirm password labels must match" }, "rules": { "description1": "Welcome to the exciting world of KiWiQ! In this challenging game, your goal is to embark on a journey full of knowledge and fun.", diff --git a/webapp/public/locales/es/translation.json b/webapp/public/locales/es/translation.json index 73665564..c0fa406e 100644 --- a/webapp/public/locales/es/translation.json +++ b/webapp/public/locales/es/translation.json @@ -53,7 +53,9 @@ "authorized": { "type": "Error de Autorización: ", "message": "Correo electrónico o contraseña no válidos, verifique que sean correctos" - } + }, + "empty_password": "La confirmación de contraseña no puede estar vacía", + "password_mismatch": "Las contraseñas no coinciden" }, "rules": { "description1": "¡Bienvenidos al emocionante mundo de KiWiQ! En este desafiante juego, tu objetivo es embarcarte en un viaje lleno de conocimiento y diversión.", diff --git a/webapp/src/pages/Signup.jsx b/webapp/src/pages/Signup.jsx index 9708f9bc..3fc8ed40 100644 --- a/webapp/src/pages/Signup.jsx +++ b/webapp/src/pages/Signup.jsx @@ -19,6 +19,7 @@ export default function Signup() { const [showPassword, setShowPassword] = useState(false); const [showConfirmPassword, setShowConfirmPassword] = useState(false); const [errorMessage, setErrorMessage] = useState(null); + const [isSubmitting, setIsSubmitting] = useState(false); const navigate = useNavigate(); const { t, i18n } = useTranslation(); @@ -32,7 +33,13 @@ export default function Signup() { navigate("/dashboard"); } } + const sendRegistration = async () => { + setIsSubmitting(true); + if (confirmPassword.trim() === "") { + setErrorMessage({ type: t("error.conflict.type"), message: t("error.empty_password") }); + return; + } const registerData = { "email": email, "username": username, @@ -169,7 +176,7 @@ export default function Signup() { {confirmPassword && password && confirmPassword !== password && ( - Las contraseñas no coinciden + {t("error.password_mismatch")} )}