rez-table-listing-mui 1.2.16 → 1.2.17
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 +8 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/assets/svg.tsx +2 -1
- package/src/kanban/index.tsx +11 -2
- package/src/listing/components/filter/components/attributes-filter.tsx +156 -50
- package/src/listing/components/filter/components/forms/components/Filter-criteria.tsx +21 -2
- package/src/listing/components/filter/components/forms/index.tsx +29 -9
- package/src/listing/components/filter/components/main-filter.tsx +16 -1
- package/src/listing/components/filter/components/saved-edit-filter.tsx +27 -0
- package/src/listing/components/filter/components/saved-filter.tsx +66 -25
- package/src/listing/components/filter/index.tsx +56 -44
- package/src/listing/components/index.scss +1 -1
- package/src/listing/components/login/index.tsx +1 -1
- package/src/listing/components/table-head.tsx +2 -6
- package/src/listing/components/topbar/index.scss +0 -1
- package/src/listing/components/topbar/index.tsx +66 -20
- package/src/listing/libs/hooks/useEntityTableAPI.tsx +66 -4
- package/src/listing/libs/hooks/useGetNavigationLayoutAPI.tsx +12 -0
- package/src/listing/libs/services/getLayoutAPI.tsx +17 -0
- package/src/listing/libs/services/saveLayoutAPI.tsx +20 -0
- package/src/listing/libs/utils/apiColumn.ts +2 -2
- package/src/listing/libs/utils/common.ts +1 -0
- package/src/listing/types/common.ts +8 -0
- package/src/listing/types/filter.ts +13 -0
- package/src/view/FIlterWrapper.tsx +46 -0
- package/src/view/ListingView.tsx +18 -7
|
@@ -23,6 +23,7 @@ export function TableFilter({
|
|
|
23
23
|
onSaveFilter,
|
|
24
24
|
onUpdateFilter,
|
|
25
25
|
dropdownData,
|
|
26
|
+
onChangeFunction,
|
|
26
27
|
}: FilterDrawerProps) {
|
|
27
28
|
const [tabValue, setTabValue] = useState(0);
|
|
28
29
|
const [editMode, setEditMode] = useState(false);
|
|
@@ -30,6 +31,11 @@ export function TableFilter({
|
|
|
30
31
|
UpdatedFilterStateProps[]
|
|
31
32
|
>([]);
|
|
32
33
|
|
|
34
|
+
// tabs
|
|
35
|
+
const FILTER_TAB = 0;
|
|
36
|
+
const SAVED_TAB = 1;
|
|
37
|
+
const ATTR_TAB = 2;
|
|
38
|
+
|
|
33
39
|
// remove this
|
|
34
40
|
const [saveFilterModalOpen, setSaveFilterModalOpen] = useState(false);
|
|
35
41
|
const [deleteFilterModalOpen, setDeleteFilterModalOpen] = useState(false);
|
|
@@ -45,6 +51,26 @@ export function TableFilter({
|
|
|
45
51
|
setShowFilterOption,
|
|
46
52
|
} = tableStates;
|
|
47
53
|
|
|
54
|
+
const clearAttributeRadio = () => {
|
|
55
|
+
const newFilterMaster = {
|
|
56
|
+
...filterMaster,
|
|
57
|
+
attributes: {
|
|
58
|
+
...filterMaster?.attributes,
|
|
59
|
+
radio: [],
|
|
60
|
+
},
|
|
61
|
+
activeFilterTabIndex: FILTER_TAB,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
setFilterMaster(newFilterMaster as FilterMasterStateProps);
|
|
65
|
+
|
|
66
|
+
// const newState = {
|
|
67
|
+
// filterMaster: newFilterMaster,
|
|
68
|
+
// filters: filters,
|
|
69
|
+
// };
|
|
70
|
+
|
|
71
|
+
// onChangeFunction && onChangeFunction(newState);
|
|
72
|
+
};
|
|
73
|
+
|
|
48
74
|
const filterNameInput: InputField = {
|
|
49
75
|
label: "Filter Name",
|
|
50
76
|
placeholder: 'e.g., "Website Leads - This Week"',
|
|
@@ -78,6 +104,10 @@ export function TableFilter({
|
|
|
78
104
|
}, [filters, columnsData, tabValue]);
|
|
79
105
|
|
|
80
106
|
const handleTabChange = (_: React.SyntheticEvent, newValue: number) => {
|
|
107
|
+
if (tabValue === ATTR_TAB && newValue === FILTER_TAB) {
|
|
108
|
+
clearAttributeRadio();
|
|
109
|
+
}
|
|
110
|
+
|
|
81
111
|
setTabValue(newValue);
|
|
82
112
|
if (newValue === 0) {
|
|
83
113
|
setEditMode(false);
|
|
@@ -93,44 +123,33 @@ export function TableFilter({
|
|
|
93
123
|
];
|
|
94
124
|
|
|
95
125
|
const handleTabCrossClick = (index: number) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
126
|
+
// always-clear bits
|
|
127
|
+
setFilters([]);
|
|
128
|
+
setSelectedFilters([]);
|
|
129
|
+
|
|
130
|
+
// only tab 1 needs this
|
|
131
|
+
if (index === 1) setEditMode(false);
|
|
132
|
+
|
|
133
|
+
const patches: Record<number, Partial<FilterMasterStateProps>> = {
|
|
134
|
+
0: {}, // no extra fields
|
|
135
|
+
1: { saved_filters: { selectedId: "", selectedName: "" } },
|
|
136
|
+
2: { attributes: { radio: [], selected: "" } },
|
|
103
137
|
};
|
|
104
138
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
117
|
-
},
|
|
118
|
-
2: () => {
|
|
119
|
-
commonStateReset();
|
|
120
|
-
setFilterMaster(
|
|
121
|
-
(prev) =>
|
|
122
|
-
({
|
|
123
|
-
...prev,
|
|
124
|
-
attributes: {
|
|
125
|
-
radio: [],
|
|
126
|
-
selected: "",
|
|
127
|
-
},
|
|
128
|
-
} as FilterMasterStateProps)
|
|
129
|
-
);
|
|
130
|
-
},
|
|
139
|
+
const newFilterMasterState = {
|
|
140
|
+
...filterMaster,
|
|
141
|
+
activeFilterTabIndex: -1,
|
|
142
|
+
...(patches[index] ?? {}),
|
|
143
|
+
} as FilterMasterStateProps;
|
|
144
|
+
|
|
145
|
+
setFilterMaster(newFilterMasterState);
|
|
146
|
+
|
|
147
|
+
const newState = {
|
|
148
|
+
filterMaster: newFilterMasterState,
|
|
149
|
+
filters: filters,
|
|
131
150
|
};
|
|
132
151
|
|
|
133
|
-
|
|
152
|
+
onChangeFunction && onChangeFunction(newState);
|
|
134
153
|
};
|
|
135
154
|
|
|
136
155
|
return (
|
|
@@ -167,6 +186,7 @@ export function TableFilter({
|
|
|
167
186
|
setSelectedFilters={setSelectedFilters}
|
|
168
187
|
setSavedFilterModalOpen={setSaveFilterModalOpen}
|
|
169
188
|
dropdownData={dropdownData}
|
|
189
|
+
onChangeFunction={onChangeFunction}
|
|
170
190
|
/>
|
|
171
191
|
</CustomTabPanel>
|
|
172
192
|
|
|
@@ -182,6 +202,7 @@ export function TableFilter({
|
|
|
182
202
|
setSavedFilterModalOpen={setSaveFilterModalOpen}
|
|
183
203
|
dropdownData={dropdownData}
|
|
184
204
|
tabValue={tabValue}
|
|
205
|
+
onChangeFunction={onChangeFunction}
|
|
185
206
|
/>
|
|
186
207
|
</CustomTabPanel>
|
|
187
208
|
|
|
@@ -193,6 +214,7 @@ export function TableFilter({
|
|
|
193
214
|
searchTerm={searchTerm}
|
|
194
215
|
setSearchTerm={setSearchTerm}
|
|
195
216
|
tabValue={tabValue}
|
|
217
|
+
onChangeFunction={onChangeFunction}
|
|
196
218
|
/>
|
|
197
219
|
</CustomTabPanel>
|
|
198
220
|
|
|
@@ -230,7 +252,6 @@ export function TableFilter({
|
|
|
230
252
|
|
|
231
253
|
onSaveFilter && onSaveFilter(inputValue || "");
|
|
232
254
|
setSaveFilterModalOpen(false);
|
|
233
|
-
|
|
234
255
|
setTabValue(1);
|
|
235
256
|
},
|
|
236
257
|
variant: "contained",
|
|
@@ -267,15 +288,6 @@ export function TableFilter({
|
|
|
267
288
|
onDeleteFilter && onDeleteFilter();
|
|
268
289
|
setDeleteFilterModalOpen(false);
|
|
269
290
|
setEditMode && setEditMode(false);
|
|
270
|
-
setSelectedFilters([]);
|
|
271
|
-
setFilters([]);
|
|
272
|
-
setFilterMaster(
|
|
273
|
-
(prev) =>
|
|
274
|
-
({
|
|
275
|
-
...prev,
|
|
276
|
-
activeFilterTabIndex: -1,
|
|
277
|
-
} as FilterMasterStateProps)
|
|
278
|
-
);
|
|
279
291
|
},
|
|
280
292
|
variant: "contained",
|
|
281
293
|
sx: {
|
|
@@ -5,11 +5,7 @@ import {
|
|
|
5
5
|
} from "../types/table-options";
|
|
6
6
|
import { DownArrow, UpArrow } from "../../assets/svg";
|
|
7
7
|
import { CSSProperties, useState } from "react";
|
|
8
|
-
import {
|
|
9
|
-
getColumnAlignment,
|
|
10
|
-
getColumnPinningStyles,
|
|
11
|
-
} from "../libs/utils/common";
|
|
12
|
-
import { align } from "../types/common";
|
|
8
|
+
import { getColumnPinningStyles } from "../libs/utils/common";
|
|
13
9
|
import {
|
|
14
10
|
horizontalListSortingStrategy,
|
|
15
11
|
SortableContext,
|
|
@@ -39,7 +35,7 @@ function TableHead<T>({
|
|
|
39
35
|
} = featureOptions;
|
|
40
36
|
|
|
41
37
|
// Popover
|
|
42
|
-
const [
|
|
38
|
+
const [, setAnchorEl] = useState<HTMLElement | null>(null);
|
|
43
39
|
|
|
44
40
|
const handleHover = (event: React.MouseEvent<HTMLElement>) => {
|
|
45
41
|
setAnchorEl((prev) => (prev ? null : event.currentTarget));
|
|
@@ -60,8 +60,7 @@ function Topbar<T>({
|
|
|
60
60
|
table.getAllLeafColumns().map((col) => col.id)
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
// const [showFilterInput, setShowFilterInput] = useState(false);
|
|
63
|
+
const { setShowTableFilter } = tableStates;
|
|
65
64
|
|
|
66
65
|
// search
|
|
67
66
|
const [showSearchInput, setShowSearchInput] = useState(false);
|
|
@@ -77,7 +76,6 @@ function Topbar<T>({
|
|
|
77
76
|
rightSideComponent,
|
|
78
77
|
showColumnToggle,
|
|
79
78
|
showChangeLayoutToggle,
|
|
80
|
-
viewMoreToggle,
|
|
81
79
|
showSortingToggle,
|
|
82
80
|
showFilterToggle,
|
|
83
81
|
showSearch,
|
|
@@ -93,10 +91,6 @@ function Topbar<T>({
|
|
|
93
91
|
handler: () => setShowColumnHiding(false),
|
|
94
92
|
});
|
|
95
93
|
|
|
96
|
-
const handleLayoutIconClick = (event: React.MouseEvent<HTMLElement>) => {
|
|
97
|
-
setLayoutAnchorEl(event.currentTarget);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
94
|
const handleLayoutSelect = (layout: string) => {
|
|
101
95
|
setSelectedLayout(layout);
|
|
102
96
|
setLayoutAnchorEl(null);
|
|
@@ -175,14 +169,6 @@ function Topbar<T>({
|
|
|
175
169
|
{rightSideComponent}
|
|
176
170
|
{paginationComponent}
|
|
177
171
|
|
|
178
|
-
{/* {showSearch && (
|
|
179
|
-
<div title="Search">
|
|
180
|
-
<TableSearch
|
|
181
|
-
value={searchValue ?? ""}
|
|
182
|
-
onChange={onSearchChange ?? (() => {})}
|
|
183
|
-
/>
|
|
184
|
-
</div>
|
|
185
|
-
)} */}
|
|
186
172
|
{showSearch && (
|
|
187
173
|
<div
|
|
188
174
|
title="Search"
|
|
@@ -203,9 +189,6 @@ function Topbar<T>({
|
|
|
203
189
|
{showChangeLayoutToggle && (
|
|
204
190
|
<>
|
|
205
191
|
<div className="change-layout ts--button" title="Layout">
|
|
206
|
-
{/* <div onClick={handleLayoutIconClick}>
|
|
207
|
-
<ChangeLayoutIcon />
|
|
208
|
-
</div> */}
|
|
209
192
|
<div
|
|
210
193
|
onClick={(e) => {
|
|
211
194
|
const customEvent = new CustomEvent("triggerLayoutPopover", {
|
|
@@ -275,13 +258,76 @@ function Topbar<T>({
|
|
|
275
258
|
</>
|
|
276
259
|
)}
|
|
277
260
|
|
|
261
|
+
{/* {showFilterToggle && (
|
|
262
|
+
<div
|
|
263
|
+
className="filter ts--button"
|
|
264
|
+
title="Filter"
|
|
265
|
+
onClick={onFilterButtonClick}
|
|
266
|
+
style={{
|
|
267
|
+
display: "flex",
|
|
268
|
+
justifyContent: "center",
|
|
269
|
+
alignItems: "center",
|
|
270
|
+
backgroundColor:
|
|
271
|
+
tableStates.showTableFilter || tableStates.filters.length > 0
|
|
272
|
+
? "#e8e2fb"
|
|
273
|
+
: "transparent",
|
|
274
|
+
height: "25px",
|
|
275
|
+
width: "25px",
|
|
276
|
+
borderRadius: "6px",
|
|
277
|
+
cursor: "pointer",
|
|
278
|
+
}}
|
|
279
|
+
>
|
|
280
|
+
<FilterationIcon
|
|
281
|
+
color={
|
|
282
|
+
tableStates.showTableFilter || tableStates.filters.length > 0
|
|
283
|
+
? "#7A5AF8"
|
|
284
|
+
: "#1C1B1F"
|
|
285
|
+
}
|
|
286
|
+
/>
|
|
287
|
+
</div>
|
|
288
|
+
)} */}
|
|
289
|
+
|
|
278
290
|
{showFilterToggle && (
|
|
279
291
|
<div
|
|
280
292
|
className="filter ts--button"
|
|
281
293
|
title="Filter"
|
|
282
|
-
onClick={onFilterButtonClick
|
|
294
|
+
onClick={onFilterButtonClick}
|
|
295
|
+
style={{
|
|
296
|
+
position: "relative",
|
|
297
|
+
display: "flex",
|
|
298
|
+
justifyContent: "center",
|
|
299
|
+
alignItems: "center",
|
|
300
|
+
backgroundColor:
|
|
301
|
+
tableStates.showTableFilter || tableStates.filters.length > 0
|
|
302
|
+
? "#eae4fe"
|
|
303
|
+
: "transparent",
|
|
304
|
+
height: "25px",
|
|
305
|
+
width: "25px",
|
|
306
|
+
borderRadius: "6px",
|
|
307
|
+
cursor: "pointer",
|
|
308
|
+
}}
|
|
283
309
|
>
|
|
284
|
-
<FilterationIcon
|
|
310
|
+
<FilterationIcon
|
|
311
|
+
color={
|
|
312
|
+
tableStates.showTableFilter || tableStates.filters.length > 0
|
|
313
|
+
? "#7A5AF8"
|
|
314
|
+
: "#1C1B1F"
|
|
315
|
+
}
|
|
316
|
+
/>
|
|
317
|
+
|
|
318
|
+
{tableStates.filters.length > 0 && !tableStates.showTableFilter && (
|
|
319
|
+
<span
|
|
320
|
+
style={{
|
|
321
|
+
position: "absolute",
|
|
322
|
+
top: "1px",
|
|
323
|
+
right: "1px",
|
|
324
|
+
width: "6px",
|
|
325
|
+
height: "6px",
|
|
326
|
+
borderRadius: "50%",
|
|
327
|
+
backgroundColor: "#F63D68",
|
|
328
|
+
}}
|
|
329
|
+
/>
|
|
330
|
+
)}
|
|
285
331
|
</div>
|
|
286
332
|
)}
|
|
287
333
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
useQuery,
|
|
5
5
|
useQueryClient,
|
|
6
6
|
} from "@tanstack/react-query";
|
|
7
|
-
import { api, ENTITY_TYPE } from "../utils/common";
|
|
7
|
+
import { api, ENTITY_TYPE, MAPPED_ENTITY_TYPE } from "../utils/common";
|
|
8
8
|
import {
|
|
9
9
|
APIParamsProps,
|
|
10
10
|
EntityListingResponse,
|
|
@@ -20,7 +20,12 @@ import {
|
|
|
20
20
|
updateSavedFilter,
|
|
21
21
|
viewSettingsDropDown,
|
|
22
22
|
} from "../utils/apiColumn";
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
FilterColumnsDataProps,
|
|
25
|
+
FilterMasterStateProps,
|
|
26
|
+
} from "../../types/filter";
|
|
27
|
+
import { CraftTableOptionsProps } from "../../types/table-options";
|
|
28
|
+
import { saveLayoutAPI } from "../services/saveLayoutAPI";
|
|
24
29
|
|
|
25
30
|
const entityListingCall = async ({
|
|
26
31
|
page,
|
|
@@ -129,7 +134,7 @@ export const useSavedFilterAPI = () => {
|
|
|
129
134
|
};
|
|
130
135
|
|
|
131
136
|
//for delete filter API
|
|
132
|
-
export const useDeleteFilterAPI = () => {
|
|
137
|
+
export const useDeleteFilterAPI = (tableStates: CraftTableOptionsProps) => {
|
|
133
138
|
const queryClient = useQueryClient();
|
|
134
139
|
const deleteMutation = useMutation({
|
|
135
140
|
mutationKey: ["deleteFilter"],
|
|
@@ -142,8 +147,65 @@ export const useDeleteFilterAPI = () => {
|
|
|
142
147
|
}) => {
|
|
143
148
|
return deleteSavedFilter(entity_type, payload);
|
|
144
149
|
},
|
|
145
|
-
onSuccess: () => {
|
|
150
|
+
onSuccess: async () => {
|
|
146
151
|
queryClient.invalidateQueries({ queryKey: ["meta"] });
|
|
152
|
+
|
|
153
|
+
console.log("on success is running");
|
|
154
|
+
|
|
155
|
+
const { filters, filterToDelete, filterMaster, setFilterMaster } =
|
|
156
|
+
tableStates;
|
|
157
|
+
|
|
158
|
+
console.log(
|
|
159
|
+
filterToDelete?.value === filterMaster?.saved_filters?.selectedId,
|
|
160
|
+
filterToDelete,
|
|
161
|
+
filterMaster
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
if (filterToDelete?.value === filterMaster?.saved_filters?.selectedId) {
|
|
165
|
+
console.log("inside if condition");
|
|
166
|
+
// const newFilterMasterState: FilterMasterStateProps = {
|
|
167
|
+
// ...filterMaster,
|
|
168
|
+
// attributes: {
|
|
169
|
+
// selected: filterMaster?.attributes.selected || "",
|
|
170
|
+
// radio: filterMaster?.attributes.radio || [],
|
|
171
|
+
// },
|
|
172
|
+
// saved_filters: {
|
|
173
|
+
// selectedId: "",
|
|
174
|
+
// selectedName: "",
|
|
175
|
+
// },
|
|
176
|
+
// activeFilterTabIndex: -1,
|
|
177
|
+
// };
|
|
178
|
+
|
|
179
|
+
const newFilterMasterState = {
|
|
180
|
+
...filterMaster,
|
|
181
|
+
saved_filters: {
|
|
182
|
+
selectedId: "",
|
|
183
|
+
selectedName: "",
|
|
184
|
+
},
|
|
185
|
+
activeFilterTabIndex: -1,
|
|
186
|
+
};
|
|
187
|
+
console.log(" 1");
|
|
188
|
+
|
|
189
|
+
setFilterMaster(newFilterMasterState as FilterMasterStateProps);
|
|
190
|
+
|
|
191
|
+
const newState = {
|
|
192
|
+
filterMaster: newFilterMasterState as FilterMasterStateProps,
|
|
193
|
+
filters: filters,
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
console.log("first");
|
|
197
|
+
|
|
198
|
+
const payload = {
|
|
199
|
+
entity_type: MAPPED_ENTITY_TYPE,
|
|
200
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
201
|
+
mapped_json: newState,
|
|
202
|
+
type: "filter",
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
console.log("payload - ", payload);
|
|
206
|
+
|
|
207
|
+
await saveLayoutAPI(payload);
|
|
208
|
+
}
|
|
147
209
|
},
|
|
148
210
|
});
|
|
149
211
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { getLeadNavigationTabs } from "../services/getLayoutAPI";
|
|
3
|
+
|
|
4
|
+
export const useGetNavigationLayoutAPI = (entity_type: string) => {
|
|
5
|
+
const getNavigationLayoutQuery = useQuery({
|
|
6
|
+
queryKey: ["GET_NAVIGATION_LAYOUT", entity_type],
|
|
7
|
+
queryFn: () => getLeadNavigationTabs(entity_type),
|
|
8
|
+
enabled: !!entity_type,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return getNavigationLayoutQuery;
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { api } from "../utils/common";
|
|
2
|
+
|
|
3
|
+
export const getLeadNavigationTabs = async (entity_type: string) => {
|
|
4
|
+
try {
|
|
5
|
+
const params = {
|
|
6
|
+
entity_type: entity_type,
|
|
7
|
+
type: "filter",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const response = await api.get("/layout-preference", { params });
|
|
11
|
+
|
|
12
|
+
return response.data.mapped_json;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error("Failed to fetch settings data:", error);
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { api, MAPPED_ENTITY_TYPE } from "../utils/common";
|
|
2
|
+
|
|
3
|
+
export const saveLayoutAPI = async (payload: any) => {
|
|
4
|
+
let url = `/entity/create?entity_type=${MAPPED_ENTITY_TYPE}`;
|
|
5
|
+
if (
|
|
6
|
+
payload.mapped_entity_type === "USER" ||
|
|
7
|
+
payload.mapped_entity_type === "ROLE" ||
|
|
8
|
+
payload.mapped_entity_type === "ORGP"
|
|
9
|
+
) {
|
|
10
|
+
url = `/layout/create`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const response = await api.post(url, payload);
|
|
15
|
+
return response.data;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error("Failed to save settings data:", error);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { api } from "./common";
|
|
1
|
+
import { api, MAPPED_ENTITY_TYPE } from "./common";
|
|
2
2
|
import {
|
|
3
3
|
createSavedFilterPayload,
|
|
4
4
|
deleteSavedFilterPayload,
|
|
@@ -127,7 +127,7 @@ export const updateSavedFilter = async (
|
|
|
127
127
|
|
|
128
128
|
export const saveSettingsData = async (payload: any) => {
|
|
129
129
|
try {
|
|
130
|
-
const response = await api.post(`/entity/create?entity_type
|
|
130
|
+
const response = await api.post(`/entity/create?entity_type=${MAPPED_ENTITY_TYPE}`, payload);
|
|
131
131
|
return response.data;
|
|
132
132
|
} catch (error) {
|
|
133
133
|
console.error("Failed to save settings data:", error);
|
|
@@ -79,6 +79,7 @@ export function customDebounce<T extends (...args: any[]) => any>(
|
|
|
79
79
|
//ENTITY TYPE
|
|
80
80
|
const ENVIRONMENT = "crm_dev";
|
|
81
81
|
export const ENTITY_TYPE = "LEAD";
|
|
82
|
+
export const MAPPED_ENTITY_TYPE = "LAP";
|
|
82
83
|
|
|
83
84
|
const environments = {
|
|
84
85
|
adm_dev: "http://localhost:4010/api",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FilterMasterStateProps, UpdatedFilterStateProps } from "./filter";
|
|
2
|
+
|
|
1
3
|
export interface defaultColumnsProps {
|
|
2
4
|
id: number;
|
|
3
5
|
name: string;
|
|
@@ -111,3 +113,9 @@ export type DropdownOption = {
|
|
|
111
113
|
value: string | number;
|
|
112
114
|
label: string;
|
|
113
115
|
};
|
|
116
|
+
|
|
117
|
+
export interface onFilterChangeFunctionProps {
|
|
118
|
+
updatedFilters?: any;
|
|
119
|
+
filterMaster?: any;
|
|
120
|
+
filters?: any;
|
|
121
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { onFilterChangeFunctionProps } from "./common";
|
|
1
2
|
import { CraftTableOptionsProps } from "./table-options";
|
|
2
3
|
|
|
3
4
|
interface OperationProps {
|
|
@@ -79,6 +80,10 @@ export interface FilterDrawerProps {
|
|
|
79
80
|
tableData?: {
|
|
80
81
|
entity_list: any[];
|
|
81
82
|
};
|
|
83
|
+
onChangeFunction: ({
|
|
84
|
+
updatedFilters,
|
|
85
|
+
filterMaster,
|
|
86
|
+
}: onFilterChangeFunctionProps) => void;
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
export interface FilterCriteria {
|
|
@@ -175,6 +180,10 @@ export interface FilterFormComponentProps {
|
|
|
175
180
|
setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
176
181
|
setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
177
182
|
tabValue?: number;
|
|
183
|
+
onChangeFunction: ({
|
|
184
|
+
updatedFilters,
|
|
185
|
+
filterMaster,
|
|
186
|
+
}: onFilterChangeFunctionProps) => void;
|
|
178
187
|
}
|
|
179
188
|
|
|
180
189
|
export interface FilterMasterStateProps {
|
|
@@ -196,6 +205,10 @@ export interface AttributesFilterProps {
|
|
|
196
205
|
searchTerm: string;
|
|
197
206
|
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
198
207
|
tabValue?: number;
|
|
208
|
+
onChangeFunction: ({
|
|
209
|
+
updatedFilters,
|
|
210
|
+
filterMaster,
|
|
211
|
+
}: onFilterChangeFunctionProps) => void;
|
|
199
212
|
}
|
|
200
213
|
|
|
201
214
|
export interface AttributesFilterSelectProps {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { CraftTableFilter } from "..";
|
|
3
|
+
import { useGetNavigationLayoutAPI } from "../listing/libs/hooks/useGetNavigationLayoutAPI";
|
|
4
|
+
import { ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
5
|
+
|
|
6
|
+
const CraftTableFilterWrapper = ({
|
|
7
|
+
tableStates,
|
|
8
|
+
dropdownData,
|
|
9
|
+
onDeleteFilter,
|
|
10
|
+
onSaveFilter,
|
|
11
|
+
handleUpdateFilter,
|
|
12
|
+
onChangeFunction,
|
|
13
|
+
columnsData,
|
|
14
|
+
}: any) => {
|
|
15
|
+
const getNavigationLayoutQuery = useGetNavigationLayoutAPI(ENTITY_TYPE);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (getNavigationLayoutQuery.isSuccess) {
|
|
19
|
+
const { setFilters, setFilterMaster } = tableStates;
|
|
20
|
+
const filters = getNavigationLayoutQuery?.data?.filters || [];
|
|
21
|
+
const filterMaster = getNavigationLayoutQuery?.data?.filterMaster || {};
|
|
22
|
+
|
|
23
|
+
if (filters.length > 0) {
|
|
24
|
+
tableStates.setShowTableFilter(true);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setFilters(filters);
|
|
28
|
+
setFilterMaster(filterMaster);
|
|
29
|
+
}
|
|
30
|
+
}, [getNavigationLayoutQuery.isSuccess, getNavigationLayoutQuery.data]);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<CraftTableFilter
|
|
34
|
+
tableStates={tableStates}
|
|
35
|
+
onClose={() => tableStates.setShowTableFilter(false)}
|
|
36
|
+
onUpdateFilter={handleUpdateFilter}
|
|
37
|
+
columnsData={columnsData}
|
|
38
|
+
dropdownData={dropdownData || []}
|
|
39
|
+
onDeleteFilter={onDeleteFilter}
|
|
40
|
+
onSaveFilter={onSaveFilter}
|
|
41
|
+
onChangeFunction={onChangeFunction}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default CraftTableFilterWrapper;
|