Skip to content

Commit

Permalink
Merge pull request #308 from Arquisoft/develop
Browse files Browse the repository at this point in the history
error with confirm password
  • Loading branch information
Toto-hitori authored Apr 28, 2024
2 parents 22d7a67 + e9a42d7 commit f08dbc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion webapp/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
4 changes: 3 additions & 1 deletion webapp/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
9 changes: 8 additions & 1 deletion webapp/src/pages/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
Expand Down Expand Up @@ -169,7 +176,7 @@ export default function Signup() {
</InputRightElement>
</InputGroup>
{confirmPassword && password && confirmPassword !== password && (
<FormHelperText color="red">Las contraseñas no coinciden</FormHelperText>
<FormHelperText color="red">{t("error.password_mismatch")}</FormHelperText>
)}
</FormControl>
<Flex>
Expand Down

0 comments on commit f08dbc6

Please sign in to comment.