rez-table-listing-mui 1.0.37 → 1.0.39
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 +100 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +82 -27
- package/src/components/common/confirm-modal/index.tsx +8 -3
- package/src/components/filter/components/forms/components/Date.tsx +109 -161
- package/src/components/filter/components/forms/components/Filter-criteria.tsx +12 -55
- package/src/components/filter/components/forms/index.tsx +1 -1
- package/src/components/filter/components/saved-filter.tsx +6 -3
- package/src/components/filter/index.tsx +1 -1
- package/src/components/filter/style.ts +0 -1
- package/src/components/index-table.tsx +5 -2
- package/src/components/index.scss +2 -0
- package/src/components/login/index.tsx +1 -1
- package/src/components/search/index.tsx +31 -6
- package/src/components/table-head-popover.tsx +1 -1
- package/src/components/table-settings/common/draggable-listitem.tsx +66 -0
- package/src/components/table-settings/common/listing-values.tsx +117 -0
- package/src/components/table-settings/components/column.tsx +332 -0
- package/src/components/table-settings/components/custom-button.tsx +15 -0
- package/src/components/table-settings/components/custom-dialog.tsx +27 -0
- package/src/components/table-settings/components/quick-tab.tsx +335 -0
- package/src/components/table-settings/components/sorting.tsx +619 -0
- package/src/components/table-settings/components/toggle-button-switch.tsx +45 -0
- package/src/components/table-settings/constants.ts +12 -0
- package/src/components/table-settings/index.tsx +133 -0
- package/src/components/table-settings/style.ts +115 -0
- package/src/components/table-settings/tabs/horizontal/index.tsx +21 -0
- package/src/components/table-settings/tabs/styles.ts +67 -0
- package/src/components/table-settings/tabs/vertical/custom-tab-panel.tsx +29 -0
- package/src/components/table-settings/tabs/vertical/index.tsx +38 -0
- package/src/components/tabs/index.tsx +30 -36
- package/src/index.ts +1 -0
- package/src/libs/hooks/useCraftTableFilterSettings.tsx +176 -0
- package/src/libs/hooks/useEntityTableAPI.tsx +82 -1
- package/src/libs/utils/apiColumn.ts +25 -0
- package/src/libs/utils/common.ts +2 -2
- package/src/types/common.ts +6 -0
- package/src/types/filter-settings.ts +97 -0
- package/src/types/filter.ts +6 -0
- package/src/types/table-options.ts +19 -0
- package/src/types/table.ts +10 -1
- package/.env.uat +0 -1
package/src/App.tsx
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
useDeleteFilterAPI,
|
|
10
10
|
useEntityTableAPI,
|
|
11
11
|
useSavedFilterAPI,
|
|
12
|
+
useSaveSettingsDataAPI,
|
|
13
|
+
useSettingsDropDownAPI,
|
|
12
14
|
useUpdateFilterAPI,
|
|
13
15
|
} from "./libs/hooks/useEntityTableAPI";
|
|
14
16
|
import {
|
|
@@ -17,6 +19,8 @@ import {
|
|
|
17
19
|
} from "./libs/hooks/useEntityTableHooks";
|
|
18
20
|
import LoginButton from "./components/login";
|
|
19
21
|
import { CraftTableFilter } from ".";
|
|
22
|
+
import { useCraftTableFilterSettings } from "./libs/hooks/useCraftTableFilterSettings";
|
|
23
|
+
import QuickFilterSettings from "./components/table-settings";
|
|
20
24
|
// import { ENTITY_TYPE } from "./libs/utils/common";
|
|
21
25
|
|
|
22
26
|
function App() {
|
|
@@ -25,13 +29,22 @@ function App() {
|
|
|
25
29
|
const [columns, setColumns] = useState<any[]>([]);
|
|
26
30
|
const [searchTerm, setSearchTerm] = useState("");
|
|
27
31
|
// const [data, setData] = useState<Person[]>(() => makeData(50, 3, 2));
|
|
28
|
-
// const [entity_type] = useState(ENTITY_TYPE); //OR
|
|
32
|
+
// const [entity_type] = useState(ENTITY_TYPE); //OR UPR BRD
|
|
29
33
|
|
|
30
34
|
const [selectedTab, setSelectedTab] = useState("ALL");
|
|
31
35
|
|
|
32
36
|
const tableStates = useCraftTable();
|
|
37
|
+
const filterSettingStates = useCraftTableFilterSettings();
|
|
38
|
+
|
|
33
39
|
const { filters, setFilters, filterMaster, filterToDelete } = tableStates;
|
|
34
40
|
|
|
41
|
+
const {
|
|
42
|
+
showListViewSettings,
|
|
43
|
+
setShowListViewSettings,
|
|
44
|
+
settingsData,
|
|
45
|
+
setSettingsData,
|
|
46
|
+
} = filterSettingStates;
|
|
47
|
+
|
|
35
48
|
const { defaultColumns } = useDefaultColumns();
|
|
36
49
|
|
|
37
50
|
const { metaQuery } = useFetchData("AYR");
|
|
@@ -46,6 +59,16 @@ function App() {
|
|
|
46
59
|
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
47
60
|
|
|
48
61
|
const { dropdownData } = useCommonDropdownAPI(metaQuery.data);
|
|
62
|
+
const { settingsTabDropdownData, settingsTabDropdownPending } =
|
|
63
|
+
useSettingsDropDownAPI({
|
|
64
|
+
entity_type: "AYR",
|
|
65
|
+
column: filterSettingStates?.quickTabStates?.attribute,
|
|
66
|
+
sort_by: filterSettingStates?.quickTabStates?.sorting,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const { saveSettingsAPIData } = useSaveSettingsDataAPI({
|
|
70
|
+
payload: filterSettingStates?.settingsData,
|
|
71
|
+
});
|
|
49
72
|
|
|
50
73
|
useEffect(() => {
|
|
51
74
|
// setTimeout(() => {
|
|
@@ -68,16 +91,23 @@ function App() {
|
|
|
68
91
|
setFilters(detailsQuery.data ?? []);
|
|
69
92
|
}, [detailsQuery.data]);
|
|
70
93
|
|
|
71
|
-
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
setSettingsData(saveSettingsAPIData?.layout_json);
|
|
96
|
+
console.log("settingsData", settingsData);
|
|
97
|
+
}, [saveSettingsAPIData]);
|
|
72
98
|
|
|
73
|
-
|
|
99
|
+
//For server side sorting
|
|
100
|
+
const enableServerSideSorting = true;
|
|
101
|
+
|
|
102
|
+
const { tableData } = useEntityTableAPI({
|
|
74
103
|
page: 0,
|
|
75
104
|
size: 50,
|
|
76
105
|
entity_type: "AYR",
|
|
77
106
|
tabs: {
|
|
78
107
|
columnName: "status",
|
|
79
108
|
sortBy: "ASC",
|
|
80
|
-
value:
|
|
109
|
+
value:
|
|
110
|
+
selectedTab.toLowerCase() === "all" ? "" : selectedTab.toLowerCase(),
|
|
81
111
|
},
|
|
82
112
|
quickFilter: tableStates.filters,
|
|
83
113
|
sortby: [
|
|
@@ -157,7 +187,16 @@ function App() {
|
|
|
157
187
|
filterDetails: quickFilter,
|
|
158
188
|
};
|
|
159
189
|
const entity_type = "SFM";
|
|
160
|
-
savedMutation.mutate(
|
|
190
|
+
savedMutation.mutate(
|
|
191
|
+
{ entity_type, payload },
|
|
192
|
+
{
|
|
193
|
+
onSuccess: () => {},
|
|
194
|
+
onError: (error: any) => {
|
|
195
|
+
const msg = error?.response?.data?.message;
|
|
196
|
+
console.log("Error in saving filter", msg, error);
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
);
|
|
161
200
|
};
|
|
162
201
|
|
|
163
202
|
// API to handle removing or deleting a filter
|
|
@@ -216,24 +255,6 @@ function App() {
|
|
|
216
255
|
// isLoading: isTableDataPending || detailsQuery.isPending,
|
|
217
256
|
// // loaderText: "Loading, Please wait...",
|
|
218
257
|
// }}
|
|
219
|
-
topbarOptions={{
|
|
220
|
-
tableStates,
|
|
221
|
-
leftSideComponent: (
|
|
222
|
-
<TableTabs
|
|
223
|
-
activeTab={selectedTab}
|
|
224
|
-
tableStates={tableStates}
|
|
225
|
-
tabsData={tabsData}
|
|
226
|
-
onClick={(state) => {
|
|
227
|
-
setSelectedTab(state);
|
|
228
|
-
}}
|
|
229
|
-
/>
|
|
230
|
-
),
|
|
231
|
-
searchValue: searchTerm,
|
|
232
|
-
onSearchChange: (val) => setSearchTerm(val),
|
|
233
|
-
showFilterToggle: true,
|
|
234
|
-
onFilterButtonClick: () =>
|
|
235
|
-
tableStates.setShowTableFilter(!tableStates.showTableFilter),
|
|
236
|
-
}}
|
|
237
258
|
paginationOptions={{
|
|
238
259
|
showPagination: true,
|
|
239
260
|
paginationPosition: "top",
|
|
@@ -244,20 +265,54 @@ function App() {
|
|
|
244
265
|
renderStatus: handleRenderStatus,
|
|
245
266
|
renderAction: handleRenderAction,
|
|
246
267
|
}}
|
|
268
|
+
// emptyListComponent={<div>No data found</div>}
|
|
247
269
|
filterOptions={{
|
|
248
|
-
show: tableStates
|
|
270
|
+
show: tableStates?.showTableFilter,
|
|
249
271
|
component: (
|
|
250
272
|
<CraftTableFilter
|
|
251
273
|
tableStates={tableStates}
|
|
252
|
-
|
|
274
|
+
onClose={() => tableStates.setShowTableFilter(false)}
|
|
275
|
+
onUpdateFilter={handleUpdateFilter}
|
|
276
|
+
columnsData={metaQuery.data || {}}
|
|
253
277
|
dropdownData={dropdownData || []}
|
|
254
278
|
onDeleteFilter={handleRemoveFilter}
|
|
255
279
|
onSaveFilter={handleSaveFilter}
|
|
256
|
-
onUpdateFilter={handleUpdateFilter}
|
|
257
|
-
onClose={() => tableStates.setShowTableFilter(false)}
|
|
258
280
|
/>
|
|
259
281
|
),
|
|
260
282
|
}}
|
|
283
|
+
topbarOptions={{
|
|
284
|
+
tableStates,
|
|
285
|
+
leftSideComponent: (
|
|
286
|
+
<>
|
|
287
|
+
<TableTabs
|
|
288
|
+
columns={columns}
|
|
289
|
+
settingsOptions={{
|
|
290
|
+
showIcon: true,
|
|
291
|
+
onClick: () => setShowListViewSettings(!showListViewSettings),
|
|
292
|
+
}}
|
|
293
|
+
activeTab={selectedTab}
|
|
294
|
+
tableStates={tableStates}
|
|
295
|
+
tabsData={tabsData}
|
|
296
|
+
onClick={(state) => {
|
|
297
|
+
setSelectedTab(state);
|
|
298
|
+
}}
|
|
299
|
+
/>
|
|
300
|
+
|
|
301
|
+
<QuickFilterSettings
|
|
302
|
+
filterSettingStates={filterSettingStates}
|
|
303
|
+
onClose={() => setShowListViewSettings(false)}
|
|
304
|
+
columnsData={metaQuery.data || {}}
|
|
305
|
+
tabsApiData={settingsTabDropdownData || []}
|
|
306
|
+
tabsApiDataLoading={settingsTabDropdownPending}
|
|
307
|
+
/>
|
|
308
|
+
</>
|
|
309
|
+
),
|
|
310
|
+
searchValue: searchTerm,
|
|
311
|
+
onSearchChange: (val) => setSearchTerm(val),
|
|
312
|
+
showFilterToggle: true,
|
|
313
|
+
onFilterButtonClick: () =>
|
|
314
|
+
tableStates.setShowTableFilter(!tableStates.showTableFilter),
|
|
315
|
+
}}
|
|
261
316
|
/>
|
|
262
317
|
</div>
|
|
263
318
|
);
|
|
@@ -17,7 +17,7 @@ import { Theme } from "@emotion/react";
|
|
|
17
17
|
// Types for the component props
|
|
18
18
|
export interface ModalButton {
|
|
19
19
|
label: string;
|
|
20
|
-
onClick: (inputValue?: string) => void;
|
|
20
|
+
onClick: (inputValue?: string, error?: string, setError?: any) => void;
|
|
21
21
|
variant?: "text" | "outlined" | "contained";
|
|
22
22
|
color?: "primary" | "secondary" | "error" | "info" | "success" | "warning";
|
|
23
23
|
disabled?: boolean;
|
|
@@ -58,14 +58,14 @@ const ConfirmModal: React.FC<ConfirmModalProps> = ({
|
|
|
58
58
|
fullWidth = true,
|
|
59
59
|
}) => {
|
|
60
60
|
const [inputValue, setInputValue] = useState(input?.defaultValue || "");
|
|
61
|
-
|
|
61
|
+
const [error, setError] = useState("");
|
|
62
62
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
63
63
|
setInputValue(event.target.value);
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
const handleButtonClick = (button: ModalButton) => {
|
|
67
67
|
if (input) {
|
|
68
|
-
button.onClick(inputValue);
|
|
68
|
+
button.onClick(inputValue, error, setError);
|
|
69
69
|
} else {
|
|
70
70
|
button.onClick();
|
|
71
71
|
}
|
|
@@ -168,6 +168,11 @@ const ConfirmModal: React.FC<ConfirmModalProps> = ({
|
|
|
168
168
|
},
|
|
169
169
|
}}
|
|
170
170
|
/>
|
|
171
|
+
{error && (
|
|
172
|
+
<Typography variant="body2" color="error.main">
|
|
173
|
+
{error}
|
|
174
|
+
</Typography>
|
|
175
|
+
)}
|
|
171
176
|
</Box>
|
|
172
177
|
)}
|
|
173
178
|
</DialogContent>
|
|
@@ -4,7 +4,7 @@ import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
|
4
4
|
import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
|
|
5
5
|
import moment from "moment";
|
|
6
6
|
import { UpdatedFilterStateProps } from "../../../../../types/filter";
|
|
7
|
-
import { SxProps, Theme
|
|
7
|
+
import { SxProps, Theme } from "@mui/material";
|
|
8
8
|
|
|
9
9
|
type FormDatePickerProps = {
|
|
10
10
|
filter: UpdatedFilterStateProps;
|
|
@@ -18,173 +18,121 @@ const FormDatePicker = ({
|
|
|
18
18
|
filter,
|
|
19
19
|
control,
|
|
20
20
|
sx,
|
|
21
|
-
views = ["day", "month", "year"],
|
|
21
|
+
views = ["day", "month", "year"], // default to full date picker
|
|
22
22
|
onValueChange,
|
|
23
23
|
}: FormDatePickerProps) => {
|
|
24
|
-
const isRange = filter.filter_operator === "between";
|
|
25
|
-
|
|
26
|
-
console.log("filter", filter.filter_operator);
|
|
27
|
-
|
|
28
24
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (isRange) {
|
|
45
|
-
const fromDate = Array.isArray(value) ? value[0] : "";
|
|
46
|
-
const toDate = Array.isArray(value) ? value[1] : "";
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<>
|
|
50
|
-
<DatePicker
|
|
51
|
-
views={views}
|
|
52
|
-
value={
|
|
53
|
-
fromDate ? moment(fromDate, "YYYY-MM-DD").toDate() : null //
|
|
54
|
-
}
|
|
55
|
-
onChange={(date) => {
|
|
56
|
-
let formatted = "";
|
|
57
|
-
if (date) {
|
|
58
|
-
formatted =
|
|
59
|
-
views?.length === 1 && views[0] === "year"
|
|
60
|
-
? moment(date).format("YYYY")
|
|
61
|
-
: moment(date).format("YYYY-MM-DD"); //
|
|
62
|
-
}
|
|
63
|
-
const updated: [string, string] = [
|
|
64
|
-
formatted,
|
|
65
|
-
toDate || "",
|
|
66
|
-
];
|
|
67
|
-
field.onChange(updated);
|
|
68
|
-
onValueChange?.();
|
|
69
|
-
}}
|
|
70
|
-
format={
|
|
71
|
-
views?.length === 1 && views[0] === "year"
|
|
72
|
-
? "yyyy"
|
|
73
|
-
: "dd-MM-yyyy"
|
|
74
|
-
}
|
|
75
|
-
sx={{
|
|
76
|
-
"& .MuiOutlinedInput-input": {
|
|
77
|
-
padding: "12px 20px",
|
|
78
|
-
},
|
|
79
|
-
...sx,
|
|
80
|
-
}}
|
|
81
|
-
slotProps={{
|
|
82
|
-
textField: {
|
|
83
|
-
size: "small",
|
|
84
|
-
fullWidth: true,
|
|
85
|
-
placeholder:
|
|
86
|
-
views?.length === 1 && views[0] === "year"
|
|
87
|
-
? "YYYY"
|
|
88
|
-
: "From Date",
|
|
89
|
-
},
|
|
90
|
-
}}
|
|
91
|
-
/>
|
|
92
|
-
|
|
93
|
-
<DatePicker
|
|
94
|
-
views={views}
|
|
95
|
-
value={
|
|
96
|
-
toDate ? moment(toDate, "YYYY-MM-DD").toDate() : null //
|
|
97
|
-
}
|
|
98
|
-
onChange={(date) => {
|
|
99
|
-
let formatted = "";
|
|
100
|
-
if (date) {
|
|
101
|
-
formatted =
|
|
102
|
-
views?.length === 1 && views[0] === "year"
|
|
103
|
-
? moment(date).format("YYYY")
|
|
104
|
-
: moment(date).format("YYYY-MM-DD"); //
|
|
105
|
-
}
|
|
106
|
-
const updated: [string, string] = [
|
|
107
|
-
fromDate || "",
|
|
108
|
-
formatted,
|
|
109
|
-
];
|
|
110
|
-
field.onChange(updated);
|
|
111
|
-
onValueChange?.();
|
|
112
|
-
}}
|
|
113
|
-
format={
|
|
114
|
-
views?.length === 1 && views[0] === "year"
|
|
115
|
-
? "yyyy"
|
|
116
|
-
: "dd-MM-yyyy"
|
|
117
|
-
}
|
|
118
|
-
sx={{
|
|
119
|
-
"& .MuiOutlinedInput-input": {
|
|
120
|
-
padding: "12px 20px",
|
|
121
|
-
},
|
|
122
|
-
...sx,
|
|
123
|
-
}}
|
|
124
|
-
slotProps={{
|
|
125
|
-
textField: {
|
|
126
|
-
size: "small",
|
|
127
|
-
fullWidth: true,
|
|
128
|
-
placeholder:
|
|
129
|
-
views?.length === 1 && views[0] === "year"
|
|
130
|
-
? "YYYY"
|
|
131
|
-
: "To Date",
|
|
132
|
-
},
|
|
133
|
-
}}
|
|
134
|
-
/>
|
|
135
|
-
</>
|
|
136
|
-
);
|
|
25
|
+
<Controller
|
|
26
|
+
name={`${filter?.name}.value`} // Use consistent field structure
|
|
27
|
+
control={control}
|
|
28
|
+
defaultValue={
|
|
29
|
+
filter.filter_value
|
|
30
|
+
? moment(filter.filter_value, "DD-MM-YYYY").toDate()
|
|
31
|
+
: null
|
|
32
|
+
}
|
|
33
|
+
render={({ field }) => (
|
|
34
|
+
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
35
|
+
<DatePicker
|
|
36
|
+
{...field}
|
|
37
|
+
views={views}
|
|
38
|
+
value={
|
|
39
|
+
field.value ? moment(field.value, "DD-MM-YYYY").toDate() : null
|
|
137
40
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
field.value
|
|
146
|
-
? moment(field.value, "YYYY-MM-DD").toDate() //
|
|
147
|
-
: null
|
|
41
|
+
onChange={(date) => {
|
|
42
|
+
let formatted = "";
|
|
43
|
+
if (date) {
|
|
44
|
+
if (views?.length === 1 && views[0] === "year") {
|
|
45
|
+
formatted = moment(date).format("YYYY");
|
|
46
|
+
} else {
|
|
47
|
+
formatted = moment(date).format("DD-MM-YYYY");
|
|
148
48
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
49
|
+
}
|
|
50
|
+
field.onChange(formatted);
|
|
51
|
+
onValueChange?.();
|
|
52
|
+
}}
|
|
53
|
+
format={
|
|
54
|
+
views?.length === 1 && views[0] === "year" ? "yyyy" : "dd-MM-yyyy"
|
|
55
|
+
}
|
|
56
|
+
sx={{
|
|
57
|
+
"& .MuiOutlinedInput-input": {
|
|
58
|
+
padding: "12px 20px",
|
|
59
|
+
},
|
|
60
|
+
...sx,
|
|
61
|
+
}}
|
|
62
|
+
slotProps={{
|
|
63
|
+
textField: {
|
|
64
|
+
size: "small",
|
|
65
|
+
fullWidth: true,
|
|
66
|
+
placeholder:
|
|
161
67
|
views?.length === 1 && views[0] === "year"
|
|
162
|
-
? "
|
|
163
|
-
: "
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}}
|
|
171
|
-
slotProps={{
|
|
172
|
-
textField: {
|
|
173
|
-
size: "small",
|
|
174
|
-
fullWidth: true,
|
|
175
|
-
placeholder:
|
|
176
|
-
views?.length === 1 && views[0] === "year"
|
|
177
|
-
? "YYYY"
|
|
178
|
-
: "DD-MM-YYYY",
|
|
179
|
-
},
|
|
180
|
-
}}
|
|
181
|
-
/>
|
|
182
|
-
);
|
|
183
|
-
}}
|
|
184
|
-
/>
|
|
185
|
-
</Box>
|
|
186
|
-
</LocalizationProvider>
|
|
68
|
+
? "YYYY"
|
|
69
|
+
: "DD-MM-YYYY",
|
|
70
|
+
},
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
</LocalizationProvider>
|
|
74
|
+
)}
|
|
75
|
+
/>
|
|
187
76
|
);
|
|
188
77
|
};
|
|
189
78
|
|
|
190
79
|
export default FormDatePicker;
|
|
80
|
+
|
|
81
|
+
// import { Controller } from "react-hook-form";
|
|
82
|
+
// import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
|
83
|
+
// import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
84
|
+
// import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
|
|
85
|
+
// import moment from "moment";
|
|
86
|
+
// import { UpdatedFilterStateProps } from "../../../../../types/filter";
|
|
87
|
+
// import { SxProps, Theme } from "@mui/material";
|
|
88
|
+
|
|
89
|
+
// const FormDatePicker = ({
|
|
90
|
+
// filter,
|
|
91
|
+
// control,
|
|
92
|
+
// sx,
|
|
93
|
+
// }: {
|
|
94
|
+
// filter: UpdatedFilterStateProps;
|
|
95
|
+
// control: any;
|
|
96
|
+
// sx?: SxProps<Theme>;
|
|
97
|
+
// }) => {
|
|
98
|
+
// return (
|
|
99
|
+
// <Controller
|
|
100
|
+
// name={`${filter?.name}.value`} // or use a consistent structure like `filters.${index}.filter_value`
|
|
101
|
+
// control={control}
|
|
102
|
+
// defaultValue={
|
|
103
|
+
// filter.filter_value
|
|
104
|
+
// ? moment(filter.filter_value, "DD-MM-YYYY").toDate()
|
|
105
|
+
// : null
|
|
106
|
+
// }
|
|
107
|
+
// render={({ field }) => (
|
|
108
|
+
// <LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
109
|
+
// <DatePicker
|
|
110
|
+
// sx={{
|
|
111
|
+
// "& .MuiOutlinedInput-input": {
|
|
112
|
+
// padding: "12px 20px",
|
|
113
|
+
// },
|
|
114
|
+
// }}
|
|
115
|
+
// {...field}
|
|
116
|
+
// value={
|
|
117
|
+
// field.value ? moment(field.value, "DD-MM-YYYY").toDate() : null
|
|
118
|
+
// }
|
|
119
|
+
// onChange={(date) => {
|
|
120
|
+
// const formatted = date ? moment(date).format("DD-MM-YYYY") : "";
|
|
121
|
+
// field.onChange(formatted);
|
|
122
|
+
// }}
|
|
123
|
+
// format="dd-MM-yyyy"
|
|
124
|
+
// slotProps={{
|
|
125
|
+
// textField: {
|
|
126
|
+
// size: "small",
|
|
127
|
+
// fullWidth: true,
|
|
128
|
+
// placeholder: "DD-MM-YYYY",
|
|
129
|
+
// },
|
|
130
|
+
// }}
|
|
131
|
+
// />
|
|
132
|
+
// </LocalizationProvider>
|
|
133
|
+
// )}
|
|
134
|
+
// />
|
|
135
|
+
// );
|
|
136
|
+
// };
|
|
137
|
+
|
|
138
|
+
// export default FormDatePicker;
|
|
@@ -48,65 +48,15 @@ const FilterCriteria = ({
|
|
|
48
48
|
const { filters, setFilters } = tableStates;
|
|
49
49
|
const filterButtonRef = useRef<HTMLButtonElement>(null);
|
|
50
50
|
|
|
51
|
-
//Remove this function once date with range is fixed
|
|
52
|
-
// const handleAddFilter = (column: FilterColumnsListProps) => {
|
|
53
|
-
// const dropdownOptions = columnsData.operation_list[column.data_type];
|
|
54
|
-
|
|
55
|
-
// // console.log("dropdownOptionssssss", dropdownOptions);
|
|
56
|
-
|
|
57
|
-
// const defaultValue = column.data_type === "multiselect" ? [] : "";
|
|
58
|
-
// console.log("defaultValue", defaultValue);
|
|
59
|
-
|
|
60
|
-
// const defaultOperator = dropdownOptions?.[0]?.value || "";
|
|
61
|
-
// // console.log("defaultOperator", defaultOperator);
|
|
62
|
-
|
|
63
|
-
// const matchingDropdownList =
|
|
64
|
-
// columnsData.operation_list[column.data_type] || [];
|
|
65
|
-
|
|
66
|
-
// // console.log("matchingDropdownList", matchingDropdownList);
|
|
67
|
-
|
|
68
|
-
// const newFilter = {
|
|
69
|
-
// filter_attribute: column.attribute_key,
|
|
70
|
-
// filter_operator: defaultOperator,
|
|
71
|
-
// filter_value: defaultValue,
|
|
72
|
-
// };
|
|
73
|
-
|
|
74
|
-
// const newSelectedFilter = {
|
|
75
|
-
// ...newFilter,
|
|
76
|
-
// id: column.id,
|
|
77
|
-
// name: column.name,
|
|
78
|
-
// data_type: column.data_type,
|
|
79
|
-
// dropdown_list: matchingDropdownList,
|
|
80
|
-
// };
|
|
81
|
-
|
|
82
|
-
// setFilters((prev) => [...prev, newFilter]);
|
|
83
|
-
// setSelectedFilters((prev) => [...prev, newSelectedFilter]);
|
|
84
|
-
// // if (editMode) {
|
|
85
|
-
// // setEditFilters((prev) => [...prev, newFilter]);
|
|
86
|
-
// // setSelectedFilters((prev) => [...prev, newSelectedFilter]);
|
|
87
|
-
// // } else {
|
|
88
|
-
// // setFilters((prev) => [...prev, newFilter]);
|
|
89
|
-
// // setSelectedFilters((prev) => [...prev, newSelectedFilter]);
|
|
90
|
-
// // }
|
|
91
|
-
|
|
92
|
-
// setShowFilterOption(false);
|
|
93
|
-
// };
|
|
94
|
-
|
|
95
|
-
// Updated this function to handle the addition of date with
|
|
96
|
-
|
|
97
51
|
const handleAddFilter = (column: FilterColumnsListProps) => {
|
|
98
|
-
const dropdownOptions = columnsData.operation_list[column.data_type]
|
|
52
|
+
const dropdownOptions = columnsData.operation_list[column.data_type];
|
|
99
53
|
|
|
100
|
-
const
|
|
54
|
+
const defaultValue = column.data_type === "multiselect" ? [] : "";
|
|
101
55
|
|
|
102
|
-
const
|
|
103
|
-
column.data_type === "date" && defaultOperator === "between"
|
|
104
|
-
? ["", ""] // range-based value for "between"
|
|
105
|
-
: column.data_type === "multiselect"
|
|
106
|
-
? []
|
|
107
|
-
: "";
|
|
56
|
+
const defaultOperator = dropdownOptions?.[0]?.value || "";
|
|
108
57
|
|
|
109
|
-
const matchingDropdownList =
|
|
58
|
+
const matchingDropdownList =
|
|
59
|
+
columnsData.operation_list[column.data_type] || [];
|
|
110
60
|
|
|
111
61
|
const newFilter = {
|
|
112
62
|
filter_attribute: column.attribute_key,
|
|
@@ -124,6 +74,13 @@ const FilterCriteria = ({
|
|
|
124
74
|
|
|
125
75
|
setFilters((prev) => [...prev, newFilter]);
|
|
126
76
|
setSelectedFilters((prev) => [...prev, newSelectedFilter]);
|
|
77
|
+
// if (editMode) {
|
|
78
|
+
// setEditFilters((prev) => [...prev, newFilter]);
|
|
79
|
+
// setSelectedFilters((prev) => [...prev, newSelectedFilter]);
|
|
80
|
+
// } else {
|
|
81
|
+
// setFilters((prev) => [...prev, newFilter]);
|
|
82
|
+
// setSelectedFilters((prev) => [...prev, newSelectedFilter]);
|
|
83
|
+
// }
|
|
127
84
|
|
|
128
85
|
setShowFilterOption(false);
|
|
129
86
|
};
|
|
@@ -72,10 +72,13 @@ const SavedFilter = ({
|
|
|
72
72
|
|
|
73
73
|
const renderList = () => (
|
|
74
74
|
<>
|
|
75
|
-
<CustomSearch
|
|
75
|
+
<CustomSearch
|
|
76
|
+
value={searchTerm}
|
|
77
|
+
onChange={setSearchTerm}
|
|
78
|
+
className="search-input"
|
|
79
|
+
/>
|
|
76
80
|
|
|
77
|
-
{
|
|
78
|
-
columnsData?.saved_filter?.length === 0 ? (
|
|
81
|
+
{columnsData.saved_filter.length === 0 ? (
|
|
79
82
|
<Typography sx={{ mt: 2 }}>No saved filters yet.</Typography>
|
|
80
83
|
) : (
|
|
81
84
|
<List
|
|
@@ -242,6 +242,9 @@ function TableWrapper<T>({
|
|
|
242
242
|
// ...(styleOptions?.wrapperStyle && { style: styleOptions.wrapperStyle }),
|
|
243
243
|
// className: "ts__table__wrapper",
|
|
244
244
|
// };
|
|
245
|
+
// const emptyListComponentCondition = () => {
|
|
246
|
+
// if(isLoading) {}
|
|
247
|
+
// }
|
|
245
248
|
|
|
246
249
|
const showFilterCondition = filterOptions?.show;
|
|
247
250
|
|
|
@@ -275,8 +278,8 @@ function TableWrapper<T>({
|
|
|
275
278
|
/>
|
|
276
279
|
) : null
|
|
277
280
|
}
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
searchValue={craftTopbarOptions.searchValue}
|
|
282
|
+
onSearchChange={craftTopbarOptions.onSearchChange}
|
|
280
283
|
tableStates={tableStates}
|
|
281
284
|
onFilterButtonClick={topbarOptions?.onFilterButtonClick}
|
|
282
285
|
/>
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
opacity: 0;
|
|
29
29
|
margin-right: calc(-1 * var(--filter-width));
|
|
30
30
|
transition: all 0.4s ease-in-out;
|
|
31
|
+
max-height: calc(100vh - 50px);
|
|
31
32
|
}
|
|
32
33
|
.ts__table__filter.show {
|
|
33
34
|
transition: all 0.4s ease-in-out;
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
max-width: var(--filter-width);
|
|
37
38
|
margin-left: 1.25rem;
|
|
38
39
|
margin-right: 0rem;
|
|
40
|
+
min-height: calc(100vh - 50px);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|