trithuc-mvc-react 2.4.7 → 2.4.8

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.
@@ -13,7 +13,7 @@ import { TableRowRender } from "./TableRowRender";
13
13
  import TableToolbar from "./TableToolbar";
14
14
  import { useDataTable } from "./hooks";
15
15
  import { usePermission } from "../../hooks";
16
- const DataTable = ({ multipleActions = [] }) => {
16
+ const DataTable = ({ multipleActions = [],page, setPage = () => { } }) => {
17
17
  const {
18
18
  tableName,
19
19
  selectedField,
@@ -31,7 +31,7 @@ const DataTable = ({ multipleActions = [] }) => {
31
31
  const queryClient = useQueryClient();
32
32
  const confirm = useConfirm();
33
33
  const [selectedItems, setSelectedItems] = useState([]);
34
- const [page, setPage] = useState(0);
34
+ // const [page, setPage] = useState(0);
35
35
  const [rowsPerPage, setRowsPerPage] = useState(defaultRowsPerPage);
36
36
 
37
37
  const { data, isLoading } = useQuery({
@@ -14,9 +14,10 @@ export function FilterElement({
14
14
  childrenFields,
15
15
  datas,
16
16
  loading = false,
17
- onChange = () => {},
17
+ onChange = () => { },
18
18
  size = "small",
19
- handleChange = () => {},
19
+ handleChange = () => { },
20
+ setPage = () => { },
20
21
  }) {
21
22
  const { control, setValue } = useFormContext();
22
23
 
@@ -43,6 +44,7 @@ export function FilterElement({
43
44
  onChange={(e) => {
44
45
  onFieldChange(e);
45
46
  handleFilterChangeDebounce(name, e.target.value);
47
+ setPage(0);
46
48
  }}
47
49
  placeholder={label}
48
50
  variant="outlined"
@@ -72,9 +74,8 @@ export function FilterElement({
72
74
  onChange={(event, newValue, reason) => {
73
75
  let updateObject = { [name]: newValue?.[keyValue] };
74
76
  onFieldChange(newValue?.[keyValue]);
75
-
76
77
  onChange(newValue);
77
-
78
+ setPage(0);
78
79
  childrenFields?.forEach((childrenField) => {
79
80
  setValue(childrenField, null, { shouldTouch: true });
80
81
  updateObject[childrenField] = null;
@@ -103,6 +104,7 @@ export function FilterElement({
103
104
  onChange={(e) => {
104
105
  handleChange(e);
105
106
  onFieldChange(e);
107
+ setPage(0);
106
108
  setDataSearch({ ...dataSearch, [name]: e.target.value });
107
109
  }}
108
110
  >
@@ -10,7 +10,7 @@ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
10
10
  import { DateRangePicker } from "../date";
11
11
  import { ArraySchema } from "yup";
12
12
 
13
- export const FilterGod = ({ filters, elementSize = "small" }) => {
13
+ export const FilterGod = ({ filters, elementSize = "small",setPage=()=>{} }) => {
14
14
  const { handleSubmit } = useFormContext();
15
15
  const onSubmit = (data) => console.log(data);
16
16
  const { setDataSearch, dataSearch } = useDataTable();
@@ -50,7 +50,8 @@ export const FilterGod = ({ filters, elementSize = "small" }) => {
50
50
  [field[0]]: value[0],
51
51
  [field[1]]: value[1]
52
52
  });
53
- }}
53
+ setPage(0)
54
+ }}
54
55
  size={elementSize}
55
56
  value={[dataSearch?.[field[0]], dataSearch?.[field[1]]]}
56
57
  />
@@ -68,6 +69,7 @@ export const FilterGod = ({ filters, elementSize = "small" }) => {
68
69
  [field[0]]: value[0],
69
70
  [field[1]]: value[1]
70
71
  });
72
+ setPage(0)
71
73
  }}
72
74
  size={elementSize}
73
75
  marks={rest.marks}
@@ -81,7 +83,7 @@ export const FilterGod = ({ filters, elementSize = "small" }) => {
81
83
  }
82
84
  return (
83
85
  <Grid key={field} md={size?.md} xs={size?.xs} sm={size?.sm}>
84
- <FilterElement name={field} {...rest} />
86
+ <FilterElement name={field} {...rest} setPage={setPage}/>
85
87
  </Grid>
86
88
  );
87
89
  })}
@@ -108,6 +108,8 @@ function DataManagement({
108
108
  }, [filters]);
109
109
 
110
110
  const [dataSearch, setDataSearch] = useState({ ...defaults, ...getDefaultValues(filters) });
111
+ const [page, setPage] = useState(0);
112
+
111
113
  const values = useMemo(() => {
112
114
  const hasTabpanel = !!tabPanel;
113
115
  return {
@@ -206,9 +208,9 @@ function DataManagement({
206
208
 
207
209
  <Card>
208
210
  {tabPanel}
209
- <FilterGod filters={filters} elementSize={elementSize} />
211
+ <FilterGod filters={filters} elementSize={elementSize} setPage={setPage} />
210
212
  {backParentNavigator}
211
- <DataTable multipleActions={multipleActions} />
213
+ <DataTable multipleActions={multipleActions} page={page} setPage={setPage}/>
212
214
  </Card>
213
215
  </FormProvider>
214
216
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "2.4.7",
3
+ "version": "2.4.8",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"