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