rez-table-listing-mui 1.2.13 → 1.2.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.
Files changed (114) hide show
  1. package/dist/index.d.ts +15 -2
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +1 -1
  7. package/src/App.tsx +47 -405
  8. package/src/index.ts +10 -9
  9. package/src/kanban/components/LeadCard.tsx +130 -0
  10. package/src/kanban/constants/kanban-constants.ts +249 -0
  11. package/src/kanban/hooks/hooks.ts +16 -0
  12. package/src/kanban/index.tsx +340 -0
  13. package/src/kanban/services/service.ts +11 -0
  14. package/src/kanban/styles/styles.tsx +256 -0
  15. package/src/kanban/types/types.ts +59 -0
  16. package/src/{components → listing/components}/column-visibility-modal/column-list-item.tsx +1 -1
  17. package/src/{components → listing/components}/column-visibility-modal/index.tsx +1 -1
  18. package/src/{components → listing/components}/filter/components/forms/components/Filter-criteria.tsx +1 -1
  19. package/src/{components → listing/components}/filter/components/forms/index.tsx +1 -1
  20. package/src/{components → listing/components}/filter/components/saved-filter.tsx +2 -2
  21. package/src/{components → listing/components}/filter/components/search/index.tsx +1 -1
  22. package/src/{components → listing/components}/filter/components/tabs/index.tsx +1 -1
  23. package/src/{components → listing/components}/index-table.tsx +1 -1
  24. package/src/{components → listing/components}/pagination/default/index.tsx +1 -1
  25. package/src/{components → listing/components}/search/index.tsx +1 -1
  26. package/src/{components → listing/components}/sorting-modal.tsx/index.tsx +1 -1
  27. package/src/{components → listing/components}/sorting-modal.tsx/sorting-item.tsx +1 -1
  28. package/src/{components → listing/components}/table-change-layout.tsx +1 -1
  29. package/src/{components → listing/components}/table-head-dnd-cell.tsx +1 -1
  30. package/src/{components → listing/components}/table-head-pin.tsx +1 -1
  31. package/src/{components → listing/components}/table-head-popover.tsx +1 -1
  32. package/src/{components → listing/components}/table-head.tsx +1 -1
  33. package/src/{components → listing/components}/table-settings/common/listing-values.tsx +1 -1
  34. package/src/listing/components/table-settings/components/group-by.tsx +513 -0
  35. package/src/listing/components/table-settings/components/lane.tsx +512 -0
  36. package/src/{components → listing/components}/table-settings/components/sorting.tsx +1 -1
  37. package/src/{components → listing/components}/table-settings/constants.ts +12 -0
  38. package/src/{components → listing/components}/table-settings/index.tsx +61 -29
  39. package/src/{components → listing/components}/tabs/index.tsx +1 -1
  40. package/src/{components → listing/components}/topbar/index.tsx +7 -7
  41. package/src/{components → listing/components}/viewmore/index.tsx +1 -1
  42. package/src/{libs → listing/libs}/utils/common.ts +2 -5
  43. package/src/{types → listing/types}/filter-settings.ts +1 -0
  44. package/src/view/KanbanView.tsx +68 -0
  45. package/src/view/ListingView.tsx +421 -0
  46. /package/src/{components → listing/components}/column-visibility-modal/index.scss +0 -0
  47. /package/src/{components → listing/components}/common/confirm-modal/index.tsx +0 -0
  48. /package/src/{components → listing/components}/common/index.scss +0 -0
  49. /package/src/{components → listing/components}/common/index.tsx +0 -0
  50. /package/src/{components → listing/components}/common/loader/loader.tsx +0 -0
  51. /package/src/{components → listing/components}/dropdown/index.scss +0 -0
  52. /package/src/{components → listing/components}/dropdown/index.tsx +0 -0
  53. /package/src/{components → listing/components}/filter/components/attributes-filter.tsx +0 -0
  54. /package/src/{components → listing/components}/filter/components/forms/components/Date.tsx +0 -0
  55. /package/src/{components → listing/components}/filter/components/forms/components/Dropdown.tsx +0 -0
  56. /package/src/{components → listing/components}/filter/components/forms/components/Multi-Select.tsx +0 -0
  57. /package/src/{components → listing/components}/filter/components/forms/components/Select.tsx +0 -0
  58. /package/src/{components → listing/components}/filter/components/forms/components/Textfield.tsx +0 -0
  59. /package/src/{components → listing/components}/filter/components/forms/components/styles.tsx +0 -0
  60. /package/src/{components → listing/components}/filter/components/main-filter.tsx +0 -0
  61. /package/src/{components → listing/components}/filter/components/saved-edit-filter.tsx +0 -0
  62. /package/src/{components → listing/components}/filter/components/tabs/custom-tab-panel.tsx +0 -0
  63. /package/src/{components → listing/components}/filter/index.tsx +0 -0
  64. /package/src/{components → listing/components}/filter/style.ts +0 -0
  65. /package/src/{components → listing/components}/index.scss +0 -0
  66. /package/src/{components → listing/components}/inputs/checkbox/index.tsx +0 -0
  67. /package/src/{components → listing/components}/inputs/index.scss +0 -0
  68. /package/src/{components → listing/components}/inputs/switch.tsx +0 -0
  69. /package/src/{components → listing/components}/login/index.tsx +0 -0
  70. /package/src/{components → listing/components}/nestedcomponent/index.scss +0 -0
  71. /package/src/{components → listing/components}/nestedcomponent/index.tsx +0 -0
  72. /package/src/{components → listing/components}/pagination/default/index.scss +0 -0
  73. /package/src/{components → listing/components}/search/style.ts +0 -0
  74. /package/src/{components → listing/components}/table-body-dnd-cell.tsx +0 -0
  75. /package/src/{components → listing/components}/table-body.tsx +0 -0
  76. /package/src/{components → listing/components}/table-dnd.tsx +0 -0
  77. /package/src/{components → listing/components}/table-settings/common/draggable-listitem.tsx +0 -0
  78. /package/src/{components → listing/components}/table-settings/common/info-alert.tsx +0 -0
  79. /package/src/{components → listing/components}/table-settings/components/column.tsx +0 -0
  80. /package/src/{components → listing/components}/table-settings/components/custom-button.tsx +0 -0
  81. /package/src/{components → listing/components}/table-settings/components/custom-dialog.tsx +0 -0
  82. /package/src/{components → listing/components}/table-settings/components/quick-tab.tsx +0 -0
  83. /package/src/{components → listing/components}/table-settings/components/toggle-button-switch.tsx +0 -0
  84. /package/src/{components → listing/components}/table-settings/style.ts +0 -0
  85. /package/src/{components → listing/components}/table-settings/tabs/horizontal/index.tsx +0 -0
  86. /package/src/{components → listing/components}/table-settings/tabs/styles.ts +0 -0
  87. /package/src/{components → listing/components}/table-settings/tabs/vertical/custom-tab-panel.tsx +0 -0
  88. /package/src/{components → listing/components}/table-settings/tabs/vertical/index.tsx +0 -0
  89. /package/src/{components → listing/components}/table.tsx +0 -0
  90. /package/src/{components → listing/components}/tabs/index.scss +0 -0
  91. /package/src/{components → listing/components}/tabs/styles.ts +0 -0
  92. /package/src/{components → listing/components}/topbar/index.scss +0 -0
  93. /package/src/{components → listing/components}/viewmore/index.scss +0 -0
  94. /package/src/{libs → listing/libs}/hooks/useCraftTable.tsx +0 -0
  95. /package/src/{libs → listing/libs}/hooks/useCraftTableFilterSettings.tsx +0 -0
  96. /package/src/{libs → listing/libs}/hooks/useDefaultColumns.tsx +0 -0
  97. /package/src/{libs → listing/libs}/hooks/useElementWidth.tsx +0 -0
  98. /package/src/{libs → listing/libs}/hooks/useEntityTableAPI.tsx +0 -0
  99. /package/src/{libs → listing/libs}/hooks/useEntityTableHooks.ts +0 -0
  100. /package/src/{libs → listing/libs}/hooks/useFullScreen.tsx +0 -0
  101. /package/src/{libs → listing/libs}/hooks/useOutsideClick.tsx +0 -0
  102. /package/src/{libs → listing/libs}/utils/Data-format.ts +0 -0
  103. /package/src/{libs → listing/libs}/utils/amount-format.ts +0 -0
  104. /package/src/{libs → listing/libs}/utils/apiColumn.ts +0 -0
  105. /package/src/{libs → listing/libs}/utils/date-format.ts +0 -0
  106. /package/src/{libs → listing/libs}/utils/debounce.ts +0 -0
  107. /package/src/{libs → listing/libs}/utils/make-data.ts +0 -0
  108. /package/src/{libs → listing/libs}/utils/make-hierar-data.ts +0 -0
  109. /package/src/{libs → listing/libs}/utils/make-nested-data.ts +0 -0
  110. /package/src/{libs → listing/libs}/utils/rows-data.ts +0 -0
  111. /package/src/{types → listing/types}/common.ts +0 -0
  112. /package/src/{types → listing/types}/filter.ts +0 -0
  113. /package/src/{types → listing/types}/table-options.ts +0 -0
  114. /package/src/{types → listing/types}/table.ts +0 -0
@@ -8,7 +8,7 @@ import {
8
8
  IconButton,
9
9
  Switch as MUISwitch,
10
10
  } from "@mui/material";
11
- import { CloseIcon, ViewMoreIcon } from "../../assets/svg";
11
+ import { CloseIcon, ViewMoreIcon } from "../../../assets/svg";
12
12
  import { useFullscreenPopoverContainer } from "../../libs/hooks/useFullScreen";
13
13
  import { CraftTableOptionsProps } from "../../types/table-options";
14
14
 
@@ -77,8 +77,8 @@ export function customDebounce<T extends (...args: any[]) => any>(
77
77
  }
78
78
 
79
79
  //ENTITY TYPE
80
- const ENVIRONMENT = "uat";
81
- export const ENTITY_TYPE = "UPR";
80
+ const ENVIRONMENT = "crm_dev";
81
+ export const ENTITY_TYPE = "LEAD";
82
82
 
83
83
  const environments = {
84
84
  adm_dev: "http://localhost:4010/api",
@@ -88,9 +88,6 @@ const environments = {
88
88
 
89
89
  const getBaseUrl = () => environments[ENVIRONMENT];
90
90
 
91
- // uat http://13.200.182.92:4010/api
92
- // local http://localhost:4010/api
93
-
94
91
  // API INTEGRATION
95
92
  export const api = axios.create({
96
93
  baseURL: getBaseUrl(),
@@ -2,6 +2,7 @@ import { FilterColumnsDataProps } from "./filter";
2
2
  import { craftTableFilterSettingsOptionsProps } from "./table-options";
3
3
 
4
4
  export interface QuickFilterModalProps {
5
+ view?: string;
5
6
  show?: boolean;
6
7
  filterSettingStates: craftTableFilterSettingsOptionsProps;
7
8
  onClose?: () => void;
@@ -0,0 +1,68 @@
1
+ import { useState } from "react";
2
+ import Kanban from "../kanban";
3
+ import LeadCard from "../kanban/components/LeadCard";
4
+ import { useGetKanbanData } from "../kanban/hooks/hooks";
5
+ import { useCraftTable } from "../listing/libs/hooks/useCraftTable";
6
+ import {
7
+ useEntityTableAPI,
8
+ useGetSettingsDataAPI,
9
+ } from "../listing/libs/hooks/useEntityTableAPI";
10
+ import { ENTITY_TYPE } from "../listing/libs/utils/common";
11
+ import { useCraftTableFilterSettings } from "../listing/libs/hooks/useCraftTableFilterSettings";
12
+ import { QuickFilterSettings } from "../listing/components/table-settings";
13
+
14
+ const KanbanView = () => {
15
+ const { metaData, isLoading } = useGetKanbanData("LEAD");
16
+ const { getSettingsAPIData } = useGetSettingsDataAPI(ENTITY_TYPE);
17
+ const [selectedTab, setSelectedTab] = useState("All");
18
+ const tableStates = useCraftTable();
19
+ const { tableData } = useEntityTableAPI({
20
+ page: 0,
21
+ size: 50,
22
+ entity_type: ENTITY_TYPE,
23
+ tabs: {
24
+ columnName:
25
+ getSettingsAPIData?.layout_json?.quick_tab?.attribute || "status",
26
+ sortBy: getSettingsAPIData?.layout_json?.quick_tab?.sorting || "ASC",
27
+ value:
28
+ selectedTab.toLowerCase() === "all" ? "" : selectedTab.toLowerCase(),
29
+ },
30
+ quickFilter: tableStates.filters,
31
+ sortby: [
32
+ {
33
+ sortColum: "name",
34
+ sortType: "ASC",
35
+ },
36
+ ],
37
+ attributeFilter: [],
38
+ });
39
+ const filterSettingStates = useCraftTableFilterSettings();
40
+
41
+ const { showListViewSettings, setShowListViewSettings, setSettingsData } =
42
+ filterSettingStates;
43
+
44
+ return (
45
+ <div>
46
+ <Kanban
47
+ metaData={metaData}
48
+ data={tableData?.entity_list}
49
+ isLoading={isLoading}
50
+ KanbanCardComponent={LeadCard}
51
+ showSettings={true}
52
+ onOpenSettings={() => setShowListViewSettings(true)}
53
+ />
54
+ <QuickFilterSettings
55
+ view="kanban"
56
+ filterSettingStates={filterSettingStates}
57
+ onClose={() => setShowListViewSettings(false)}
58
+ columnsData={metaData || {}}
59
+ columnsDataLoading={isLoading}
60
+ // tabsApiData={settingsTabDropdownData || []}
61
+ // tabsApiDataLoading={settingsTabDropdownPending}
62
+ // onSaveSettingsData={handleSaveSettingsData}
63
+ />
64
+ </div>
65
+ );
66
+ };
67
+
68
+ export default KanbanView;
@@ -0,0 +1,421 @@
1
+ import { useEffect, useMemo, useState } from "react";
2
+ import { useCraftTable } from "../listing/libs/hooks/useCraftTable";
3
+ import { useCraftTableFilterSettings } from "../listing/libs/hooks/useCraftTableFilterSettings";
4
+ import { useDefaultColumns } from "../listing/libs/hooks/useDefaultColumns";
5
+ import {
6
+ useDetailsQueryAPI,
7
+ useFetchData,
8
+ } from "../listing/libs/hooks/useEntityTableHooks";
9
+ import { ENTITY_TYPE } from "../listing/libs/utils/common";
10
+ import {
11
+ useCommonDropdownAPI,
12
+ useDeleteFilterAPI,
13
+ useEntityTableAPI,
14
+ useGetSettingsDataAPI,
15
+ useSavedFilterAPI,
16
+ useSaveSettingsDataAPI,
17
+ useSettingsDropDownAPI,
18
+ useUpdateFilterAPI,
19
+ } from "../listing/libs/hooks/useEntityTableAPI";
20
+ import { entityTableMetaMaster } from "../listing/libs/utils/apiColumn";
21
+ import { ColumnDef } from "@tanstack/react-table";
22
+ import { FilterMasterStateProps } from "../listing/types/filter";
23
+ import { SettingsDataProps } from "../listing/types/filter-settings";
24
+ import TableWrapper from "../listing/components/index-table";
25
+ import { CraftTableFilter } from "..";
26
+ import { TableTabs } from "../listing/components/tabs";
27
+ import { QuickFilterSettings } from "../listing/components/table-settings";
28
+
29
+ function ListingView() {
30
+ // const [mockLoading, setMockLoading] = useState<boolean>(true);
31
+ // const [jsonData] = useState<any[]>([]);
32
+ const [columns, setColumns] = useState<any[]>([]);
33
+ const [searchTerm, setSearchTerm] = useState("");
34
+ // const [data, setData] = useState<Person[]>(() => makeData(200, 3, 2));
35
+
36
+ const [selectedTab, setSelectedTab] = useState("All");
37
+
38
+ const tableStates = useCraftTable();
39
+ const filterSettingStates = useCraftTableFilterSettings();
40
+
41
+ const { filters, setFilters, filterMaster, setFilterMaster, filterToDelete } =
42
+ tableStates;
43
+
44
+ const { showListViewSettings, setShowListViewSettings, setSettingsData } =
45
+ filterSettingStates;
46
+
47
+ const { defaultColumns } = useDefaultColumns();
48
+
49
+ const { metaQuery } = useFetchData(ENTITY_TYPE);
50
+ const { detailsQuery } = useDetailsQueryAPI(
51
+ filterMaster?.saved_filters?.selectedId
52
+ ? filterMaster?.saved_filters?.selectedId
53
+ : metaQuery?.data?.default_filter?.value
54
+ );
55
+
56
+ const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
57
+ const { deleteMutation } = useDeleteFilterAPI(); //API FOR DELETING FILTER
58
+ const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
59
+ const { saveSettingsDataMutation } = useSaveSettingsDataAPI(ENTITY_TYPE);
60
+ const { dropdownData } = useCommonDropdownAPI(metaQuery.data);
61
+ const { settingsTabDropdownData, settingsTabDropdownPending } =
62
+ useSettingsDropDownAPI({
63
+ entity_type: ENTITY_TYPE,
64
+ column: filterSettingStates?.quickTabStates?.attribute,
65
+ sort_by: filterSettingStates?.quickTabStates?.sorting,
66
+ });
67
+
68
+ const { getSettingsAPIData } = useGetSettingsDataAPI(ENTITY_TYPE);
69
+
70
+ useEffect(() => {
71
+ // setTimeout(() => {
72
+ // setMockLoading(false);
73
+ // }, 1000);
74
+
75
+ const fetchMeta = async () => {
76
+ try {
77
+ const { res: allColumns } = await entityTableMetaMaster(ENTITY_TYPE);
78
+
79
+ const savedColumnSettings = filterSettingStates.settingsData?.column;
80
+
81
+ const getOrderedColumns = (
82
+ showList: { value: string }[],
83
+ filteredColumns: any[]
84
+ ) => {
85
+ // Build ordered columns using showList and filteredColumns
86
+ return showList
87
+ ?.map((showItem) => {
88
+ return filteredColumns.find(
89
+ (col) => col?.accessorKey === showItem?.value
90
+ );
91
+ })
92
+ ?.filter((col): col is ColumnDef<any> => col !== undefined); // Ensure non-undefined columns are returned
93
+ };
94
+
95
+ if (
96
+ savedColumnSettings &&
97
+ !savedColumnSettings.isDefault &&
98
+ savedColumnSettings.tabs
99
+ ) {
100
+ // Tab-wise view: find the active tab and use its show_list
101
+ const activeTabSettings = savedColumnSettings.tabs.find(
102
+ (tab) => tab.tab_name.toLowerCase() === selectedTab.toLowerCase()
103
+ );
104
+
105
+ if (activeTabSettings?.show_list) {
106
+ const visibleColumns = new Set(
107
+ activeTabSettings.show_list.map((c) => c.value)
108
+ );
109
+
110
+ // First, filter columns based on visibleColumns
111
+ const filteredColumns = allColumns.filter((col: any) =>
112
+ visibleColumns.has(col?.accessorKey)
113
+ );
114
+ setColumns(
115
+ getOrderedColumns(activeTabSettings.show_list, filteredColumns)
116
+ );
117
+ } else {
118
+ // Fallback if no specific settings for the active tab are found
119
+ setColumns(allColumns);
120
+ }
121
+ } else if (savedColumnSettings && savedColumnSettings.show_list) {
122
+ // Default view: use the main show_list
123
+ const visibleColumns = new Set(
124
+ savedColumnSettings.show_list.map((c) => c.value)
125
+ );
126
+ const filtered = allColumns.filter((col: any) =>
127
+ visibleColumns.has(col?.accessorKey)
128
+ );
129
+
130
+ setColumns(
131
+ getOrderedColumns(savedColumnSettings.show_list, filtered)
132
+ );
133
+ } else {
134
+ // No settings found, use all columns
135
+ setColumns(allColumns);
136
+ }
137
+ } catch (error) {
138
+ console.error("Failed to fetch metadata:", error);
139
+ }
140
+ };
141
+
142
+ fetchMeta();
143
+ }, [selectedTab]);
144
+
145
+ useEffect(() => {
146
+ setFilters(detailsQuery.data ?? []);
147
+ }, [detailsQuery.data]);
148
+
149
+ useEffect(() => {
150
+ setSettingsData(getSettingsAPIData?.layout_json);
151
+ }, [getSettingsAPIData]);
152
+
153
+ //For server side sorting
154
+ const enableServerSideSorting = true;
155
+
156
+ const { tableData } = useEntityTableAPI({
157
+ page: 0,
158
+ size: 50,
159
+ entity_type: ENTITY_TYPE,
160
+ tabs: {
161
+ columnName:
162
+ getSettingsAPIData?.layout_json?.quick_tab?.attribute || "status",
163
+ sortBy: getSettingsAPIData?.layout_json?.quick_tab?.sorting || "ASC",
164
+ value:
165
+ selectedTab.toLowerCase() === "all" ? "" : selectedTab.toLowerCase(),
166
+ },
167
+ quickFilter: tableStates.filters,
168
+ sortby: [
169
+ {
170
+ sortColum: "name",
171
+ sortType: "ASC",
172
+ },
173
+ ],
174
+ attributeFilter: [],
175
+ });
176
+
177
+ const newData = useMemo(
178
+ () => tableData?.entity_list || [],
179
+ [tableData?.entity_list]
180
+ );
181
+ const tabsData = tableData?.entity_tabs;
182
+
183
+ // Auto-switch tab if the selected tab is removed
184
+ useEffect(() => {
185
+ if (
186
+ tabsData &&
187
+ tabsData.length > 0 &&
188
+ !tabsData.some(
189
+ (tab) => tab.tab_value?.toLowerCase() === selectedTab.toLowerCase()
190
+ )
191
+ ) {
192
+ // Try to select 'ALL' if it exists
193
+ const allTab = tabsData.find(
194
+ (tab) => tab.tab_value?.toLowerCase() === "all"
195
+ );
196
+ if (allTab) {
197
+ setSelectedTab(allTab.tab_value || "All");
198
+ } else {
199
+ setSelectedTab(tabsData[0].tab_value || "All");
200
+ }
201
+ }
202
+ }, [tabsData, selectedTab]);
203
+
204
+ const totalCount = useMemo(() => {
205
+ return Number(
206
+ tableData?.entity_tabs?.find((tab) => {
207
+ const activeTab = selectedTab || "All";
208
+ return (
209
+ tab.tab_value?.toLocaleLowerCase() === activeTab.toLocaleLowerCase()
210
+ );
211
+ })?.tab_value_count || "0"
212
+ );
213
+ }, [tableData, selectedTab]);
214
+
215
+ const handleRenderStatus = ({ value }: any) => {
216
+ const statusValue = value?.toUpperCase();
217
+ return (
218
+ <div
219
+ style={{
220
+ backgroundColor: "#F0F0F0",
221
+ color: "#757575",
222
+ textTransform: "capitalize",
223
+ fontSize: "0.75rem",
224
+ fontWeight: 500,
225
+ borderRadius: "4px",
226
+ padding: "4px",
227
+ width: "fit-content",
228
+ }}
229
+ >
230
+ {statusValue}
231
+ </div>
232
+ );
233
+ };
234
+
235
+ const handleRenderAction = ({ row }: any) => {
236
+ return <button onClick={() => alert(JSON.stringify(row))}>Edit</button>;
237
+ };
238
+
239
+ const filteredData = useMemo(() => {
240
+ if (!searchTerm) return newData;
241
+
242
+ return newData.filter((row: any) =>
243
+ Object.values(row)
244
+ .join(" ")
245
+ .toLowerCase()
246
+ .includes(searchTerm.toLowerCase())
247
+ );
248
+ }, [newData, searchTerm]);
249
+
250
+ // API to handle saving a filter
251
+ const handleSaveFilter = (name: string) => {
252
+ const quickFilter = filters.map((f) => ({
253
+ filter_attribute: f.filter_attribute,
254
+ filter_operator: f.filter_operator,
255
+ filter_value: f.filter_value,
256
+ }));
257
+
258
+ const payload = {
259
+ name,
260
+ is_default: false,
261
+ mapped_entity_type: ENTITY_TYPE, // For that entity type
262
+ status: "ACTIVE",
263
+ entity_type: "SFM", // FIXED entity type
264
+ filterDetails: quickFilter,
265
+ };
266
+ const entity_type = "SFM";
267
+ savedMutation.mutate(
268
+ { entity_type, payload },
269
+ {
270
+ onSuccess: (response) => {
271
+ const newFilterId = response?.id;
272
+ if (newFilterId) {
273
+ setFilterMaster(
274
+ (prev) =>
275
+ ({
276
+ ...prev,
277
+ saved_filters: {
278
+ ...prev?.saved_filters,
279
+ selectedId: newFilterId.toString(),
280
+ selectedName: name,
281
+ },
282
+ activeFilterTabIndex: 1,
283
+ } as FilterMasterStateProps)
284
+ );
285
+ }
286
+ },
287
+ }
288
+ );
289
+ };
290
+
291
+ // API to handle removing or deleting a filter
292
+ const handleRemoveFilter = () => {
293
+ const payload = {
294
+ name: filterToDelete?.label,
295
+ id: filterToDelete?.value,
296
+ is_default: false,
297
+ mapped_entity_type: ENTITY_TYPE,
298
+ status: "INACTIVE",
299
+ entity_type: "SFM",
300
+ };
301
+ const entity_type = "SFM";
302
+ deleteMutation.mutate({ entity_type, payload });
303
+ };
304
+
305
+ //API to update the filter
306
+ const handleUpdateFilter = () => {
307
+ const quickFilter = filters.map((f) => ({
308
+ filter_attribute: f.filter_attribute,
309
+ filter_operator: f.filter_operator,
310
+ filter_value: f.filter_value,
311
+ }));
312
+
313
+ const payload = {
314
+ name: filterMaster?.saved_filters?.selectedName, // Name of the filter
315
+ is_default: false,
316
+ id: filterMaster?.saved_filters?.selectedId,
317
+ mapped_entity_type: ENTITY_TYPE,
318
+ status: "ACTIVE",
319
+ entity_type: "SFM",
320
+ filterDetails: quickFilter,
321
+ };
322
+ const entity_type = "SFM";
323
+ updateMutation.mutate({ entity_type, payload });
324
+ };
325
+
326
+ const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
327
+ const payload = {
328
+ entity_type: "LAP",
329
+ mapped_entity_type: ENTITY_TYPE,
330
+ layout_json: settingsData,
331
+ };
332
+
333
+ saveSettingsDataMutation.mutate({ payload });
334
+ };
335
+
336
+ return (
337
+ <TableWrapper
338
+ data={filteredData}
339
+ // data={data}
340
+ // columns={defaultColumns}
341
+ columns={columns && columns.length > 0 ? columns : defaultColumns}
342
+ tableStates={tableStates}
343
+ featureOptions={{
344
+ striped: true,
345
+ compactTable: false,
346
+ enableSorting: !enableServerSideSorting,
347
+ enableColumnReordering: true,
348
+ enableColumnResizing: true,
349
+ enableRowSelection: false,
350
+ enableServerSideSorting: enableServerSideSorting,
351
+ }}
352
+ // loadingOptions={{
353
+ // isLoading: isTableDataPending || detailsQuery.isPending,
354
+ // // loaderText: "Loading, Please wait...",
355
+ // }}
356
+ paginationOptions={{
357
+ showPagination: true,
358
+ paginationPosition: "top",
359
+ paginationView: "compact",
360
+ totalRows: totalCount,
361
+ }}
362
+ customRenderFn={{
363
+ renderStatus: handleRenderStatus,
364
+ renderAction: handleRenderAction,
365
+ }}
366
+ // emptyListComponent={<div>No data found</div>}
367
+ filterOptions={{
368
+ show: tableStates?.showTableFilter,
369
+ component: (
370
+ <CraftTableFilter
371
+ tableStates={tableStates}
372
+ onClose={() => tableStates.setShowTableFilter(false)}
373
+ onUpdateFilter={handleUpdateFilter}
374
+ columnsData={metaQuery.data || {}}
375
+ dropdownData={dropdownData || []}
376
+ onDeleteFilter={handleRemoveFilter}
377
+ onSaveFilter={handleSaveFilter}
378
+ />
379
+ ),
380
+ }}
381
+ topbarOptions={{
382
+ tableStates,
383
+ leftSideComponent: (
384
+ <>
385
+ <TableTabs
386
+ columns={columns}
387
+ settingsOptions={{
388
+ showIcon: true,
389
+ onClick: () => setShowListViewSettings(!showListViewSettings),
390
+ }}
391
+ activeTab={selectedTab}
392
+ tableStates={tableStates}
393
+ tabsData={tabsData}
394
+ onClick={(state) => {
395
+ setSelectedTab(state);
396
+ }}
397
+ />
398
+
399
+ <QuickFilterSettings
400
+ view="listing"
401
+ filterSettingStates={filterSettingStates}
402
+ onClose={() => setShowListViewSettings(false)}
403
+ columnsData={metaQuery.data || {}}
404
+ columnsDataLoading={metaQuery.isPending}
405
+ tabsApiData={settingsTabDropdownData || []}
406
+ tabsApiDataLoading={settingsTabDropdownPending}
407
+ onSaveSettingsData={handleSaveSettingsData}
408
+ />
409
+ </>
410
+ ),
411
+ searchValue: searchTerm,
412
+ onSearchChange: (val) => setSearchTerm(val),
413
+ showFilterToggle: true,
414
+ onFilterButtonClick: () =>
415
+ tableStates.setShowTableFilter(!tableStates.showTableFilter),
416
+ }}
417
+ />
418
+ );
419
+ }
420
+
421
+ export default ListingView;