trithuc-mvc-react 2.9.9 → 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.
|
@@ -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
|