rez-table-listing-mui 1.3.61 → 1.3.64

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez-table-listing-mui",
3
- "version": "1.3.61",
3
+ "version": "1.3.64",
4
4
  "type": "module",
5
5
  "description": "A rez table listing component built on TanStack Table",
6
6
  "main": "dist/index.js",
@@ -42,7 +42,7 @@ const FilterCriteriaEntityList = ({
42
42
 
43
43
  // Case 2: default behavior (apply search filter)
44
44
  return allEntities.filter((entity) =>
45
- entity.label.toLowerCase().includes(searchTerm.toLowerCase())
45
+ entity.label?.toLowerCase().includes(searchTerm?.toLowerCase())
46
46
  );
47
47
  }, [isSingleEntity, filters, allEntities, searchTerm]);
48
48
 
@@ -190,11 +190,24 @@ const ColumnTab = ({
190
190
  }
191
191
  };
192
192
 
193
+ const constructHideList = (): ColumnItem[] => {
194
+ return (
195
+ columnTabAttributes
196
+ ?.map((column) => ({
197
+ label: column?.name,
198
+ value: column?.attribute_key,
199
+ }))
200
+ ?.filter(
201
+ (tab) =>
202
+ !settingsColumnState?.show_list?.find((i) => i.value === tab.value)
203
+ ) || []
204
+ );
205
+ };
193
206
  const getCurrentLists = () => {
194
207
  if (settingsColumnState?.isDefault) {
195
208
  return {
196
209
  showList: settingsColumnState.show_list || [],
197
- hideList: settingsColumnState.hide_list || [],
210
+ hideList: constructHideList() || [],
198
211
  };
199
212
  } else {
200
213
  const currentTab = settingsColumnState?.tabs?.[selectedTabIndex];
@@ -106,6 +106,8 @@ const QuickTab = ({
106
106
  show_list: [],
107
107
  },
108
108
  }));
109
+
110
+ setCurrentQuickAttribute("");
109
111
  }
110
112
  }, [tabsApiData]);
111
113
 
@@ -174,8 +176,14 @@ const QuickTab = ({
174
176
  ];
175
177
 
176
178
  // Convert show_list/hide_list to FilterValue[] for rendering only
179
+
180
+ const constructHideList = () => {
181
+ return tabsApiData?.filter(
182
+ (tab) => !showListValues?.find((i) => i.value === tab.value)
183
+ );
184
+ };
177
185
  const showListValues = quickTabStates?.show_list || [];
178
- const hideListValues = quickTabStates?.hide_list || [];
186
+ const hideListValues = constructHideList() || [];
179
187
 
180
188
  const sensors = useSensors(
181
189
  useSensor(MouseSensor),
@@ -15,7 +15,7 @@ interface TabDataProps {
15
15
  interface TableTabsProps {
16
16
  loading?: boolean;
17
17
  tabsData?: TabDataProps[];
18
- activeTab?: string;
18
+ activeTab?: any;
19
19
  tableStates: CraftTableOptionsProps;
20
20
  onClick: (state: string) => void;
21
21
  columns?: any[];
@@ -72,22 +72,24 @@ export function TableTabs({
72
72
  {/* Tabs */}
73
73
  <Tabs
74
74
  value={selectedTab}
75
- onChange={(_, newValue) => handleTabClick(newValue)}
75
+ onChange={(_, newValue) => {
76
+ handleTabClick(newValue);
77
+ }}
76
78
  variant="scrollable"
77
79
  scrollButtons="auto"
78
80
  slotProps={{ indicator: { sx: { display: "none" } } }}
79
81
  sx={tableTabsStyles.tabs}
80
82
  >
81
- {normalizedTabs.map(({ tab_name, count }) => {
82
- const isSelected = activeTab === tab_name;
83
+ {normalizedTabs.map((tab) => {
84
+ const isSelected = activeTab?.tab_name === tab?.tab_name;
83
85
 
84
86
  return (
85
87
  <Tab
86
- key={tab_name}
87
- value={tab_name}
88
+ key={tab?.tab_name}
89
+ value={tab}
88
90
  label={
89
91
  <Box display="flex" alignItems="center" gap={1}>
90
- <Box>{tab_name}</Box>
92
+ <Box>{tab?.tab_name}</Box>
91
93
  <Box
92
94
  sx={{
93
95
  ...tableTabsStyles.tabCount,
@@ -100,7 +102,9 @@ export function TableTabs({
100
102
  }),
101
103
  }}
102
104
  >
103
- {count == 0 ? "0" : String(count).padStart(2, "0")}
105
+ {tab?.count == 0
106
+ ? "0"
107
+ : String(tab?.count).padStart(2, "0")}
104
108
  </Box>
105
109
  </Box>
106
110
  }
@@ -24,6 +24,8 @@ import {
24
24
  getOperationList,
25
25
  getLayoutAttributes,
26
26
  getAttributes,
27
+ getTableTabs,
28
+ newCommonGetDropdownDataAPI,
27
29
  } from "../utils/apiColumn";
28
30
  import {
29
31
  FilterDataMainFilterEntityListProps,
@@ -268,7 +270,11 @@ export const useCommonFilterDropdownAPI = (
268
270
  queries: dropdownConfigs.map((cfg) => {
269
271
  return {
270
272
  queryKey: ["commonDropdown", cfg?.dataSourceType],
271
- queryFn: () => commonGetDropdownDataAPI(cfg?.dataSourceType, null),
273
+ queryFn: () =>
274
+ newCommonGetDropdownDataAPI({
275
+ entity_type: "ROL",
276
+ attribute_key: cfg?.key,
277
+ }),
272
278
  enabled: !!cfg?.dataSourceType,
273
279
  };
274
280
  }),
@@ -363,10 +369,14 @@ export const useGetFilterEntityListAndCriteria = ({
363
369
  return { filterEntityList, filterEntityWiseCriteria };
364
370
  };
365
371
 
366
- export const useGetAttributes = (entity_type: string) => {
372
+ export const useGetAttributes = (
373
+ entity_type: string,
374
+ element_type?: string
375
+ ) => {
367
376
  const attributes = useQuery({
368
- queryKey: ["attributes", entity_type],
369
- queryFn: () => getAttributes(entity_type),
377
+ queryKey: ["attributes", entity_type, element_type],
378
+ queryFn: () => getAttributes(entity_type, element_type),
379
+ enabled: !!entity_type, // optional safety
370
380
  });
371
381
 
372
382
  return { attributes };
@@ -401,6 +411,54 @@ export const useGetLayoutAttributes = ({
401
411
  return { layoutAttributes };
402
412
  };
403
413
 
414
+ export const useGetTableTabs = (payload: any) => {
415
+ const { data: tableTabs, isLoading } = useQuery({
416
+ queryKey: ["tableTabs", payload],
417
+ queryFn: () => getTableTabs(payload),
418
+ });
419
+ return { tableTabs, isLoading };
420
+ };
421
+
422
+ export const useDropdownAPI = ({
423
+ entity_type,
424
+ attribute_key,
425
+ inactiveIds,
426
+ parentId,
427
+ data,
428
+ enabled = true,
429
+ }: {
430
+ entity_type: string;
431
+ attribute_key?: string;
432
+ inactiveIds?: string | null;
433
+ parentId?: number | string;
434
+ data?: any;
435
+ enabled?: boolean;
436
+ }) => {
437
+ const query = useQuery({
438
+ queryKey: [
439
+ "commonDropdown",
440
+ entity_type,
441
+ attribute_key,
442
+ inactiveIds,
443
+ parentId,
444
+ ],
445
+ queryFn: () =>
446
+ newCommonGetDropdownDataAPI({
447
+ entity_type,
448
+ attribute_key,
449
+ inactiveIds,
450
+ parentId,
451
+ data,
452
+ }),
453
+ enabled, // prevents auto call unless needed
454
+ staleTime: 5 * 60 * 1000, // cache for 5 mins
455
+ });
456
+
457
+ return {
458
+ ...query,
459
+ dropdownData: query.data || [],
460
+ };
461
+ };
404
462
  // export const useGetSettingsColumnAttributes = (entity_type: string) => {
405
463
  // // First query to get meta data
406
464
  // const settingsColumnAttributes = useQuery({
@@ -14,11 +14,11 @@ export const useDetailsQueryAPI = (value: string | undefined) => {
14
14
  return { detailsQuery };
15
15
  };
16
16
 
17
- export const useFetchData = (entity_type: string) => {
17
+ export const useFetchData = (entity_type: string, payload?: any) => {
18
18
  // First query to get meta data
19
19
  const metaQuery = useQuery({
20
- queryKey: ["meta", entity_type],
21
- queryFn: () => entityTableFilterMaster(entity_type),
20
+ queryKey: ["meta", entity_type, payload],
21
+ queryFn: () => entityTableFilterMaster(entity_type, payload),
22
22
  });
23
23
 
24
24
  return { metaQuery };
@@ -7,7 +7,7 @@ export const getLeadNavigationTabs = async (entity_type: string) => {
7
7
  type: "layout",
8
8
  };
9
9
 
10
- const response = await api.get("/layout-preference", { params });
10
+ const response = await api.get("meta/layout-preference", { params });
11
11
 
12
12
  return response.data.mapped_json;
13
13
  } catch (error) {
@@ -27,10 +27,14 @@ export const entityTableMetaMaster = async (entity_type: string) => {
27
27
  }
28
28
  };
29
29
 
30
- export const entityTableFilterMaster = async (entity_type: string) => {
30
+ export const entityTableFilterMaster = async (
31
+ entity_type: string,
32
+ payload?: any
33
+ ) => {
31
34
  try {
32
35
  const response = await api.post(
33
- `/meta/get-table-data?entity_type=${entity_type}&list_type=${entity_type}`
36
+ `/meta/get-table-data?entity_type=${entity_type}&list_type=${entity_type}`,
37
+ payload
34
38
  );
35
39
 
36
40
  // const filteredData = {
@@ -141,7 +145,7 @@ export const saveSettingsData = async (payload: any) => {
141
145
  export const getSettingsData = async (entity_type: any) => {
142
146
  try {
143
147
  const response = await api.get(
144
- `layout-preference?entity_type=${entity_type}`
148
+ `meta/layout-preference?entity_type=${entity_type}`
145
149
  );
146
150
  return response.data;
147
151
  } catch (error) {
@@ -156,7 +160,7 @@ export const viewSettingsDropDown = async ({
156
160
  sort_by,
157
161
  }: viewSettingsDropDownAPIProps): Promise<Array<string>> => {
158
162
  const response = await api.get(
159
- `/layout-preference/column?entity_type=${entity_type}&column=${column}&sort_by=${sort_by}`
163
+ `meta/layout-preference/column?entity_type=${entity_type}&column=${column}&sort_by=${sort_by}`
160
164
  );
161
165
 
162
166
  return response.data;
@@ -164,7 +168,7 @@ export const viewSettingsDropDown = async ({
164
168
 
165
169
  export const getFilterEntityList = async (entity_type: string) => {
166
170
  const response = await api.get(
167
- `/entity-relation/${entity_type}?include=true`
171
+ `meta/entity-relation/${entity_type}?include=true`
168
172
  );
169
173
 
170
174
  return response.data;
@@ -176,7 +180,7 @@ export const getFilterCriteriaByEntity = async (
176
180
  const params = { entity_type: selectedFilterEntity?.value };
177
181
 
178
182
  const response = await api.get(
179
- `/attribute-master/getAttributes?direct=false&entity_type=${selectedFilterEntity?.value}`
183
+ `meta/attribute-master/getAttributes?direct=false&entity_type=${selectedFilterEntity?.value}`
180
184
  );
181
185
 
182
186
  return response.data;
@@ -198,18 +202,64 @@ export const getLayoutAttributes = async ({
198
202
  element_type,
199
203
  };
200
204
  const response = await api.post(
201
- `/layout-preference/attributes`,
205
+ `meta/layout-preference/attributes`,
202
206
  { entity_type },
203
207
  { params }
204
208
  );
205
209
  return response.data;
206
210
  };
207
211
 
208
- export const getAttributes = async (entity_type: string) => {
209
- const response = await api.get(
210
- `/attribute-master/getAttributes?direct=false&entity_type=${entity_type}`
211
- );
212
- console.log("resss", response);
212
+ export const getAttributes = async (
213
+ entity_type: string,
214
+ element_type?: string
215
+ ) => {
216
+ const response = await api.get("/meta/attribute-master/getAttributes", {
217
+ params: {
218
+ // direct: false, // commented as per requirement
219
+ entity_type,
220
+ ...(element_type && { element_type }),
221
+ },
222
+ });
223
+
224
+ return response.data;
225
+ };
213
226
 
227
+ export const getTableTabs = async (payload: any) => {
228
+ const response = await api.post(`filter/adm/tabs`, payload);
214
229
  return response.data;
215
230
  };
231
+
232
+ export const newCommonGetDropdownDataAPI = async ({
233
+ entity_type,
234
+ attribute_key,
235
+ // organization_id,
236
+ data,
237
+ inactiveIds,
238
+ parentId,
239
+ }: {
240
+ entity_type: string | undefined;
241
+ attribute_key?: string;
242
+ // organization_id?: string | null;
243
+ data?: any;
244
+ inactiveIds?: string | null;
245
+ parentId?: number | string;
246
+ }) => {
247
+ // Body can still accept optional custom data if needed
248
+ const requestBody = data || {};
249
+
250
+ // Build query params dynamically
251
+ const queryParams: string[] = [];
252
+
253
+ if (entity_type) queryParams.push(`entity_type=${entity_type}`);
254
+ if (attribute_key) queryParams.push(`attribute_key=${attribute_key}`);
255
+ if (!Number.isNaN(Number(inactiveIds)) && inactiveIds)
256
+ queryParams.push(`inactiveIds=${inactiveIds}`);
257
+ if (parentId !== undefined && parentId !== null)
258
+ queryParams.push(`parent=${parentId}`);
259
+
260
+ const queryString = queryParams.length > 0 ? `?${queryParams.join("&")}` : "";
261
+
262
+ return await api
263
+ .post(`entity/getAttributeDropdown${queryString}`, requestBody)
264
+ .then((response) => response.data);
265
+ };
@@ -78,7 +78,7 @@ export function customDebounce<T extends (...args: any[]) => any>(
78
78
 
79
79
  //ENTITY TYPE
80
80
  const ENVIRONMENT = "adm_dev";
81
- export const ENTITY_TYPE = "SCH";
81
+ export const ENTITY_TYPE = "ROL";
82
82
  export const MAPPED_ENTITY_TYPE = "LYPR"; // LAP OR LYPR
83
83
  export const USER_ID = 226;
84
84
 
@@ -111,3 +111,47 @@ api.interceptors.request.use(
111
111
  return Promise.reject(error);
112
112
  }
113
113
  );
114
+
115
+ export const formatTableHeaders = (columns: any) => {
116
+ const mapped = columns.map((col: any) => {
117
+ const meta =
118
+ col.attribute_key === "status" ||
119
+ col.attribute_key === "lead_status" ||
120
+ col.attribute_key === "flag" ||
121
+ col.attribute_key === "invitation_status"
122
+ ? { type: "custom", propName: "renderStatus", align: col.align }
123
+ : col.attribute_key === "profile_image" ||
124
+ col.attribute_key === "short_logo"
125
+ ? {
126
+ type: "custom",
127
+ propName: "profileImageFetch",
128
+ align: col.align,
129
+ }
130
+ : col.attribute_key === "start_date" || col.attribute_key === "end_date"
131
+ ? { type: "custom", propName: "dateFormater", align: col.align }
132
+ : col.attribute_key === "action"
133
+ ? { type: "custom", propName: "renderAction", align: col.align }
134
+ : col.attribute_key === "code"
135
+ ? {
136
+ type: "custom",
137
+ propName: "drillCellRenderer",
138
+ align: col.align,
139
+ }
140
+ : col.attribute_key === "primary_mobile"
141
+ ? {
142
+ type: "custom",
143
+ propName: "apiCallonClick",
144
+ align: col.align,
145
+ }
146
+ : undefined;
147
+
148
+ return {
149
+ header: col.name ?? "",
150
+ accessorKey: col.attribute_key ?? "",
151
+ size: col.size,
152
+ meta,
153
+ };
154
+ });
155
+
156
+ return mapped;
157
+ };
@@ -48,6 +48,7 @@ export interface EntityTableAPIProps {
48
48
  columnName: string;
49
49
  sortBy: "ASC" | "DSC";
50
50
  value?: string;
51
+ name?: string;
51
52
  };
52
53
  sortby?: {
53
54
  sortColum: string;
@@ -95,7 +95,7 @@ export interface CraftTableProps<T> {
95
95
  filterOptions?: FilterOptionsProps;
96
96
  settingsOptions?: settingsOptionsProps;
97
97
  craftTableFilterSettingsOptions?: craftTableFilterSettingsOptionsProps;
98
- activeTab?: string;
98
+ activeTab?: any;
99
99
  }
100
100
  export interface CraftTableComponentProps<T> {
101
101
  table: Table<T>;