mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 11:49:19 +00:00
improvement: translated all backend errors messages
This commit is contained in:
@@ -83,9 +83,15 @@ const UserModal = ({ open, onClose, userId }) => {
|
||||
return { ...prevState, ...data };
|
||||
});
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
if (err.response && err.response.data && err.response.data.error) {
|
||||
toast.error(err.response.data.error);
|
||||
const errorMsg = err.response?.data?.error;
|
||||
if (errorMsg) {
|
||||
if (i18n.exists(`backendErrors.${errorMsg}`)) {
|
||||
toast.error(i18n.t(`backendErrors.${errorMsg}`));
|
||||
} else {
|
||||
toast.error(err.response.data.error);
|
||||
}
|
||||
} else {
|
||||
toast.error("Unknown error");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -107,9 +113,15 @@ const UserModal = ({ open, onClose, userId }) => {
|
||||
}
|
||||
toast.success(i18n.t("userModal.success"));
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
if (err.response && err.response.data && err.response.data.error) {
|
||||
toast.error(err.response.data.error);
|
||||
const errorMsg = err.response?.data?.error;
|
||||
if (errorMsg) {
|
||||
if (i18n.exists(`backendErrors.${errorMsg}`)) {
|
||||
toast.error(i18n.t(`backendErrors.${errorMsg}`));
|
||||
} else {
|
||||
toast.error(err.response.data.error);
|
||||
}
|
||||
} else {
|
||||
toast.error("Unknown error");
|
||||
}
|
||||
}
|
||||
handleClose();
|
||||
|
||||
Reference in New Issue
Block a user