trithuc-mvc-react 2.9.7 → 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.");
@@ -6,6 +6,7 @@ import { useDataTable } from "./hooks";
6
6
 
7
7
  import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
8
8
  import AccordionDetails from "@mui/material/AccordionDetails";
9
+ import moment from "moment";
9
10
  import { DateRangePicker } from "../date";
10
11
 
11
12
  export const FilterGod = ({ filters, elementSize = "small", setPage = () => {} }) => {
@@ -43,15 +44,22 @@ export const FilterGod = ({ filters, elementSize = "small", setPage = () => {} }
43
44
  <DateRangePicker
44
45
  label={label}
45
46
  onChange={(value) => {
46
- setDataSearch({
47
- ...dataSearch,
48
- [field[0]]: value[0],
49
- [field[1]]: value[1]
50
- });
51
- setPage(0);
47
+ const [fromDate, toDate] = value || []; // Destructure value để đảm bảo xử lý null/undefined
48
+ const formattedFromDate = fromDate ? moment(fromDate).format("YYYY-MM-DD HH:mm:ss.SSS") : null;
49
+ const formattedToDate = toDate ? moment(toDate).format("YYYY-MM-DD HH:mm:ss.SSS") : null;
50
+
51
+ // Kiểm tra nếu field hợp lệ trước khi cập nhật
52
+ if (field?.[0] && field?.[1]) {
53
+ setDataSearch({
54
+ ...dataSearch,
55
+ [field[0]]: formattedFromDate,
56
+ [field[1]]: formattedToDate
57
+ });
58
+ setPage(0);
59
+ }
52
60
  }}
53
61
  size={elementSize}
54
- value={[dataSearch?.[field[0]], dataSearch?.[field[1]]]}
62
+ value={[dataSearch?.[field?.[0]] || null, dataSearch?.[field?.[1]] || null]}
55
63
  />
56
64
  </Grid>
57
65
  );
@@ -26,7 +26,7 @@ DataManagement.propTypes = {
26
26
  selectedField: PropTypes.string,
27
27
  filters: PropTypes.arrayOf(
28
28
  PropTypes.shape({
29
- field: PropTypes.string,
29
+ field: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]).isRequired,
30
30
  label: PropTypes.string,
31
31
  placeHolder: PropTypes.string,
32
32
  type: PropTypes.oneOf([
@@ -39,12 +39,13 @@ DataManagement.propTypes = {
39
39
  "radio",
40
40
  "switch",
41
41
  "search",
42
+ "select",
43
+ "date-range",
42
44
  "default"
43
45
  ]),
44
- onChangeAfter: PropTypes.func,
45
- filters: PropTypes.array
46
+ onChangeAfter: PropTypes.func
46
47
  })
47
- ),
48
+ ).isRequired,
48
49
  editorFields: PropTypes.array,
49
50
  validationSchema: PropTypes.object,
50
51
  disableStatus: PropTypes.bool,
@@ -17,7 +17,6 @@ const usePermission = (tableName) => {
17
17
  if (permission) {
18
18
  if (permission.TrangThaiXuLy !== undefined && permission.ObjTrangThai) {
19
19
  const status = permission.ObjTrangThai.find((t) => t.StatusId === permission.TrangThaiXuLy) || {};
20
-
21
20
  return {
22
21
  canEdit: status.Edit ?? false,
23
22
  canDelete: status.Delete ?? false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "2.9.7",
3
+ "version": "2.9.9",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -38,13 +38,13 @@
38
38
  "@mui/icons-material": "^5.15.12",
39
39
  "@mui/lab": "^5.0.0-alpha.142",
40
40
  "@mui/material": "^5.15.12",
41
- "@mui/x-date-pickers": "^7.22.1",
41
+ "@mui/x-date-pickers": "^6.10.2",
42
42
  "@mui/x-tree-view": "^7.22.1",
43
+ "material-ui-confirm": "^3.0.9",
43
44
  "react": ">=16",
44
45
  "react-dom": ">=16",
46
+ "react-hook-form": "^7.45.2",
45
47
  "react-query": "^3.39.3",
46
- "react-toastify": "^10.0.6",
47
- "material-ui-confirm": "^3.0.9",
48
- "react-hook-form": "^7.45.2"
48
+ "react-toastify": "^10.0.6"
49
49
  }
50
50
  }