rez-table-listing-mui 1.2.15 → 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/common/index.scss +1 -1
- 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 -3
- package/src/listing/components/login/index.tsx +1 -1
- package/src/listing/components/table-head.tsx +2 -6
- package/src/listing/components/table-settings/components/column.tsx +0 -5
- package/src/listing/components/table-settings/components/group-by.tsx +3 -5
- package/src/listing/components/table-settings/components/lane.tsx +2 -4
- package/src/listing/components/table-settings/components/sorting.tsx +0 -2
- package/src/listing/components/tabs/index.scss +1 -1
- 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 -5
- 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
|
@@ -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
|
|
|
@@ -270,7 +332,6 @@ export const useSaveSettingsDataAPI = (entity_type: string) => {
|
|
|
270
332
|
},
|
|
271
333
|
onError: (error: any) => {
|
|
272
334
|
const msg = error?.response?.data?.message;
|
|
273
|
-
console.log("Error in saving settings tab data", msg, error);
|
|
274
335
|
},
|
|
275
336
|
});
|
|
276
337
|
|
|
@@ -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;
|
package/src/view/ListingView.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useDetailsQueryAPI,
|
|
7
7
|
useFetchData,
|
|
8
8
|
} from "../listing/libs/hooks/useEntityTableHooks";
|
|
9
|
-
import { ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
9
|
+
import { ENTITY_TYPE, MAPPED_ENTITY_TYPE } from "../listing/libs/utils/common";
|
|
10
10
|
import {
|
|
11
11
|
useCommonDropdownAPI,
|
|
12
12
|
useDeleteFilterAPI,
|
|
@@ -22,9 +22,10 @@ import { ColumnDef } from "@tanstack/react-table";
|
|
|
22
22
|
import { FilterMasterStateProps } from "../listing/types/filter";
|
|
23
23
|
import { SettingsDataProps } from "../listing/types/filter-settings";
|
|
24
24
|
import TableWrapper from "../listing/components/index-table";
|
|
25
|
-
import { CraftTableFilter } from "..";
|
|
26
25
|
import { TableTabs } from "../listing/components/tabs";
|
|
27
26
|
import { QuickFilterSettings } from "../listing/components/table-settings";
|
|
27
|
+
import CraftTableFilterWrapper from "./FIlterWrapper";
|
|
28
|
+
import { saveLayoutAPI } from "../listing/libs/services/saveLayoutAPI";
|
|
28
29
|
|
|
29
30
|
function ListingView() {
|
|
30
31
|
// const [mockLoading, setMockLoading] = useState<boolean>(true);
|
|
@@ -54,7 +55,7 @@ function ListingView() {
|
|
|
54
55
|
);
|
|
55
56
|
|
|
56
57
|
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
57
|
-
const { deleteMutation } = useDeleteFilterAPI(); //API FOR DELETING FILTER
|
|
58
|
+
const { deleteMutation } = useDeleteFilterAPI(tableStates); //API FOR DELETING FILTER
|
|
58
59
|
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
59
60
|
const { saveSettingsDataMutation } = useSaveSettingsDataAPI(ENTITY_TYPE);
|
|
60
61
|
const { dropdownData } = useCommonDropdownAPI(metaQuery.data);
|
|
@@ -288,6 +289,17 @@ function ListingView() {
|
|
|
288
289
|
);
|
|
289
290
|
};
|
|
290
291
|
|
|
292
|
+
const handleChangeFunction = async (data: any) => {
|
|
293
|
+
const payload = {
|
|
294
|
+
entity_type: MAPPED_ENTITY_TYPE,
|
|
295
|
+
mapped_entity_type: ENTITY_TYPE,
|
|
296
|
+
mapped_json: data,
|
|
297
|
+
type: "filter",
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
await saveLayoutAPI(payload);
|
|
301
|
+
};
|
|
302
|
+
|
|
291
303
|
// API to handle removing or deleting a filter
|
|
292
304
|
const handleRemoveFilter = () => {
|
|
293
305
|
const payload = {
|
|
@@ -325,7 +337,7 @@ function ListingView() {
|
|
|
325
337
|
|
|
326
338
|
const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
|
|
327
339
|
const payload = {
|
|
328
|
-
entity_type:
|
|
340
|
+
entity_type: MAPPED_ENTITY_TYPE,
|
|
329
341
|
mapped_entity_type: ENTITY_TYPE,
|
|
330
342
|
layout_json: settingsData,
|
|
331
343
|
};
|
|
@@ -336,8 +348,6 @@ function ListingView() {
|
|
|
336
348
|
return (
|
|
337
349
|
<TableWrapper
|
|
338
350
|
data={filteredData}
|
|
339
|
-
// data={data}
|
|
340
|
-
// columns={defaultColumns}
|
|
341
351
|
columns={columns && columns.length > 0 ? columns : defaultColumns}
|
|
342
352
|
tableStates={tableStates}
|
|
343
353
|
featureOptions={{
|
|
@@ -367,7 +377,7 @@ function ListingView() {
|
|
|
367
377
|
filterOptions={{
|
|
368
378
|
show: tableStates?.showTableFilter,
|
|
369
379
|
component: (
|
|
370
|
-
<
|
|
380
|
+
<CraftTableFilterWrapper
|
|
371
381
|
tableStates={tableStates}
|
|
372
382
|
onClose={() => tableStates.setShowTableFilter(false)}
|
|
373
383
|
onUpdateFilter={handleUpdateFilter}
|
|
@@ -375,6 +385,7 @@ function ListingView() {
|
|
|
375
385
|
dropdownData={dropdownData || []}
|
|
376
386
|
onDeleteFilter={handleRemoveFilter}
|
|
377
387
|
onSaveFilter={handleSaveFilter}
|
|
388
|
+
onChangeFunction={handleChangeFunction}
|
|
378
389
|
/>
|
|
379
390
|
),
|
|
380
391
|
}}
|