mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 03:39:29 +00:00
improvement: started translation of backend errors
This commit is contained in:
@@ -25,12 +25,6 @@ const useStyles = makeStyles(theme => ({
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
},
|
||||
|
||||
// btnWrapper: {
|
||||
// // margin: theme.spacing(1),
|
||||
// // position: "relative",
|
||||
// display: "flex",
|
||||
// },
|
||||
}));
|
||||
|
||||
const filterOptions = createFilterOptions({
|
||||
@@ -89,9 +83,15 @@ const NewTicketModal = ({ modalOpen, onClose }) => {
|
||||
});
|
||||
history.push(`/tickets/${ticket.id}`);
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
setLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user