refactor: change password validation and add more success alerts

This commit is contained in:
2026-07-08 15:10:53 +02:00
parent 6be34c93aa
commit 018a7aefc7
4 changed files with 15 additions and 12 deletions
@@ -1,12 +1,4 @@
import {
Alert,
Button,
DialogTitle,
Input,
Modal,
ModalDialog,
Stack,
} from "@mui/joy";
import { Alert, Button, DialogTitle, Input, Modal, ModalDialog, Stack, } from "@mui/joy";
import { useForm } from "@tanstack/react-form";
import { useMutation } from "@tanstack/react-query";
import { useTranslation } from "react-i18next";
@@ -39,7 +31,10 @@ export const ChangePasswordModal = (props: ChangePasswordProps) => {
onSubmit: async ({ value }) => {
console.log(value);
if (value.newPassword === value.newPasswordRep) {
if (
value.newPassword === value.newPasswordRep &&
value.newPassword !== ""
) {
mutate(value);
} else {
setAlert({
+6
View File
@@ -82,6 +82,12 @@ export const Settings = () => {
const { mutate } = useMutation({
mutationFn: (values: SettingsIntf) => mutateSettings(values),
onSuccess() {
setAlert({
isAlert: true,
type: "success",
header: t("success"),
text: t("SE001"),
});
queryClient.invalidateQueries({ queryKey: ["settings"] });
},
onError: showError,
+2 -1
View File
@@ -58,6 +58,7 @@
"success": "Erfolg",
"submit": "Absenden",
"SU005": "Das Passwort wurde erfolgreich geändert!",
"SE001": "Die Einstellungen wurden erfolgreich geändert!",
"EG001": "Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.",
"EU001": "Falscher Benutzername oder Passwort!",
"EU002": "Ihr Konto wurde deaktiviert. Bitte wenden Sie sich an einen Administrator.",
@@ -83,4 +84,4 @@
"EP006": "Das Produkt konnte nicht gelöscht werden. Bitte versuchen Sie es erneut.",
"EP007": "Bitte geben Sie mindestens einen Produktnamen ein.",
"EP008": "Einige erforderliche Produktinformationen fehlen. Bitte überprüfen Sie Ihre Eingabe."
}
}
+2 -1
View File
@@ -58,6 +58,7 @@
"success": "Success",
"submit": "Submit",
"SU005": "Your password is updated successfully!",
"SE001": "The settings are updated successfully!",
"EG001": "An unexpected error occurred. Please try again later.",
"EU001": "Wrong username or password!",
"EU002": "Your account has been deactivated. Please contact an administrator.",
@@ -83,4 +84,4 @@
"EP006": "The product could not be deleted. Please try again.",
"EP007": "Please enter at least a product name.",
"EP008": "Some required product information is missing. Please check your input."
}
}