rez-table-listing-mui 2.0.13 → 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,4 +1,4 @@
1
- import { api, MAPPED_ENTITY_TYPE } from "./common";
1
+ import { api, APP_CODE, MAPPED_ENTITY_TYPE } from "./common";
2
2
  import {
3
3
  createSavedFilterPayload,
4
4
  deleteSavedFilterPayload,
@@ -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);
@@ -225,7 +234,7 @@ export const getAttributes = async (
225
234
  };
226
235
 
227
236
  export const getTableTabs = async (payload: any) => {
228
- const response = await api.post(`filter/adm/tabs`, payload);
237
+ const response = await api.post(`filter/${APP_CODE}/tabs`, payload);
229
238
  return response.data;
230
239
  };
231
240
 
@@ -263,3 +272,49 @@ export const newCommonGetDropdownDataAPI = async ({
263
272
  .post(`entity/getAttributeDropdown${queryString}`, requestBody)
264
273
  .then((response) => response.data);
265
274
  };
275
+
276
+ export const commonFetchDropdownDataAPI = async ({
277
+ entity_type,
278
+ enterprise_id,
279
+ data,
280
+ inactiveIds,
281
+ parentId,
282
+ }: {
283
+ entity_type: string | undefined;
284
+ enterprise_id?: string | null;
285
+ data?: any;
286
+ inactiveIds?: string | null;
287
+ parentId?: number | string;
288
+ }) => {
289
+ const requestBody = {
290
+ // status: "ACTIVE",
291
+ enterprise_id,
292
+ ...data,
293
+ };
294
+
295
+ let params = "";
296
+
297
+ const queryParams: string[] = [];
298
+
299
+ if (!Number.isNaN(Number(inactiveIds)) && inactiveIds) {
300
+ queryParams.push(`inactiveIds=${inactiveIds}`);
301
+ }
302
+
303
+ if (parentId !== undefined && parentId !== null) {
304
+ queryParams.push(`parent=${parentId}`);
305
+ }
306
+
307
+ if (queryParams.length > 0) {
308
+ params = `?${queryParams.join("&")}`;
309
+ }
310
+ // if (entity_type === "ORGP") {
311
+ // return await api.get(`organization/sso/getdropdown`).then((response) => {
312
+ // return response.data;
313
+ // });
314
+ // }
315
+ return await api
316
+ .post(`entity/getListMasterDropdown/${entity_type}${params}`, requestBody)
317
+ .then((response) => {
318
+ return response.data;
319
+ });
320
+ };
@@ -77,14 +77,16 @@ export function customDebounce<T extends (...args: any[]) => any>(
77
77
  }
78
78
 
79
79
  //ENTITY TYPE
80
- const ENVIRONMENT = "adm_dev";
81
- export const ENTITY_TYPE = "SCH";
80
+ const ENVIRONMENT = "crm_dev";
81
+ export const ENTITY_TYPE = "LEAD";
82
+ export const MODULE_CODE = "school_adm_org";
82
83
  export const MAPPED_ENTITY_TYPE = "LYPR"; // LAP OR LYPR
83
84
  export const USER_ID = 226;
85
+ export const APP_CODE = "crm";
84
86
 
85
87
  const environments = {
86
88
  adm_dev: "http://localhost:6010/api",
87
- crm_dev: "http://localhost:4011/api",
89
+ crm_dev: "http://localhost:6011/api",
88
90
  uat: "https://api.eth-qa.rezolut.in/api/enrol",
89
91
  };
90
92
 
@@ -65,6 +65,7 @@ export interface EntityTableAPIProps {
65
65
  filter_value: string[] | string;
66
66
  }[];
67
67
  flatJson: boolean;
68
+ module_code?: string;
68
69
  }
69
70
 
70
71
  export interface viewSettingsDropDownAPIProps {
@@ -19,6 +19,11 @@ export interface QuickFilterModalProps {
19
19
  tabsApiDataLoading?: boolean;
20
20
  onSaveSettingsData?: (data: any) => void;
21
21
  activeTab?: string;
22
+ selectAttributeData?: { label: string; value: string }[];
23
+ selectSwinLandData?: { label: string; value: string }[];
24
+ laneHideListData?: { label: string; value: string }[];
25
+ swimLaneHideListData?: { label: string; value: string }[];
26
+ onSaveKanbanSettingsData?: (data: KanbanSettingsDataProps) => void;
22
27
  }
23
28
 
24
29
  type TabName = string;
@@ -31,6 +36,15 @@ export type QuickTabSortingType =
31
36
  | "count_dsc"
32
37
  | "custom";
33
38
 
39
+ export type KanbanSortingType =
40
+ | "asc"
41
+ | "dsc"
42
+ | "count_asc"
43
+ | "count_dsc"
44
+ | "custom"
45
+ | "sort_by"
46
+ | null;
47
+
34
48
  export interface QuickTabConfigProps {
35
49
  attribute?: string;
36
50
  sorting?: QuickTabSortingType;
@@ -39,6 +53,19 @@ export interface QuickTabConfigProps {
39
53
  isAllSelected?: boolean;
40
54
  isCombineOther?: boolean;
41
55
  }
56
+ export interface LaneTabConfigProps {
57
+ attribute?: string;
58
+ sorting?: KanbanSortingType;
59
+ hide_list?: { label: string; value: string }[];
60
+ show_list?: { label: string; value: string }[];
61
+ isSubLane?: boolean;
62
+ }
63
+ export interface SwimLameTabConfigProps {
64
+ attribute?: string;
65
+ sorting?: KanbanSortingType;
66
+ hide_list?: { label: string; value: string }[];
67
+ show_list?: { label: string; value: string }[];
68
+ }
42
69
 
43
70
  interface ColumnItem {
44
71
  label: string;
@@ -115,6 +142,10 @@ export interface SettingsDataProps {
115
142
  column?: ColumnTabConfigProps;
116
143
  sorting?: SortingConfigProps;
117
144
  }
145
+ export interface KanbanSettingsDataProps {
146
+ lane?: LaneTabConfigProps;
147
+ swim_lane?: SwimLameTabConfigProps;
148
+ }
118
149
 
119
150
  export interface ToggleButtonTabsProps {
120
151
  label: string;
@@ -55,7 +55,8 @@ export type FilterInputDataTypes =
55
55
  | "multiselect"
56
56
  | "date"
57
57
  | "year"
58
- | "number";
58
+ | "number"
59
+ | "label";
59
60
 
60
61
  export interface FilterColumnsListProps {
61
62
  created_date: string | null;
@@ -15,6 +15,7 @@ import {
15
15
  } from "./filter";
16
16
  import {
17
17
  ColumnTabConfigProps,
18
+ KanbanSettingsDataProps,
18
19
  QuickTabConfigProps,
19
20
  SavedButtonErrorProps,
20
21
  SettingsDataProps,
@@ -61,6 +62,8 @@ export interface CraftTableOptionsProps {
61
62
  export interface craftTableFilterSettingsOptionsProps {
62
63
  settingsData: SettingsDataProps;
63
64
  setSettingsData: Dispatch<SetStateAction<SettingsDataProps>>;
65
+ kanbanSettingsData: KanbanSettingsDataProps;
66
+ setKanbanSettingsData: Dispatch<SetStateAction<KanbanSettingsDataProps>>;
64
67
  showListViewSettings: boolean;
65
68
  setShowListViewSettings: Dispatch<SetStateAction<boolean>>;
66
69
  quickTabStates: QuickTabConfigProps;
@@ -1,21 +1,53 @@
1
- import { useState } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  import Kanban from "../kanban";
3
3
  import LeadCard from "../kanban/components/LeadCard";
4
- import { useGetKanbanData } from "../kanban/hooks/hooks";
4
+ import {
5
+ kanbanDropdownResults,
6
+ useGetAttributeDropdown,
7
+ useGetKanbanData,
8
+ } from "../kanban/hooks/hooks";
5
9
  import { useCraftTable } from "../listing/libs/hooks/useCraftTable";
6
10
  import {
7
11
  useEntityTableAPI,
8
12
  useGetSettingsDataAPI,
13
+ useSaveSettingsDataAPI,
9
14
  } from "../listing/libs/hooks/useEntityTableAPI";
10
- import { ENTITY_TYPE } from "../listing/libs/utils/common";
15
+ import { ENTITY_TYPE, MAPPED_ENTITY_TYPE } from "../listing/libs/utils/common";
11
16
  import { useCraftTableFilterSettings } from "../listing/libs/hooks/useCraftTableFilterSettings";
12
17
  import { QuickFilterSettings } from "../listing/components/table-settings";
18
+ import { KanbanSettingsDataProps } from "../listing/types/filter-settings";
19
+ import { useQueryClient } from "@tanstack/react-query";
13
20
 
14
21
  const KanbanView = () => {
15
22
  const { metaData, isLoading } = useGetKanbanData("LEAD");
16
- const { getSettingsAPIData } = useGetSettingsDataAPI(ENTITY_TYPE);
23
+ const { getSettingsAPIData } = useGetSettingsDataAPI(ENTITY_TYPE, "kanban");
17
24
  const [selectedTab, setSelectedTab] = useState("All");
18
25
  const tableStates = useCraftTable();
26
+
27
+ const filterSettingStates = useCraftTableFilterSettings();
28
+
29
+ const {
30
+ showListViewSettings,
31
+ setShowListViewSettings,
32
+ kanbanSettingsData,
33
+ setKanbanSettingsData,
34
+ } = filterSettingStates;
35
+
36
+ const { data: laneHideListData } = useGetAttributeDropdown(
37
+ "LEAD",
38
+ kanbanSettingsData?.lane?.attribute ?? ""
39
+ );
40
+ const { data: swimLaneHideListData } = useGetAttributeDropdown(
41
+ "LEAD",
42
+ kanbanSettingsData?.swim_lane?.attribute ?? ""
43
+ );
44
+ const queryClient = useQueryClient();
45
+
46
+ const [selectAttributeData] = kanbanDropdownResults("ATT", "1001");
47
+ const [selectSwinLandData] = kanbanDropdownResults("SWM", "1001");
48
+ const { saveSettingsDataMutation: saveKanbanSettingsDataMutation } =
49
+ useSaveSettingsDataAPI(ENTITY_TYPE);
50
+
19
51
  const { tableData } = useEntityTableAPI({
20
52
  page: 0,
21
53
  size: 20,
@@ -36,10 +68,36 @@ const KanbanView = () => {
36
68
  ],
37
69
  attributeFilter: [],
38
70
  });
39
- const filterSettingStates = useCraftTableFilterSettings();
40
71
 
41
- const { showListViewSettings, setShowListViewSettings, setSettingsData } =
42
- filterSettingStates;
72
+ const handleSaveKanbanSetSettingsData = (
73
+ kanbanSettingsData: KanbanSettingsDataProps
74
+ ) => {
75
+ console.log("kanbanSettingsData", kanbanSettingsData);
76
+
77
+ const payload = {
78
+ entity_type: MAPPED_ENTITY_TYPE,
79
+ mapped_entity_type: ENTITY_TYPE,
80
+ mapped_json: kanbanSettingsData,
81
+ type: "kanban",
82
+ };
83
+
84
+ saveKanbanSettingsDataMutation.mutate(
85
+ { payload },
86
+ {
87
+ onSuccess: () => {
88
+ queryClient.invalidateQueries({
89
+ queryKey: ["GET_NAVIGATION_LAYOUT", ENTITY_TYPE],
90
+ });
91
+ queryClient.invalidateQueries({
92
+ queryKey: ["meta", ENTITY_TYPE],
93
+ });
94
+ },
95
+ }
96
+ );
97
+ };
98
+ useEffect(() => {
99
+ setKanbanSettingsData(getSettingsAPIData?.mapped_json || {});
100
+ }, [getSettingsAPIData]);
43
101
 
44
102
  return (
45
103
  <div>
@@ -57,6 +115,11 @@ const KanbanView = () => {
57
115
  onClose={() => setShowListViewSettings(false)}
58
116
  columnsData={metaData || {}}
59
117
  columnsDataLoading={isLoading}
118
+ selectAttributeData={selectAttributeData?.data}
119
+ selectSwinLandData={selectSwinLandData?.data}
120
+ laneHideListData={laneHideListData}
121
+ swimLaneHideListData={swimLaneHideListData}
122
+ onSaveKanbanSettingsData={handleSaveKanbanSetSettingsData}
60
123
  // tabsApiData={settingsTabDropdownData || []}
61
124
  // tabsApiDataLoading={settingsTabDropdownPending}
62
125
  // onSaveSettingsData={handleSaveSettingsData}
@@ -10,6 +10,7 @@ import {
10
10
  ENTITY_TYPE,
11
11
  formatTableHeaders,
12
12
  MAPPED_ENTITY_TYPE,
13
+ MODULE_CODE,
13
14
  } from "../listing/libs/utils/common";
14
15
  import {
15
16
  useCommonFilterDropdownAPI,
@@ -135,7 +136,7 @@ function ListingView() {
135
136
  // }, 1000);
136
137
 
137
138
  fetchMeta();
138
- }, [selectedTab]);
139
+ }, [selectedTab, metaQuery?.data]);
139
140
 
140
141
  // useEffect(() => {
141
142
  // setFilters(detailsQuery.data ?? []);
@@ -187,6 +188,7 @@ function ListingView() {
187
188
  ],
188
189
  attributeFilter: [],
189
190
  flatJson: metaQuery.data?.is_flat_json || false,
191
+ // module_code: MODULE_CODE,
190
192
  });
191
193
 
192
194
  const newData = useMemo(
@@ -381,24 +383,7 @@ function ListingView() {
381
383
  );
382
384
  };
383
385
 
384
- return isTableDataPending ? (
385
- <Box
386
- sx={{
387
- // full viewport height
388
- display: "flex",
389
- flexDirection: "column",
390
- alignItems: "center",
391
- justifyContent: "center",
392
- gap: 2,
393
- bgcolor: "background.default",
394
- }}
395
- >
396
- <CircularProgress size={60} thickness={5} color="primary" />
397
- <Typography variant="body1" color="text.secondary">
398
- Loading, please wait...
399
- </Typography>
400
- </Box>
401
- ) : (
386
+ return (
402
387
  <TableWrapper
403
388
  data={filteredData}
404
389
  activeTab={selectedTab}
@@ -528,7 +513,7 @@ function ListingView() {
528
513
  ),
529
514
  searchValue: searchTerm,
530
515
  onSearchChange: (val) => setSearchTerm(val),
531
- showFilterToggle: false,
516
+ showFilterToggle: true,
532
517
  onFilterButtonClick: () =>
533
518
  tableStates.setShowTableFilter(!tableStates.showTableFilter),
534
519
  showColumnToggle: false,