trithuc-mvc-react 2.9.8 → 3.0.0
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
|
|
69
|
-
const
|
|
70
|
-
|
|
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
|
|
97
|
-
const
|
|
98
|
-
|
|
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
|
|
121
|
-
const
|
|
122
|
-
|
|
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.");
|
|
@@ -7,16 +7,28 @@ import { useDataTable } from "./hooks";
|
|
|
7
7
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
8
8
|
import AccordionDetails from "@mui/material/AccordionDetails";
|
|
9
9
|
import moment from "moment";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
10
11
|
import { DateRangePicker } from "../date";
|
|
11
12
|
|
|
12
|
-
export const FilterGod = ({ filters, elementSize = "small", setPage = () => {} }) => {
|
|
13
|
+
export const FilterGod = ({ tableName, filters, elementSize = "small", setPage = () => {} }) => {
|
|
13
14
|
const { handleSubmit } = useFormContext();
|
|
14
15
|
const onSubmit = (data) => console.log(data);
|
|
15
16
|
const { setDataSearch, dataSearch } = useDataTable();
|
|
17
|
+
// Lấy trạng thái từ localStorage hoặc mặc định là true
|
|
18
|
+
const [isFilterVisible, setFilterVisible] = useState(
|
|
19
|
+
() => JSON.parse(localStorage.getItem(`${tableName}-isFilterVisible`)) ?? true
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// Lưu trạng thái vào localStorage mỗi khi thay đổi
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
localStorage.setItem(`${tableName}-isFilterVisible`, JSON.stringify(isFilterVisible));
|
|
25
|
+
}, [isFilterVisible]);
|
|
26
|
+
|
|
27
|
+
const toggleFilterVisibility = () => setFilterVisible((prev) => !prev);
|
|
16
28
|
|
|
17
29
|
return (
|
|
18
30
|
<Box component={"form"}>
|
|
19
|
-
<Accordion>
|
|
31
|
+
<Accordion expanded={isFilterVisible} onChange={toggleFilterVisibility}>
|
|
20
32
|
<AccordionSummary
|
|
21
33
|
sx={{
|
|
22
34
|
minHeight: 40,
|
|
@@ -258,7 +258,7 @@ function DataManagement({
|
|
|
258
258
|
|
|
259
259
|
<Card>
|
|
260
260
|
{tabPanel}
|
|
261
|
-
<FilterGod filters={filters} elementSize={elementSize} setPage={setPage} />
|
|
261
|
+
<FilterGod tableName={tableName} filters={filters} elementSize={elementSize} setPage={setPage} />
|
|
262
262
|
{backParentNavigator}
|
|
263
263
|
{!isSmallScreen ? (
|
|
264
264
|
<DataTable
|