rez-table-listing-mui 2.0.14 → 2.0.15

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.
@@ -1,10 +1,12 @@
1
- import React, { useEffect, useState } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  import {
3
3
  Box,
4
4
  Select,
5
5
  MenuItem,
6
6
  FormControl,
7
7
  Typography,
8
+ Checkbox,
9
+ FormControlLabel,
8
10
  Grid,
9
11
  } from "@mui/material";
10
12
 
@@ -21,133 +23,299 @@ import {
21
23
  } from "@dnd-kit/core";
22
24
  import { TabsStyles } from "../style";
23
25
  import { craftTableFilterSettingsOptionsProps } from "../../../types/table-options";
24
- import { LANE_SELECTS } from "../constants";
25
26
 
26
- const GroupBy = ({
27
+ const SwimLane = ({
27
28
  filterSettingStates,
28
- columnsData,
29
- tabsApiData,
30
29
  tabsApiDataLoading,
30
+ selectSwinLandData,
31
+ swimLaneHideListData,
31
32
  }: {
32
33
  filterSettingStates: craftTableFilterSettingsOptionsProps;
33
34
  columnsData: any;
34
- tabsApiData?: any[];
35
+ tabsApiData?: { label: string; value: string }[];
35
36
  tabsApiDataLoading?: boolean;
37
+ selectSwinLandData?: { label: string; value: string }[];
38
+ swimLaneHideListData?: { label: string; value: string }[];
36
39
  }) => {
37
- const { settingsData, setSettingsData } = filterSettingStates;
40
+ const { kanbanSettingsData, setKanbanSettingsData } = filterSettingStates;
38
41
 
39
- const quickTabStates = settingsData?.quick_tab as any;
40
- const [searchTerm, setSearchTerm] = useState("");
42
+ const [searchTerm, setSearchTerm] = useState<string>("");
43
+ const [currentSwimLaneAttribute, setCurrentSwimLaneAttribute] =
44
+ useState<string>(kanbanSettingsData?.swim_lane?.attribute || "");
41
45
 
42
- const isStatus = quickTabStates?.attribute === "Status";
43
- const enableDND =
44
- quickTabStates?.attribute === "Source" &&
45
- quickTabStates?.sorting === "custom";
46
-
47
- const sensors = useSensors(
48
- useSensor(MouseSensor),
49
- useSensor(TouchSensor),
50
- useSensor(KeyboardSensor)
51
- );
46
+ const isStatusAttribute =
47
+ kanbanSettingsData?.swim_lane?.attribute === "lead_status" ||
48
+ kanbanSettingsData?.swim_lane?.attribute === "status";
49
+ const isSourceAttribute =
50
+ kanbanSettingsData?.swim_lane?.attribute === "lead_source";
52
51
 
53
52
  useEffect(() => {
54
- if (!quickTabStates || !quickTabStates.attribute) {
55
- setSettingsData((prev) => ({
53
+ if (isStatusAttribute) {
54
+ setKanbanSettingsData((prev) => ({
56
55
  ...prev,
57
- quick_tab: {
58
- attribute: "Status",
59
- sorting: "asc",
60
- show_list: [],
61
- hide_list: [],
56
+ swim_lane: {
57
+ ...prev.swim_lane,
58
+ sorting: "sort_by",
62
59
  },
63
60
  }));
64
61
  }
65
- }, []);
62
+ }, [kanbanSettingsData?.swim_lane?.attribute]);
66
63
 
67
64
  useEffect(() => {
68
- if (!tabsApiData) return;
65
+ if (!isSourceAttribute) return;
69
66
 
70
- setSettingsData((prev) => ({
67
+ setKanbanSettingsData((prev) => ({
71
68
  ...prev,
72
- quick_tab: {
73
- ...prev.quick_tab,
74
- hide_list: tabsApiData,
75
- show_list: [],
76
- sorting: quickTabStates?.attribute === "Source" ? "count_dsc" : "asc",
69
+ swim_lane: {
70
+ ...prev.swim_lane,
71
+ sorting: "count_dsc",
77
72
  },
78
73
  }));
79
- }, [quickTabStates?.attribute]);
74
+ }, [isSourceAttribute]);
75
+
76
+ useEffect(() => {
77
+ const stateToArray =
78
+ (kanbanSettingsData?.swim_lane &&
79
+ Object.entries(kanbanSettingsData?.swim_lane)) ||
80
+ [];
81
+ const isEmptyState = stateToArray.length ? false : true;
82
+
83
+ if (isEmptyState) {
84
+ setKanbanSettingsData((prev) => ({
85
+ ...prev,
86
+ swim_lane: {
87
+ ...prev?.swim_lane,
88
+ attribute: selectSwinLandData
89
+ ?.filter((i) => i?.value !== kanbanSettingsData?.lane?.attribute)
90
+ ?.find((i) => i?.value == "lead_status" || i?.value == "status")
91
+ ?.value,
92
+ // sorting: "asc",
93
+ },
94
+ }));
95
+ } else {
96
+ if (
97
+ kanbanSettingsData?.swim_lane?.attribute ==
98
+ kanbanSettingsData?.lane?.attribute
99
+ ) {
100
+ setKanbanSettingsData((prev) => ({
101
+ ...prev,
102
+ swim_lane: {
103
+ ...prev?.swim_lane,
104
+ attribute: selectSwinLandData
105
+ ?.filter((i) => i?.value !== kanbanSettingsData?.lane?.attribute)
106
+ ?.find((i) => i?.value == "lead_status" || i?.value == "status")
107
+ ?.value,
108
+ // sorting: "asc",
109
+ },
110
+ }));
111
+ }
112
+ }
113
+ }, [selectSwinLandData]);
114
+
115
+ useEffect(() => {
116
+ if (currentSwimLaneAttribute === kanbanSettingsData?.swim_lane?.attribute)
117
+ return;
118
+
119
+ if (swimLaneHideListData?.length) {
120
+ setKanbanSettingsData((prev) => ({
121
+ ...prev,
122
+ swim_lane: {
123
+ ...prev?.swim_lane,
124
+ hide_list: swimLaneHideListData,
125
+ show_list: [],
126
+ },
127
+ }));
128
+
129
+ setCurrentSwimLaneAttribute(
130
+ kanbanSettingsData?.swim_lane?.attribute || ""
131
+ );
132
+ } else {
133
+ setKanbanSettingsData((prev) => ({
134
+ ...prev,
135
+ swim_lane: {
136
+ ...prev?.swim_lane,
137
+ hide_list: [],
138
+ show_list: [],
139
+ },
140
+ }));
141
+
142
+ setCurrentSwimLaneAttribute("");
143
+ }
144
+ }, [swimLaneHideListData]);
145
+
146
+ const sortingOptions = [
147
+ { label: "Sort By", value: "sort_by" },
148
+ { label: "A-Z", value: "asc" },
149
+ { label: "Z-A", value: "dsc" },
150
+ { label: "Count (Ascending)", value: "count_asc" },
151
+ { label: "Count (Descending)", value: "count_dsc" },
152
+ { label: "Custom", value: "custom" },
153
+ ];
154
+
155
+ const normalizeTabItem = (item: any) => ({
156
+ label: item.label,
157
+ value: item?.value,
158
+ });
159
+
160
+ const constructHideList = () => {
161
+ const normalizedTabs = swimLaneHideListData?.map(normalizeTabItem) || [];
162
+
163
+ // remove items already in show_list (value-safe comparison)
164
+ return normalizedTabs?.filter(
165
+ (tab) => !showListValues?.some((i) => i?.value === tab?.value)
166
+ );
167
+ };
168
+
169
+ const showListValues = kanbanSettingsData?.swim_lane?.show_list || [];
170
+ const hideListValues = constructHideList() || [];
171
+
172
+ const filteredListValues = hideListValues.filter((value: any) =>
173
+ value?.label?.toLowerCase().includes(searchTerm.toLowerCase())
174
+ );
175
+
176
+ const sensors = useSensors(
177
+ useSensor(MouseSensor),
178
+ useSensor(TouchSensor),
179
+ useSensor(KeyboardSensor)
180
+ );
80
181
 
81
- /* Drag logic unchanged */
82
182
  const handleDragEnd = (event: DragEndEvent) => {
83
183
  const { active, over } = event;
84
184
  if (!over) return;
85
185
 
86
- const from = active.data.current?.containerId;
87
- const to = over.data.current?.containerId;
88
- if (!from || !to) return;
186
+ const currentContainer = active.data.current?.containerId;
187
+ const overContainer = over.data.current?.containerId;
89
188
 
90
- const showList = [...(quickTabStates.show_list ?? [])];
91
- const hideList = [...(quickTabStates.hide_list ?? [])];
189
+ if (!currentContainer || !overContainer) return;
92
190
 
93
- if (from === to) {
94
- const list = from === "lanes" ? showList : hideList;
95
- const oldIndex = list.indexOf(String(active.id));
96
- const newIndex = list.indexOf(String(over.id));
97
- if (oldIndex !== -1 && newIndex !== -1) {
98
- const [moved] = list.splice(oldIndex, 1);
99
- list.splice(newIndex, 0, moved);
100
- }
101
- } else {
102
- if (from === "list" && to === "lanes") {
103
- hideList.splice(hideList.indexOf(String(active.id)), 1);
104
- showList.push(String(active.id));
191
+ let newShowList = [...(kanbanSettingsData?.swim_lane?.show_list ?? [])];
192
+ let newHideList = [...(kanbanSettingsData?.swim_lane?.hide_list ?? [])];
193
+
194
+ if (currentContainer === overContainer) {
195
+ if (currentContainer === "list") {
196
+ const oldIndex = newHideList.findIndex((i) => i.value === active.id);
197
+ const newIndex = newHideList.findIndex((i) => i.value === over.id);
198
+
199
+ if (oldIndex !== -1 && newIndex !== -1) {
200
+ const [removed] = newHideList.splice(oldIndex, 1);
201
+ newHideList.splice(newIndex, 0, removed);
202
+ }
203
+ } else {
204
+ const oldIndex = newShowList.findIndex((i) => i.value === active.id);
205
+ const newIndex = newShowList.findIndex((i) => i.value === over.id);
206
+
207
+ if (oldIndex !== -1 && newIndex !== -1) {
208
+ const [removed] = newShowList.splice(oldIndex, 1);
209
+ newShowList.splice(newIndex, 0, removed);
210
+ }
105
211
  }
106
- if (from === "lanes" && to === "list") {
107
- showList.splice(showList.indexOf(String(active.id)), 1);
108
- hideList.push(String(active.id));
212
+ }
213
+
214
+ // -------------------------------------
215
+ // CASE 2: MOVE BETWEEN LISTS
216
+ // -------------------------------------
217
+ if (currentContainer !== overContainer) {
218
+ if (currentContainer === "list" && overContainer === "tabs") {
219
+ // if (newShowList.length < 5) {
220
+ const idx = newHideList.findIndex((i) => i.value === String(active.id));
221
+ if (idx !== -1) {
222
+ const item = newHideList.splice(idx, 1)[0];
223
+ newShowList.push(item);
224
+ }
225
+ // }
226
+ } else if (currentContainer === "tabs" && overContainer === "list") {
227
+ const idx = newShowList.findIndex((i) => i.value === String(active.id));
228
+ if (idx !== -1) {
229
+ const item = newShowList.splice(idx, 1)[0];
230
+ newHideList.push(item);
231
+ }
109
232
  }
110
233
  }
111
234
 
112
- setSettingsData((prev) => ({
235
+ // ----------------------------------------------------------
236
+ // ⭐ APPLY MASTER UPDATE (with isDefault CHECK for columns)
237
+ // ----------------------------------------------------------
238
+ setKanbanSettingsData((prev) => {
239
+ // FINAL RETURN
240
+ return {
241
+ ...prev,
242
+ swim_lane: {
243
+ ...prev.swim_lane,
244
+ show_list: newShowList,
245
+ hide_list: newHideList,
246
+ },
247
+ };
248
+ });
249
+ };
250
+
251
+ const handleShowAll = () => {
252
+ setKanbanSettingsData((prev) => ({
113
253
  ...prev,
114
- quick_tab: {
115
- ...prev.quick_tab,
116
- show_list: showList,
117
- hide_list: hideList,
254
+ swim_lane: {
255
+ ...prev?.swim_lane,
256
+ show_list: [
257
+ ...(prev?.swim_lane?.show_list || []),
258
+ ...(prev?.swim_lane?.hide_list || []),
259
+ ],
260
+ hide_list: [],
118
261
  },
119
262
  }));
120
263
  };
121
264
 
122
- const handleItemToggle = (itemId: string, fromContainerId: string) => {
123
- const showList = [...(quickTabStates.show_list ?? [])];
124
- const hideList = [...(quickTabStates.hide_list ?? [])];
125
-
126
- if (fromContainerId === "list") {
127
- hideList.splice(hideList.indexOf(itemId), 1);
128
- showList.push(itemId);
129
- } else {
130
- showList.splice(showList.indexOf(itemId), 1);
131
- hideList.push(itemId);
132
- }
133
-
134
- setSettingsData((prev) => ({
265
+ const handleHideAll = () => {
266
+ setKanbanSettingsData((prev) => ({
135
267
  ...prev,
136
- quick_tab: {
137
- ...prev.quick_tab,
138
- show_list: showList,
139
- hide_list: hideList,
268
+ swim_lane: {
269
+ ...prev?.swim_lane,
270
+ hide_list: [
271
+ ...(prev?.swim_lane?.hide_list || []),
272
+ ...(prev?.swim_lane?.show_list || []),
273
+ ],
274
+ show_list: [],
140
275
  },
141
276
  }));
142
277
  };
143
278
 
144
- const sortingOptions = [
145
- { label: "A-Z", value: "asc" },
146
- { label: "Z-A", value: "dsc" },
147
- { label: "Count (Ascending)", value: "count_asc" },
148
- { label: "Count (Descending)", value: "count_dsc" },
149
- { label: "Custom", value: "custom" },
150
- ];
279
+ const handleItemToggle = (
280
+ item: { label: string; value: string },
281
+ fromContainerId: string
282
+ ) => {
283
+ setKanbanSettingsData((prev) => {
284
+ const toShowList = [...(kanbanSettingsData?.swim_lane?.show_list ?? [])];
285
+ const toHideList = [...(kanbanSettingsData?.swim_lane?.hide_list ?? [])];
286
+
287
+ if (fromContainerId === "list") {
288
+ const index = toHideList.findIndex((i) => i.value == item.value);
289
+ if (index > -1) {
290
+ toHideList.splice(index, 1);
291
+ toShowList.push(item);
292
+ // 🌟 ALSO create sorting tab entry if missing
293
+ }
294
+ } else if (fromContainerId === "tabs") {
295
+ const index = toShowList.findIndex((i) => i.value == item.value);
296
+ if (index > -1) {
297
+ toShowList.splice(index, 1);
298
+ toHideList.push(item);
299
+ // let itemIndex =
300
+ // filterSettingStates?.quickTabStates?.show_list?.findIndex(
301
+ // (i) => i.value == item.value
302
+ // );
303
+ // 🔥 REMOVE COLUMN WHEN TAB REMOVED (if not default)
304
+ }
305
+ }
306
+ return {
307
+ ...prev,
308
+ swim_lane: {
309
+ ...prev?.swim_lane,
310
+ show_list: toShowList,
311
+ hide_list: toHideList,
312
+ },
313
+ };
314
+ });
315
+ };
316
+
317
+ const enableDND =
318
+ isSourceAttribute && kanbanSettingsData?.swim_lane?.sorting === "custom";
151
319
 
152
320
  return (
153
321
  <Box sx={{ display: "flex", flexDirection: "column", height: "100%" }}>
@@ -156,54 +324,68 @@ const GroupBy = ({
156
324
  </Typography>
157
325
 
158
326
  <Grid sx={{ position: "relative" }} container>
327
+ {/* Attribute + Sort */}
159
328
  <Grid size={12}>
160
329
  <Grid sx={TabsStyles.mainTabDropdown} size={6}>
161
330
  <FormControl sx={TabsStyles.mainTabSelect} size="small">
162
331
  <Select
163
- value={quickTabStates?.attribute || ""}
332
+ value={kanbanSettingsData?.swim_lane?.attribute || ""}
164
333
  onChange={(e) =>
165
- setSettingsData((prev) => ({
334
+ setKanbanSettingsData((prev) => ({
166
335
  ...prev,
167
- quick_tab: {
168
- ...prev.quick_tab,
336
+ swim_lane: {
337
+ ...prev?.swim_lane,
169
338
  attribute: e.target.value,
170
339
  },
171
340
  }))
172
341
  }
173
342
  >
174
- {LANE_SELECTS?.map((lane: any) => (
175
- <MenuItem key={lane?.key} value={lane?.value}>
176
- {lane?.value}
177
- </MenuItem>
178
- ))}
343
+ {selectSwinLandData
344
+ ?.filter(
345
+ (i) => i?.value !== kanbanSettingsData?.lane?.attribute
346
+ )
347
+ ?.map((lane: any) => (
348
+ <MenuItem key={lane?.key} value={lane?.value}>
349
+ {lane?.label}
350
+ </MenuItem>
351
+ ))}
179
352
  </Select>
180
353
  </FormControl>
181
354
 
182
355
  <FormControl sx={TabsStyles.selectDropdownSeparator} size="small">
183
356
  <Select
184
- disabled={isStatus}
185
- value={quickTabStates?.sorting}
357
+ value={kanbanSettingsData?.swim_lane?.sorting || "asc"}
358
+ disabled={isStatusAttribute}
186
359
  onChange={(e) =>
187
- setSettingsData((prev) => ({
360
+ setKanbanSettingsData((prev) => ({
188
361
  ...prev,
189
- quick_tab: {
190
- ...prev.quick_tab,
362
+ swim_lane: {
363
+ ...prev?.swim_lane,
191
364
  sorting: e.target.value,
192
365
  },
193
366
  }))
194
367
  }
195
368
  >
196
- {!isStatus &&
197
- sortingOptions.map((opt) => (
198
- <MenuItem key={opt.value} value={opt.value}>
199
- {opt.label}
200
- </MenuItem>
201
- ))}
369
+ {isStatusAttribute && (
370
+ <MenuItem value="sort_by" disabled>
371
+ Sort By
372
+ </MenuItem>
373
+ )}
374
+
375
+ {!isStatusAttribute &&
376
+ sortingOptions
377
+ .filter((option) => option.value !== "sort_by")
378
+ .map((option) => (
379
+ <MenuItem key={option.value} value={option.value}>
380
+ {option.label}
381
+ </MenuItem>
382
+ ))}
202
383
  </Select>
203
384
  </FormControl>
204
385
  </Grid>
205
386
  </Grid>
206
387
 
388
+ {/* Lists */}
207
389
  <DndContext
208
390
  sensors={sensors}
209
391
  collisionDetection={closestCenter}
@@ -212,8 +394,9 @@ const GroupBy = ({
212
394
  <Grid sx={{ mt: 2 }} container spacing={2} size={12}>
213
395
  <ListingValues
214
396
  buttonText="Show All"
397
+ onClick={handleShowAll}
215
398
  headerText="List of Values"
216
- filteredValues={quickTabStates?.hide_list || []}
399
+ filteredValues={filteredListValues}
217
400
  searchTerm={searchTerm}
218
401
  setSearchTerm={setSearchTerm}
219
402
  containerId="list"
@@ -224,9 +407,10 @@ const GroupBy = ({
224
407
 
225
408
  <ListingValues
226
409
  buttonText="Hide All"
410
+ onClick={handleHideAll}
227
411
  headerText="View as Lanes"
228
- filteredValues={quickTabStates?.show_list || []}
229
- containerId="lanes"
412
+ filteredValues={showListValues}
413
+ containerId="tabs"
230
414
  onItemToggle={handleItemToggle}
231
415
  enableDragAndDrop={enableDND}
232
416
  />
@@ -237,4 +421,4 @@ const GroupBy = ({
237
421
  );
238
422
  };
239
423
 
240
- export default GroupBy;
424
+ export default SwimLane;
@@ -43,6 +43,9 @@ export function QuickFilterSettings({
43
43
  activeTab,
44
44
  selectAttributeData,
45
45
  selectSwinLandData,
46
+ laneHideListData,
47
+ swimLaneHideListData,
48
+ onSaveKanbanSettingsData,
46
49
  }: QuickFilterModalProps) {
47
50
  const [tabValue, setTabValue] = useState(0);
48
51
  const { container: fullscreenContainer } = useFullscreenPopoverContainer();
@@ -53,6 +56,7 @@ export function QuickFilterSettings({
53
56
  columnTabState,
54
57
  sortingTabState,
55
58
  saveButtonError,
59
+ kanbanSettingsData,
56
60
  } = filterSettingStates;
57
61
 
58
62
  const hasAPIData = Boolean(Object.entries(columnsData).length);
@@ -100,6 +104,16 @@ export function QuickFilterSettings({
100
104
  onClose && onClose();
101
105
  };
102
106
 
107
+ const handleSaveKanbanSetSettingsData = () => {
108
+ const modifiedKanbanSettingsData = {
109
+ lane: kanbanSettingsData?.lane,
110
+ swim_lane: kanbanSettingsData?.swim_lane,
111
+ };
112
+ onSaveKanbanSettingsData &&
113
+ onSaveKanbanSettingsData(modifiedKanbanSettingsData);
114
+ onClose && onClose();
115
+ };
116
+
103
117
  return (
104
118
  <CustomDialog
105
119
  open={show || showListViewSettings}
@@ -190,6 +204,7 @@ export function QuickFilterSettings({
190
204
  filterSettingStates={filterSettingStates}
191
205
  columnsData={columnsData}
192
206
  selectAttributeData={selectAttributeData}
207
+ laneHideListData={laneHideListData}
193
208
  />
194
209
  )}
195
210
  </CustomTabPanel>
@@ -202,6 +217,7 @@ export function QuickFilterSettings({
202
217
  filterSettingStates={filterSettingStates}
203
218
  columnsData={columnsData}
204
219
  selectSwinLandData={selectSwinLandData}
220
+ swimLaneHideListData={swimLaneHideListData}
205
221
  />
206
222
  )}
207
223
  </CustomTabPanel>
@@ -235,7 +251,7 @@ export function QuickFilterSettings({
235
251
  )}
236
252
 
237
253
  {view === "kanban" && tabValue === 1 && (
238
- <CustomButton onClick={handleSaveSetSettingsData}>
254
+ <CustomButton onClick={handleSaveKanbanSetSettingsData}>
239
255
  Save
240
256
  </CustomButton>
241
257
  )}
@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
2
2
  import { craftTableFilterSettingsOptionsProps } from "../../types/table-options";
3
3
  import {
4
4
  ColumnTabConfigProps,
5
+ KanbanSettingsDataProps,
5
6
  QuickTabConfigProps,
6
7
  SavedButtonErrorProps,
7
8
  SettingsDataProps,
@@ -14,6 +15,8 @@ export function useCraftTableFilterSettings() {
14
15
  useState<boolean>(false);
15
16
 
16
17
  const [settingsData, setSettingsData] = useState<SettingsDataProps>({});
18
+ const [kanbanSettingsData, setKanbanSettingsData] =
19
+ useState<KanbanSettingsDataProps>({});
17
20
 
18
21
  // Quick FIlter settings local states
19
22
 
@@ -46,6 +49,8 @@ export function useCraftTableFilterSettings() {
46
49
  {
47
50
  settingsData: settingsData,
48
51
  setSettingsData: setSettingsData,
52
+ kanbanSettingsData: kanbanSettingsData,
53
+ setKanbanSettingsData: setKanbanSettingsData,
49
54
  showListViewSettings: showListViewSettings,
50
55
  setShowListViewSettings: setShowListViewSettings,
51
56
  quickTabStates: quickTabStates,
@@ -347,14 +347,22 @@ export const useSaveSettingsDataAPI = (entity_type: string) => {
347
347
  return { saveSettingsDataMutation };
348
348
  };
349
349
 
350
- export const useGetSettingsDataAPI = (entity_type: string) => {
351
- const { data: getSettingsAPIData } = useQuery({
350
+ export const useGetSettingsDataAPI = (entity_type: string, type: string) => {
351
+ const {
352
+ data: getSettingsAPIData,
353
+ isSuccess: getSettingsAPIDataSuccess,
354
+ isPending: getSettingsAPIDataPending,
355
+ } = useQuery({
352
356
  queryKey: ["getSettingsData", entity_type],
353
- queryFn: () => getSettingsData(entity_type),
357
+ queryFn: () => getSettingsData(entity_type, type),
354
358
  enabled: !!entity_type,
355
359
  });
356
360
 
357
- return { getSettingsAPIData };
361
+ return {
362
+ getSettingsAPIData,
363
+ getSettingsAPIDataSuccess,
364
+ getSettingsAPIDataPending,
365
+ };
358
366
  };
359
367
 
360
368
  export const useGetFilterEntityListAndCriteria = ({
@@ -142,11 +142,20 @@ export const saveSettingsData = async (payload: any) => {
142
142
  }
143
143
  };
144
144
 
145
- export const getSettingsData = async (entity_type: any) => {
145
+ export const getSettingsData = async (entity_type: string, type: string) => {
146
+ let url = `/meta/layout-preference`;
147
+
148
+ // if (entity_type === USER || entity_type === ROLE || entity_type === ORGP) {
149
+ // url = `sso/layout`;
150
+ // }
151
+
152
+ const params = {
153
+ entity_type: entity_type,
154
+ type: type,
155
+ };
156
+
146
157
  try {
147
- const response = await api.get(
148
- `meta/layout-preference?entity_type=${entity_type}`
149
- );
158
+ const response = await api.get(url, { params });
150
159
  return response.data;
151
160
  } catch (error) {
152
161
  console.error("Failed to fetch settings data:", error);