From 018a7aefc7fb3485ac8ca2556535cef522750f2b Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Wed, 8 Jul 2026 15:10:53 +0200 Subject: [PATCH] refactor: change password validation and add more success alerts --- .../src/components/modals/ChangePasswordModal.tsx | 15 +++++---------- frontend/src/pages/Settings.tsx | 6 ++++++ frontend/src/utils/i18n/locales/de/de.json | 3 ++- frontend/src/utils/i18n/locales/en/en.json | 3 ++- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/modals/ChangePasswordModal.tsx b/frontend/src/components/modals/ChangePasswordModal.tsx index f76a4af..dbcd1e6 100644 --- a/frontend/src/components/modals/ChangePasswordModal.tsx +++ b/frontend/src/components/modals/ChangePasswordModal.tsx @@ -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({ diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index 510dbec..be562e7 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -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, diff --git a/frontend/src/utils/i18n/locales/de/de.json b/frontend/src/utils/i18n/locales/de/de.json index 9514561..6722956 100644 --- a/frontend/src/utils/i18n/locales/de/de.json +++ b/frontend/src/utils/i18n/locales/de/de.json @@ -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." -} \ No newline at end of file +} diff --git a/frontend/src/utils/i18n/locales/en/en.json b/frontend/src/utils/i18n/locales/en/en.json index 45456cc..cda7e7a 100644 --- a/frontend/src/utils/i18n/locales/en/en.json +++ b/frontend/src/utils/i18n/locales/en/en.json @@ -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." -} \ No newline at end of file +}