trithuc-mvc-react 1.5.4 → 1.5.6
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.
|
@@ -1,92 +1,91 @@
|
|
|
1
|
-
import { Slider, Toolbar } from "@mui/material";
|
|
1
|
+
import { Accordion, AccordionSummary, Box, FormControl, InputLabel, MenuItem, Select, Slider, Toolbar, Typography } from "@mui/material";
|
|
2
2
|
import { useFormContext } from "react-hook-form";
|
|
3
3
|
import Grid from "@mui/material/Unstable_Grid2";
|
|
4
4
|
import DateRangePicker from "../date/DateRangePicker";
|
|
5
5
|
import { FilterElement } from "./FilterElement";
|
|
6
6
|
import { useDataTable } from "./hooks";
|
|
7
7
|
|
|
8
|
+
import AccordionDetails from '@mui/material/AccordionDetails';
|
|
9
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
10
|
+
|
|
8
11
|
export const FilterGod = ({ filters, elementSize = "small" }) => {
|
|
9
12
|
const { handleSubmit } = useFormContext();
|
|
10
13
|
const onSubmit = (data) => console.log(data);
|
|
11
14
|
const { setDataSearch, dataSearch } = useDataTable();
|
|
12
15
|
|
|
13
16
|
return (
|
|
14
|
-
<
|
|
17
|
+
<Box
|
|
15
18
|
component={"form"}
|
|
16
|
-
disableGutters
|
|
17
19
|
onSubmit={handleSubmit(onSubmit)}
|
|
18
|
-
sx={{
|
|
19
|
-
px: 1,
|
|
20
|
-
my: elementSize == "small" ? 1 : 2,
|
|
21
|
-
display: "flex",
|
|
22
|
-
alignItems: "center"
|
|
23
|
-
}}
|
|
24
20
|
>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
21
|
+
<Accordion>
|
|
22
|
+
<AccordionSummary
|
|
23
|
+
sx={{
|
|
24
|
+
minHeight: 40,
|
|
25
|
+
'& .MuiAccordionSummary-content': {
|
|
26
|
+
my: 1
|
|
27
|
+
}
|
|
28
|
+
}}
|
|
29
|
+
expandIcon={<ExpandMoreIcon />}
|
|
30
|
+
aria-controls="panel1a-content"
|
|
31
|
+
id="panel1a-header"
|
|
32
|
+
>
|
|
33
|
+
<Typography variant="h6">Tìm kiếm</Typography>
|
|
34
|
+
</AccordionSummary>
|
|
35
|
+
<AccordionDetails>
|
|
36
|
+
<Grid container spacing={1}>
|
|
37
|
+
{filters.map(({ field, size, ...rest }) => {
|
|
38
|
+
if (rest.type === "date-range") {
|
|
39
|
+
return (
|
|
40
|
+
<Grid key={field.toString()} md={size?.md} xs={size?.xs} sm={size?.sm}>
|
|
41
|
+
<DateRangePicker
|
|
42
|
+
onChange={(value) => {
|
|
43
|
+
setDataSearch(({ previousState }) => ({
|
|
44
|
+
...previousState,
|
|
45
|
+
[field[0]]: value[0],
|
|
46
|
+
[field[1]]: value[1]
|
|
47
|
+
}));
|
|
48
|
+
}}
|
|
49
|
+
size={elementSize}
|
|
50
|
+
value={[dataSearch?.[field[0]], dataSearch?.[field[1]]]}
|
|
51
|
+
/>
|
|
52
|
+
</Grid>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
88
|
-
})}
|
|
89
|
-
</Grid>
|
|
90
|
-
</Toolbar>
|
|
56
|
+
if (rest.type === "slider-range") {
|
|
57
|
+
return (
|
|
58
|
+
<Grid
|
|
59
|
+
key={field.toString()}
|
|
60
|
+
md={size?.md} xs={size?.xs} sm={size?.sm}
|
|
61
|
+
>
|
|
62
|
+
<Slider
|
|
63
|
+
onChange={(e, value) => {
|
|
64
|
+
setDataSearch({
|
|
65
|
+
...dataSearch,
|
|
66
|
+
[field[0]]: value[0],
|
|
67
|
+
[field[1]]: value[1]
|
|
68
|
+
});
|
|
69
|
+
}}
|
|
70
|
+
size={elementSize}
|
|
71
|
+
marks={rest.marks}
|
|
72
|
+
defaultValue={rest.defaultValue}
|
|
73
|
+
valueLabelDisplay="auto"
|
|
74
|
+
max={rest.marks[rest.marks.length - 1]?.value}
|
|
75
|
+
step={null}
|
|
76
|
+
/>
|
|
77
|
+
</Grid>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return (
|
|
81
|
+
<Grid key={field} md={size?.md} xs={size?.xs} sm={size?.sm} >
|
|
82
|
+
<FilterElement name={field} {...rest} size={elementSize} />
|
|
83
|
+
</Grid>
|
|
84
|
+
);
|
|
85
|
+
})}
|
|
86
|
+
</Grid>
|
|
87
|
+
</AccordionDetails>
|
|
88
|
+
</Accordion>
|
|
89
|
+
</Box>
|
|
91
90
|
);
|
|
92
91
|
};
|
|
@@ -14,6 +14,8 @@ export function usePermission() {
|
|
|
14
14
|
const canCreate = !Permission || Permission.Create;
|
|
15
15
|
const canAction = !Permission || Permission.Action;
|
|
16
16
|
const canView = !Permission || Permission.View;
|
|
17
|
+
console.table(Permission);
|
|
18
|
+
console.table({canEdit, canDelete, canDeleteMulti, canSave, canCreate, canAction, canView});
|
|
17
19
|
return { canEdit, canDelete, canDeleteMulti, canSave, canCreate, canAction, canView };
|
|
18
20
|
}, [Permission]);
|
|
19
21
|
|