rez-table-listing-mui 1.0.31 → 1.0.33
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +7 -7
- package/src/components/filter/components/forms/components/Date.tsx +91 -16
- package/src/components/filter/components/forms/components/Filter-criteria.tsx +46 -33
- package/src/components/filter/components/forms/index.tsx +19 -2
- package/src/libs/hooks/useCraftTable.tsx +1 -1
- package/src/libs/utils/common.ts +1 -1
- package/src/types/filter.ts +1 -0
package/src/App.tsx
CHANGED
|
@@ -24,7 +24,7 @@ function App() {
|
|
|
24
24
|
const [columns, setColumns] = useState<any[]>([]);
|
|
25
25
|
const [searchTerm, setSearchTerm] = useState("");
|
|
26
26
|
// const [data, setData] = useState<Person[]>(() => makeData(50, 3, 2));
|
|
27
|
-
// const [entity_type] = useState(ENTITY_TYPE); //OR
|
|
27
|
+
// const [entity_type] = useState(ENTITY_TYPE); //OR AYR BRD
|
|
28
28
|
|
|
29
29
|
const [selectedTab, setSelectedTab] = useState("ALL");
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ function App() {
|
|
|
33
33
|
|
|
34
34
|
const { defaultColumns } = useDefaultColumns();
|
|
35
35
|
|
|
36
|
-
const { metaQuery } = useFetchData("
|
|
36
|
+
const { metaQuery } = useFetchData("AYR");
|
|
37
37
|
const { detailsQuery } = useDetailsQueryAPI(
|
|
38
38
|
filterMaster?.saved_filters?.selectedId
|
|
39
39
|
? filterMaster?.saved_filters?.selectedId
|
|
@@ -58,7 +58,7 @@ function App() {
|
|
|
58
58
|
|
|
59
59
|
const fetchMeta = async () => {
|
|
60
60
|
try {
|
|
61
|
-
const { res } = await entityTableMetaMaster("
|
|
61
|
+
const { res } = await entityTableMetaMaster("AYR");
|
|
62
62
|
setColumns(res);
|
|
63
63
|
} catch (error) {
|
|
64
64
|
console.error("Failed to fetch metadata:", error);
|
|
@@ -77,7 +77,7 @@ function App() {
|
|
|
77
77
|
const { tableData, isTableDataPending } = useEntityTableAPI({
|
|
78
78
|
page: 0,
|
|
79
79
|
size: 50,
|
|
80
|
-
entity_type: "
|
|
80
|
+
entity_type: "AYR",
|
|
81
81
|
tabs: {
|
|
82
82
|
columnName: "status",
|
|
83
83
|
sortBy: "ASC",
|
|
@@ -156,7 +156,7 @@ function App() {
|
|
|
156
156
|
const payload = {
|
|
157
157
|
name,
|
|
158
158
|
is_default: false,
|
|
159
|
-
mapped_entity_type: "
|
|
159
|
+
mapped_entity_type: "AYR", // For that entity type
|
|
160
160
|
status: "ACTIVE",
|
|
161
161
|
entity_type: "SFM", // FIXED entity type
|
|
162
162
|
filterDetails: quickFilter,
|
|
@@ -171,7 +171,7 @@ function App() {
|
|
|
171
171
|
name: filterToDelete?.label,
|
|
172
172
|
id: filterToDelete?.value,
|
|
173
173
|
is_default: false,
|
|
174
|
-
mapped_entity_type: "
|
|
174
|
+
mapped_entity_type: "AYR",
|
|
175
175
|
status: "INACTIVE",
|
|
176
176
|
entity_type: "SFM",
|
|
177
177
|
};
|
|
@@ -192,7 +192,7 @@ function App() {
|
|
|
192
192
|
name: filterMaster?.saved_filters?.selectedName, // Name of the filter
|
|
193
193
|
is_default: false,
|
|
194
194
|
id: filterMaster?.saved_filters?.selectedId,
|
|
195
|
-
mapped_entity_type: "
|
|
195
|
+
mapped_entity_type: "AYR",
|
|
196
196
|
status: "ACTIVE",
|
|
197
197
|
entity_type: "SFM",
|
|
198
198
|
filterDetails: quickFilter,
|
|
@@ -6,20 +6,22 @@ import moment from "moment";
|
|
|
6
6
|
import { UpdatedFilterStateProps } from "../../../../../types/filter";
|
|
7
7
|
import { SxProps, Theme } from "@mui/material";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
filter,
|
|
11
|
-
control,
|
|
12
|
-
}: {
|
|
9
|
+
type FormDatePickerProps = {
|
|
13
10
|
filter: UpdatedFilterStateProps;
|
|
14
11
|
control: any;
|
|
15
12
|
sx?: SxProps<Theme>;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
console.log("range+++", range);
|
|
13
|
+
views?: Array<"year" | "month" | "day">;
|
|
14
|
+
};
|
|
19
15
|
|
|
16
|
+
const FormDatePicker = ({
|
|
17
|
+
filter,
|
|
18
|
+
control,
|
|
19
|
+
sx,
|
|
20
|
+
views = ["day", "month", "year"], // default to full date picker
|
|
21
|
+
}: FormDatePickerProps) => {
|
|
20
22
|
return (
|
|
21
23
|
<Controller
|
|
22
|
-
name={`${filter?.name}.value`} //
|
|
24
|
+
name={`${filter?.name}.value`} // Use consistent field structure
|
|
23
25
|
control={control}
|
|
24
26
|
defaultValue={
|
|
25
27
|
filter.filter_value
|
|
@@ -29,25 +31,39 @@ const FormDatePicker = ({
|
|
|
29
31
|
render={({ field }) => (
|
|
30
32
|
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
31
33
|
<DatePicker
|
|
32
|
-
sx={{
|
|
33
|
-
"& .MuiOutlinedInput-input": {
|
|
34
|
-
padding: "12px 20px",
|
|
35
|
-
},
|
|
36
|
-
}}
|
|
37
34
|
{...field}
|
|
35
|
+
views={views}
|
|
38
36
|
value={
|
|
39
37
|
field.value ? moment(field.value, "DD-MM-YYYY").toDate() : null
|
|
40
38
|
}
|
|
41
39
|
onChange={(date) => {
|
|
42
|
-
|
|
40
|
+
let formatted = "";
|
|
41
|
+
if (date) {
|
|
42
|
+
if (views?.length === 1 && views[0] === "year") {
|
|
43
|
+
formatted = moment(date).format("YYYY");
|
|
44
|
+
} else {
|
|
45
|
+
formatted = moment(date).format("DD-MM-YYYY");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
43
48
|
field.onChange(formatted);
|
|
44
49
|
}}
|
|
45
|
-
format=
|
|
50
|
+
format={
|
|
51
|
+
views?.length === 1 && views[0] === "year" ? "yyyy" : "dd-MM-yyyy"
|
|
52
|
+
}
|
|
53
|
+
sx={{
|
|
54
|
+
"& .MuiOutlinedInput-input": {
|
|
55
|
+
padding: "12px 20px",
|
|
56
|
+
},
|
|
57
|
+
...sx,
|
|
58
|
+
}}
|
|
46
59
|
slotProps={{
|
|
47
60
|
textField: {
|
|
48
61
|
size: "small",
|
|
49
62
|
fullWidth: true,
|
|
50
|
-
placeholder:
|
|
63
|
+
placeholder:
|
|
64
|
+
views?.length === 1 && views[0] === "year"
|
|
65
|
+
? "YYYY"
|
|
66
|
+
: "DD-MM-YYYY",
|
|
51
67
|
},
|
|
52
68
|
}}
|
|
53
69
|
/>
|
|
@@ -58,3 +74,62 @@ const FormDatePicker = ({
|
|
|
58
74
|
};
|
|
59
75
|
|
|
60
76
|
export default FormDatePicker;
|
|
77
|
+
|
|
78
|
+
// import { Controller } from "react-hook-form";
|
|
79
|
+
// import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
|
80
|
+
// import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
81
|
+
// import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
|
|
82
|
+
// import moment from "moment";
|
|
83
|
+
// import { UpdatedFilterStateProps } from "../../../../../types/filter";
|
|
84
|
+
// import { SxProps, Theme } from "@mui/material";
|
|
85
|
+
|
|
86
|
+
// const FormDatePicker = ({
|
|
87
|
+
// filter,
|
|
88
|
+
// control,
|
|
89
|
+
// sx,
|
|
90
|
+
// }: {
|
|
91
|
+
// filter: UpdatedFilterStateProps;
|
|
92
|
+
// control: any;
|
|
93
|
+
// sx?: SxProps<Theme>;
|
|
94
|
+
// }) => {
|
|
95
|
+
// return (
|
|
96
|
+
// <Controller
|
|
97
|
+
// name={`${filter?.name}.value`} // or use a consistent structure like `filters.${index}.filter_value`
|
|
98
|
+
// control={control}
|
|
99
|
+
// defaultValue={
|
|
100
|
+
// filter.filter_value
|
|
101
|
+
// ? moment(filter.filter_value, "DD-MM-YYYY").toDate()
|
|
102
|
+
// : null
|
|
103
|
+
// }
|
|
104
|
+
// render={({ field }) => (
|
|
105
|
+
// <LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
106
|
+
// <DatePicker
|
|
107
|
+
// sx={{
|
|
108
|
+
// "& .MuiOutlinedInput-input": {
|
|
109
|
+
// padding: "12px 20px",
|
|
110
|
+
// },
|
|
111
|
+
// }}
|
|
112
|
+
// {...field}
|
|
113
|
+
// value={
|
|
114
|
+
// field.value ? moment(field.value, "DD-MM-YYYY").toDate() : null
|
|
115
|
+
// }
|
|
116
|
+
// onChange={(date) => {
|
|
117
|
+
// const formatted = date ? moment(date).format("DD-MM-YYYY") : "";
|
|
118
|
+
// field.onChange(formatted);
|
|
119
|
+
// }}
|
|
120
|
+
// format="dd-MM-yyyy"
|
|
121
|
+
// slotProps={{
|
|
122
|
+
// textField: {
|
|
123
|
+
// size: "small",
|
|
124
|
+
// fullWidth: true,
|
|
125
|
+
// placeholder: "DD-MM-YYYY",
|
|
126
|
+
// },
|
|
127
|
+
// }}
|
|
128
|
+
// />
|
|
129
|
+
// </LocalizationProvider>
|
|
130
|
+
// )}
|
|
131
|
+
// />
|
|
132
|
+
// );
|
|
133
|
+
// };
|
|
134
|
+
|
|
135
|
+
// export default FormDatePicker;
|
|
@@ -22,12 +22,16 @@ const FilterCriteria = ({
|
|
|
22
22
|
columnsData,
|
|
23
23
|
tableStates,
|
|
24
24
|
setSelectedFilters,
|
|
25
|
+
searchTerm,
|
|
26
|
+
setSearchTerm,
|
|
25
27
|
}: {
|
|
26
28
|
columnsData: FilterColumnsDataProps;
|
|
27
29
|
tableStates: CraftTableOptionsProps;
|
|
28
30
|
setSelectedFilters: React.Dispatch<
|
|
29
31
|
React.SetStateAction<UpdatedFilterStateProps[]>
|
|
30
32
|
>;
|
|
33
|
+
searchTerm: string;
|
|
34
|
+
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
31
35
|
}) => {
|
|
32
36
|
const FilterButton = styled(Button)(({ theme }) => ({
|
|
33
37
|
borderRadius: 20,
|
|
@@ -130,40 +134,49 @@ const FilterCriteria = ({
|
|
|
130
134
|
}}
|
|
131
135
|
>
|
|
132
136
|
<List
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
// subheader={
|
|
138
|
+
// <ListSubheader
|
|
139
|
+
// component="div"
|
|
140
|
+
// sx={{
|
|
141
|
+
// fontWeight: "bold",
|
|
142
|
+
// bgcolor: "#f5f5f9",
|
|
143
|
+
// borderRadius: "6px",
|
|
144
|
+
// }}
|
|
145
|
+
// >
|
|
146
|
+
// {/* Filter by... */}
|
|
147
|
+
// {/* <CustomSearch placeholder="Filter by..." /> */}
|
|
148
|
+
// </ListSubheader>
|
|
149
|
+
// }
|
|
146
150
|
>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
151
|
+
<CustomSearch
|
|
152
|
+
placeholder="Filter by..."
|
|
153
|
+
value={searchTerm}
|
|
154
|
+
onChange={setSearchTerm}
|
|
155
|
+
/>
|
|
156
|
+
{columnsData?.column_list
|
|
157
|
+
?.filter((column) =>
|
|
158
|
+
column.name.toLowerCase().includes(searchTerm.toLowerCase())
|
|
159
|
+
)
|
|
160
|
+
.map((column, index) => {
|
|
161
|
+
const isAlreadySelected = filters?.some(
|
|
162
|
+
(filter) => filter.filter_attribute === column.attribute_key
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<ListItem
|
|
167
|
+
key={index}
|
|
168
|
+
onClick={() =>
|
|
169
|
+
!isAlreadySelected && handleAddFilter(column)
|
|
170
|
+
} // Prevent click if already selected
|
|
171
|
+
sx={{
|
|
172
|
+
opacity: isAlreadySelected ? 0.5 : 1,
|
|
173
|
+
cursor: isAlreadySelected ? "not-allowed" : "pointer",
|
|
174
|
+
}}
|
|
175
|
+
>
|
|
176
|
+
<ListItemText primary={column.name} />
|
|
177
|
+
</ListItem>
|
|
178
|
+
);
|
|
179
|
+
})}
|
|
167
180
|
</List>
|
|
168
181
|
</Box>
|
|
169
182
|
</Paper>
|
|
@@ -241,8 +241,8 @@ const FilterForm = ({
|
|
|
241
241
|
columnsData={columnsData}
|
|
242
242
|
tableStates={tableStates}
|
|
243
243
|
setSelectedFilters={setSelectedFilters}
|
|
244
|
-
|
|
245
|
-
|
|
244
|
+
searchTerm={searchTerm}
|
|
245
|
+
setSearchTerm={setSearchTerm}
|
|
246
246
|
/>
|
|
247
247
|
|
|
248
248
|
{/* Render search input */}
|
|
@@ -325,6 +325,23 @@ const FilterForm = ({
|
|
|
325
325
|
<Box>
|
|
326
326
|
{filter.data_type === "text" ? (
|
|
327
327
|
<FormTextfield filter={filter} control={control} />
|
|
328
|
+
) : filter.data_type === "year" ? (
|
|
329
|
+
<FormDatePicker
|
|
330
|
+
filter={filter}
|
|
331
|
+
control={control}
|
|
332
|
+
views={["year"]}
|
|
333
|
+
sx={{
|
|
334
|
+
"& .MuiOutlinedInput-root": {
|
|
335
|
+
borderRadius: "6px",
|
|
336
|
+
fontSize: "14px",
|
|
337
|
+
bgcolor: "#ffffff",
|
|
338
|
+
"& fieldset": { borderColor: "#c1c1c1" },
|
|
339
|
+
"&.Mui-focused fieldset": {
|
|
340
|
+
borderColor: "#7A5AF8",
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
}}
|
|
344
|
+
/>
|
|
328
345
|
) : filter.data_type === "number" ? (
|
|
329
346
|
<FormTextfield filter={filter} control={control} />
|
|
330
347
|
) : filter.data_type === "date" ? (
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
export function useCraftTable(paginationPageSize: number = 25) {
|
|
16
16
|
const [pagination, setPagination] = useState<PaginationState>({
|
|
17
|
-
pageIndex:
|
|
17
|
+
pageIndex: 0,
|
|
18
18
|
pageSize: paginationPageSize,
|
|
19
19
|
});
|
|
20
20
|
const [sorting, setSorting] = useState<SortingState>([]);
|
package/src/libs/utils/common.ts
CHANGED