rez-table-listing-mui 1.0.44 → 1.0.46
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.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +49 -12
- package/src/components/login/index.tsx +1 -1
- package/src/components/search/index.tsx +15 -7
- package/src/components/table-settings/components/column.tsx +24 -12
- package/src/components/table-settings/index.tsx +1 -0
- package/src/components/tabs/index.tsx +1 -1
- package/src/components/topbar/index.tsx +2 -6
- package/src/libs/hooks/useEntityTableAPI.tsx +6 -2
- package/src/libs/utils/common.ts +1 -1
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -45,7 +45,7 @@ function App() {
|
|
|
45
45
|
|
|
46
46
|
const { defaultColumns } = useDefaultColumns();
|
|
47
47
|
|
|
48
|
-
const { metaQuery } = useFetchData("
|
|
48
|
+
const { metaQuery } = useFetchData("BRD");
|
|
49
49
|
const { detailsQuery } = useDetailsQueryAPI(
|
|
50
50
|
filterMaster?.saved_filters?.selectedId
|
|
51
51
|
? filterMaster?.saved_filters?.selectedId
|
|
@@ -55,16 +55,16 @@ function App() {
|
|
|
55
55
|
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
56
56
|
const { deleteMutation } = useDeleteFilterAPI(); //API FOR DELETING FILTER
|
|
57
57
|
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
58
|
-
const { saveSettingsDataMutation } = useSaveSettingsDataAPI("
|
|
58
|
+
const { saveSettingsDataMutation } = useSaveSettingsDataAPI("BRD");
|
|
59
59
|
const { dropdownData } = useCommonDropdownAPI(metaQuery.data);
|
|
60
60
|
const { settingsTabDropdownData, settingsTabDropdownPending } =
|
|
61
61
|
useSettingsDropDownAPI({
|
|
62
|
-
entity_type: "
|
|
62
|
+
entity_type: "BRD",
|
|
63
63
|
column: filterSettingStates?.quickTabStates?.attribute,
|
|
64
64
|
sort_by: filterSettingStates?.quickTabStates?.sorting,
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
const { getSettingsAPIData } = useGetSettingsDataAPI("
|
|
67
|
+
const { getSettingsAPIData } = useGetSettingsDataAPI("BRD");
|
|
68
68
|
|
|
69
69
|
useEffect(() => {
|
|
70
70
|
// setTimeout(() => {
|
|
@@ -73,15 +73,52 @@ function App() {
|
|
|
73
73
|
|
|
74
74
|
const fetchMeta = async () => {
|
|
75
75
|
try {
|
|
76
|
-
const { res } = await entityTableMetaMaster("
|
|
77
|
-
|
|
76
|
+
const { res: allColumns } = await entityTableMetaMaster("BRD");
|
|
77
|
+
|
|
78
|
+
const savedColumnSettings = filterSettingStates.settingsData?.column;
|
|
79
|
+
|
|
80
|
+
if (
|
|
81
|
+
savedColumnSettings &&
|
|
82
|
+
!savedColumnSettings.isDefault &&
|
|
83
|
+
savedColumnSettings.tabs
|
|
84
|
+
) {
|
|
85
|
+
// Tab-wise view: find the active tab and use its show_list
|
|
86
|
+
const activeTabSettings = savedColumnSettings.tabs.find(
|
|
87
|
+
(tab) => tab.tab_name.toLowerCase() === selectedTab.toLowerCase()
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (activeTabSettings?.show_list) {
|
|
91
|
+
const visibleColumns = new Set(
|
|
92
|
+
activeTabSettings.show_list.map((c) => c.value)
|
|
93
|
+
);
|
|
94
|
+
const filtered = allColumns.filter((col: any) =>
|
|
95
|
+
visibleColumns.has(col.accessorKey)
|
|
96
|
+
);
|
|
97
|
+
setColumns(filtered);
|
|
98
|
+
} else {
|
|
99
|
+
// Fallback if no specific settings for the active tab are found
|
|
100
|
+
setColumns(allColumns);
|
|
101
|
+
}
|
|
102
|
+
} else if (savedColumnSettings && savedColumnSettings.show_list) {
|
|
103
|
+
// Default view: use the main show_list
|
|
104
|
+
const visibleColumns = new Set(
|
|
105
|
+
savedColumnSettings.show_list.map((c) => c.value)
|
|
106
|
+
);
|
|
107
|
+
const filtered = allColumns.filter((col: any) =>
|
|
108
|
+
visibleColumns.has(col.accessorKey)
|
|
109
|
+
);
|
|
110
|
+
setColumns(filtered);
|
|
111
|
+
} else {
|
|
112
|
+
// No settings found, use all columns
|
|
113
|
+
setColumns(allColumns);
|
|
114
|
+
}
|
|
78
115
|
} catch (error) {
|
|
79
116
|
console.error("Failed to fetch metadata:", error);
|
|
80
117
|
}
|
|
81
118
|
};
|
|
82
119
|
|
|
83
120
|
fetchMeta();
|
|
84
|
-
}, []);
|
|
121
|
+
}, [filterSettingStates.settingsData, selectedTab]);
|
|
85
122
|
|
|
86
123
|
useEffect(() => {
|
|
87
124
|
setFilters(detailsQuery.data ?? []);
|
|
@@ -97,7 +134,7 @@ function App() {
|
|
|
97
134
|
const { tableData } = useEntityTableAPI({
|
|
98
135
|
page: 0,
|
|
99
136
|
size: 50,
|
|
100
|
-
entity_type: "
|
|
137
|
+
entity_type: "BRD",
|
|
101
138
|
tabs: {
|
|
102
139
|
columnName: "status",
|
|
103
140
|
sortBy: "ASC",
|
|
@@ -176,7 +213,7 @@ function App() {
|
|
|
176
213
|
const payload = {
|
|
177
214
|
name,
|
|
178
215
|
is_default: false,
|
|
179
|
-
mapped_entity_type: "
|
|
216
|
+
mapped_entity_type: "BRD", // For that entity type
|
|
180
217
|
status: "ACTIVE",
|
|
181
218
|
entity_type: "SFM", // FIXED entity type
|
|
182
219
|
filterDetails: quickFilter,
|
|
@@ -200,7 +237,7 @@ function App() {
|
|
|
200
237
|
name: filterToDelete?.label,
|
|
201
238
|
id: filterToDelete?.value,
|
|
202
239
|
is_default: false,
|
|
203
|
-
mapped_entity_type: "
|
|
240
|
+
mapped_entity_type: "BRD",
|
|
204
241
|
status: "INACTIVE",
|
|
205
242
|
entity_type: "SFM",
|
|
206
243
|
};
|
|
@@ -220,7 +257,7 @@ function App() {
|
|
|
220
257
|
name: filterMaster?.saved_filters?.selectedName, // Name of the filter
|
|
221
258
|
is_default: false,
|
|
222
259
|
id: filterMaster?.saved_filters?.selectedId,
|
|
223
|
-
mapped_entity_type: "
|
|
260
|
+
mapped_entity_type: "BRD",
|
|
224
261
|
status: "ACTIVE",
|
|
225
262
|
entity_type: "SFM",
|
|
226
263
|
filterDetails: quickFilter,
|
|
@@ -232,7 +269,7 @@ function App() {
|
|
|
232
269
|
const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
|
|
233
270
|
const payload = {
|
|
234
271
|
entity_type: "LAP",
|
|
235
|
-
mapped_entity_type: "
|
|
272
|
+
mapped_entity_type: "BRD",
|
|
236
273
|
layout_json: settingsData,
|
|
237
274
|
};
|
|
238
275
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from "react";
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
2
|
import { SearchIcon } from "../../assets/svg";
|
|
3
3
|
import useOutsideClick from "../../libs/hooks/useOutsideClick";
|
|
4
|
+
import { customDebounce } from "../../libs/utils/debounce";
|
|
4
5
|
|
|
5
6
|
interface TableSearchProps {
|
|
6
7
|
value: string;
|
|
@@ -12,6 +13,14 @@ const TableSearch: React.FC<TableSearchProps> = ({ value, onChange }) => {
|
|
|
12
13
|
const [localValue, setLocalValue] = useState(value);
|
|
13
14
|
const searchContainerRef = useRef<HTMLDivElement>(null);
|
|
14
15
|
|
|
16
|
+
// Debounced onChange function
|
|
17
|
+
const debouncedOnChange = useCallback(
|
|
18
|
+
customDebounce((newValue: string) => {
|
|
19
|
+
onChange(newValue);
|
|
20
|
+
}, 1000),
|
|
21
|
+
[onChange]
|
|
22
|
+
);
|
|
23
|
+
|
|
15
24
|
// Sync local state with prop value
|
|
16
25
|
useEffect(() => {
|
|
17
26
|
setLocalValue(value);
|
|
@@ -21,20 +30,19 @@ const TableSearch: React.FC<TableSearchProps> = ({ value, onChange }) => {
|
|
|
21
30
|
ref: searchContainerRef,
|
|
22
31
|
handler: () => {
|
|
23
32
|
setShowSearchInput(false);
|
|
24
|
-
// Update parent when clicking outside if value changed
|
|
25
|
-
if (localValue !== value) {
|
|
26
|
-
onChange(localValue);
|
|
27
|
-
}
|
|
28
33
|
},
|
|
29
34
|
});
|
|
30
35
|
|
|
31
36
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
32
37
|
const newValue = e.target.value;
|
|
33
38
|
setLocalValue(newValue);
|
|
34
|
-
|
|
39
|
+
debouncedOnChange(newValue);
|
|
35
40
|
};
|
|
36
41
|
|
|
37
42
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
43
|
+
if (e.key === "Enter") {
|
|
44
|
+
onChange(localValue);
|
|
45
|
+
}
|
|
38
46
|
if (e.key === "Escape") {
|
|
39
47
|
setShowSearchInput(false);
|
|
40
48
|
}
|
|
@@ -49,7 +57,7 @@ const TableSearch: React.FC<TableSearchProps> = ({ value, onChange }) => {
|
|
|
49
57
|
if (!showSearchInput) {
|
|
50
58
|
// Focus input when showing
|
|
51
59
|
setTimeout(() => {
|
|
52
|
-
searchContainerRef.current?.querySelector(
|
|
60
|
+
searchContainerRef.current?.querySelector("input")?.focus();
|
|
53
61
|
}, 100);
|
|
54
62
|
}
|
|
55
63
|
}}
|
|
@@ -39,8 +39,14 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
|
|
|
39
39
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
40
40
|
const [selectedTabIndex, setSelectedTabIndex] = useState<number>(0);
|
|
41
41
|
|
|
42
|
-
const {
|
|
43
|
-
|
|
42
|
+
const {
|
|
43
|
+
quickTabStates,
|
|
44
|
+
columnTabState,
|
|
45
|
+
setColumnTabState,
|
|
46
|
+
settingsData,
|
|
47
|
+
sortingTabState,
|
|
48
|
+
setSortingTabState,
|
|
49
|
+
} = filterSettingStates;
|
|
44
50
|
|
|
45
51
|
useEffect(() => {
|
|
46
52
|
const mappedColumns: ColumnItem[] =
|
|
@@ -48,7 +54,19 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
|
|
|
48
54
|
label: column?.name,
|
|
49
55
|
value: column?.attribute_key,
|
|
50
56
|
})) || [];
|
|
51
|
-
|
|
57
|
+
|
|
58
|
+
// If you have real tab data, use it
|
|
59
|
+
if (settingsData?.column?.tabs?.length) {
|
|
60
|
+
setColumnTabState({
|
|
61
|
+
isDefault: settingsData.column.isDefault ?? true,
|
|
62
|
+
show_list: mappedColumns,
|
|
63
|
+
hide_list: [],
|
|
64
|
+
tabs: settingsData.column.tabs, // Use the real tab data!
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Otherwise, use the default mapping
|
|
52
70
|
const mappedTabs: TabData[] =
|
|
53
71
|
quickTabStates?.show_list?.map((tab) => ({
|
|
54
72
|
tab_name: tab,
|
|
@@ -57,18 +75,12 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
|
|
|
57
75
|
})) || [];
|
|
58
76
|
|
|
59
77
|
if (!Object.entries(columnTabState)?.length) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
console.log("mappedColumnsssss", mappedColumns);
|
|
63
|
-
|
|
64
|
-
const newColumnState: ColumnTabConfigProps = {
|
|
78
|
+
setColumnTabState({
|
|
65
79
|
isDefault: true,
|
|
66
80
|
show_list: mappedColumns,
|
|
67
81
|
hide_list: [],
|
|
68
82
|
tabs: mappedTabs,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
setColumnTabState(newColumnState);
|
|
83
|
+
});
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
// console.log(
|
|
@@ -99,7 +111,7 @@ const ColumnTab = ({ filterSettingStates, columnsData }: ColumnTabProps) => {
|
|
|
99
111
|
hide_list: [],
|
|
100
112
|
}));
|
|
101
113
|
}
|
|
102
|
-
}, []); //
|
|
114
|
+
}, [settingsData, columnsData, quickTabStates]); // Added dependencies for consistency
|
|
103
115
|
|
|
104
116
|
// useEffect(() => {
|
|
105
117
|
// if (settingsData?.column) {
|
|
@@ -45,7 +45,6 @@ function Topbar<T>({
|
|
|
45
45
|
tableStates,
|
|
46
46
|
onFilterButtonClick,
|
|
47
47
|
}: TopbarProps<T>) {
|
|
48
|
-
const [isFullscreenState, setIsFullscreenState] = useState(isFullscreen);
|
|
49
48
|
const [sortAnchorEl, setSortAnchorEl] = useState<HTMLElement | null>(null);
|
|
50
49
|
const [groupBy, setGroupBy] = useState<string>("None");
|
|
51
50
|
|
|
@@ -211,11 +210,8 @@ function Topbar<T>({
|
|
|
211
210
|
onCompactToggle={(value: string) =>
|
|
212
211
|
setIsCompactTable(value === "Compact")
|
|
213
212
|
}
|
|
214
|
-
isFullscreen={
|
|
215
|
-
onFullscreenToggle={
|
|
216
|
-
fullscreenToggle();
|
|
217
|
-
setIsFullscreenState((prev) => !prev);
|
|
218
|
-
}}
|
|
213
|
+
isFullscreen={isFullscreen}
|
|
214
|
+
onFullscreenToggle={fullscreenToggle}
|
|
219
215
|
groupBy={groupBy}
|
|
220
216
|
onGroupByChange={(value: string) => setGroupBy(value)}
|
|
221
217
|
tableStates={tableStates}
|
|
@@ -258,7 +258,7 @@ export const useSettingsDropDownAPI = ({
|
|
|
258
258
|
// queryFn: () =>
|
|
259
259
|
// saveSettingsData({
|
|
260
260
|
// entity_type: "LAP",
|
|
261
|
-
// mapped_entity_type: "
|
|
261
|
+
// mapped_entity_type: "BRD",
|
|
262
262
|
// layout_json: payload,
|
|
263
263
|
// }),
|
|
264
264
|
// enabled: !!payload && !!Object.entries(payload).length,
|
|
@@ -276,7 +276,11 @@ export const useSaveSettingsDataAPI = (entity_type: string) => {
|
|
|
276
276
|
},
|
|
277
277
|
onSuccess: () => {
|
|
278
278
|
queryClient.invalidateQueries({
|
|
279
|
-
queryKey: ["
|
|
279
|
+
queryKey: ["entityTable"],
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
queryClient.invalidateQueries({
|
|
283
|
+
queryKey: ["getSettingsData", entity_type],
|
|
280
284
|
});
|
|
281
285
|
},
|
|
282
286
|
onError: (error: any) => {
|
package/src/libs/utils/common.ts
CHANGED