trithuc-mvc-react 2.9.8 → 2.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -65,13 +65,9 @@ const DataTable = ({ multipleActions = [], page, setPage = () => {}, disableEdit
65
65
  queryClient.invalidateQueries({ queryKey: [tableName] });
66
66
  },
67
67
  onError: (error) => {
68
- if (error.response && error.response.data && error.response.data.errors) {
69
- const errors = error.response.data.errors;
70
- // Chuyển đổi đối tượng lỗi thành chuỗi để hiển thị
71
- const errorMessages = Object.entries(errors)
72
- .map(([field, messages]) => `${field}: ${messages.join(", ")}`)
73
- .join("\n");
74
- toast.error(errorMessages);
68
+ if (error.response && error.response.data) {
69
+ const message = error.response.data.message;
70
+ toast.error(message);
75
71
  } else {
76
72
  // Nếu lỗi không theo định dạng mong đợi, hiển thị thông tin lỗi chung
77
73
  toast.error("Đã xảy ra lỗi không mong muốn.");
@@ -93,13 +89,9 @@ const DataTable = ({ multipleActions = [], page, setPage = () => {}, disableEdit
93
89
  queryClient.invalidateQueries({ queryKey: [tableName] });
94
90
  },
95
91
  onError: (error) => {
96
- if (error.response && error.response.data && error.response.data.errors) {
97
- const errors = error.response.data.errors;
98
- // Chuyển đổi đối tượng lỗi thành chuỗi để hiển thị
99
- const errorMessages = Object.entries(errors)
100
- .map(([field, messages]) => `${field}: ${messages.join(", ")}`)
101
- .join("\n");
102
- toast.error(errorMessages);
92
+ if (error.response && error.response.data) {
93
+ const message = error.response.data.message;
94
+ toast.error(message);
103
95
  } else {
104
96
  // Nếu lỗi không theo định dạng mong đợi, hiển thị thông tin lỗi chung
105
97
  toast.error("Đã xảy ra lỗi không mong muốn.");
@@ -117,13 +109,9 @@ const DataTable = ({ multipleActions = [], page, setPage = () => {}, disableEdit
117
109
  queryClient.invalidateQueries({ queryKey: [tableName] });
118
110
  },
119
111
  onError: (error) => {
120
- if (error.response && error.response.data && error.response.data.errors) {
121
- const errors = error.response.data.errors;
122
- // Chuyển đổi đối tượng lỗi thành chuỗi để hiển thị
123
- const errorMessages = Object.entries(errors)
124
- .map(([field, messages]) => `${field}: ${messages.join(", ")}`)
125
- .join("\n");
126
- toast.error(errorMessages);
112
+ if (error.response && error.response.data) {
113
+ const message = error.response.data.message;
114
+ toast.error(message);
127
115
  } else {
128
116
  // Nếu lỗi không theo định dạng mong đợi, hiển thị thông tin lỗi chung
129
117
  toast.error("Đã xảy ra lỗi không mong muốn.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "2.9.8",
3
+ "version": "2.9.9",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"