Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error with confirm password #308

Merged
merged 2 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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