rez-table-listing-mui 1.2.13 → 1.2.14
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.d.ts +116 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +47 -405
- package/src/index.ts +10 -9
- package/src/kanban/components/LeadCard.tsx +130 -0
- package/src/kanban/constants/kanban-constants.ts +249 -0
- package/src/kanban/hooks/hooks.ts +16 -0
- package/src/kanban/index.tsx +331 -0
- package/src/kanban/services/service.ts +11 -0
- package/src/kanban/styles/styles.tsx +256 -0
- package/src/kanban/types/types.ts +132 -0
- package/src/{components → listing/components}/column-visibility-modal/column-list-item.tsx +1 -1
- package/src/{components → listing/components}/column-visibility-modal/index.tsx +1 -1
- package/src/{components → listing/components}/filter/components/forms/components/Filter-criteria.tsx +1 -1
- package/src/{components → listing/components}/filter/components/forms/index.tsx +1 -1
- package/src/{components → listing/components}/filter/components/saved-filter.tsx +2 -2
- package/src/{components → listing/components}/filter/components/search/index.tsx +1 -1
- package/src/{components → listing/components}/filter/components/tabs/index.tsx +1 -1
- package/src/{components → listing/components}/index-table.tsx +1 -1
- package/src/{components → listing/components}/pagination/default/index.tsx +1 -1
- package/src/{components → listing/components}/search/index.tsx +1 -1
- package/src/{components → listing/components}/sorting-modal.tsx/index.tsx +1 -1
- package/src/{components → listing/components}/sorting-modal.tsx/sorting-item.tsx +1 -1
- package/src/{components → listing/components}/table-change-layout.tsx +1 -1
- package/src/{components → listing/components}/table-head-dnd-cell.tsx +6 -6
- package/src/{components → listing/components}/table-head-pin.tsx +1 -1
- package/src/{components → listing/components}/table-head-popover.tsx +1 -1
- package/src/{components → listing/components}/table-head.tsx +6 -6
- package/src/{components → listing/components}/table-settings/common/listing-values.tsx +1 -1
- package/src/{components → listing/components}/table-settings/components/sorting.tsx +1 -1
- package/src/{components → listing/components}/tabs/index.tsx +1 -1
- package/src/{components → listing/components}/topbar/index.tsx +7 -7
- package/src/{components → listing/components}/viewmore/index.tsx +1 -1
- package/src/{libs → listing/libs}/hooks/useDefaultColumns.tsx +1 -0
- package/src/{libs → listing/libs}/utils/common.ts +1 -1
- package/src/view/KanbanView.tsx +16 -0
- package/src/view/ListingView.tsx +423 -0
- /package/src/{components → listing/components}/column-visibility-modal/index.scss +0 -0
- /package/src/{components → listing/components}/common/confirm-modal/index.tsx +0 -0
- /package/src/{components → listing/components}/common/index.scss +0 -0
- /package/src/{components → listing/components}/common/index.tsx +0 -0
- /package/src/{components → listing/components}/common/loader/loader.tsx +0 -0
- /package/src/{components → listing/components}/dropdown/index.scss +0 -0
- /package/src/{components → listing/components}/dropdown/index.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/attributes-filter.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/forms/components/Date.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/forms/components/Dropdown.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/forms/components/Multi-Select.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/forms/components/Select.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/forms/components/Textfield.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/forms/components/styles.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/main-filter.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/saved-edit-filter.tsx +0 -0
- /package/src/{components → listing/components}/filter/components/tabs/custom-tab-panel.tsx +0 -0
- /package/src/{components → listing/components}/filter/index.tsx +0 -0
- /package/src/{components → listing/components}/filter/style.ts +0 -0
- /package/src/{components → listing/components}/index.scss +0 -0
- /package/src/{components → listing/components}/inputs/checkbox/index.tsx +0 -0
- /package/src/{components → listing/components}/inputs/index.scss +0 -0
- /package/src/{components → listing/components}/inputs/switch.tsx +0 -0
- /package/src/{components → listing/components}/login/index.tsx +0 -0
- /package/src/{components → listing/components}/nestedcomponent/index.scss +0 -0
- /package/src/{components → listing/components}/nestedcomponent/index.tsx +0 -0
- /package/src/{components → listing/components}/pagination/default/index.scss +0 -0
- /package/src/{components → listing/components}/search/style.ts +0 -0
- /package/src/{components → listing/components}/table-body-dnd-cell.tsx +0 -0
- /package/src/{components → listing/components}/table-body.tsx +0 -0
- /package/src/{components → listing/components}/table-dnd.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/common/draggable-listitem.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/common/info-alert.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/components/column.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/components/custom-button.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/components/custom-dialog.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/components/quick-tab.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/components/toggle-button-switch.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/constants.ts +0 -0
- /package/src/{components → listing/components}/table-settings/index.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/style.ts +0 -0
- /package/src/{components → listing/components}/table-settings/tabs/horizontal/index.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/tabs/styles.ts +0 -0
- /package/src/{components → listing/components}/table-settings/tabs/vertical/custom-tab-panel.tsx +0 -0
- /package/src/{components → listing/components}/table-settings/tabs/vertical/index.tsx +0 -0
- /package/src/{components → listing/components}/table.tsx +0 -0
- /package/src/{components → listing/components}/tabs/index.scss +0 -0
- /package/src/{components → listing/components}/tabs/styles.ts +0 -0
- /package/src/{components → listing/components}/topbar/index.scss +0 -0
- /package/src/{components → listing/components}/viewmore/index.scss +0 -0
- /package/src/{libs → listing/libs}/hooks/useCraftTable.tsx +0 -0
- /package/src/{libs → listing/libs}/hooks/useCraftTableFilterSettings.tsx +0 -0
- /package/src/{libs → listing/libs}/hooks/useElementWidth.tsx +0 -0
- /package/src/{libs → listing/libs}/hooks/useEntityTableAPI.tsx +0 -0
- /package/src/{libs → listing/libs}/hooks/useEntityTableHooks.ts +0 -0
- /package/src/{libs → listing/libs}/hooks/useFullScreen.tsx +0 -0
- /package/src/{libs → listing/libs}/hooks/useOutsideClick.tsx +0 -0
- /package/src/{libs → listing/libs}/utils/Data-format.ts +0 -0
- /package/src/{libs → listing/libs}/utils/amount-format.ts +0 -0
- /package/src/{libs → listing/libs}/utils/apiColumn.ts +0 -0
- /package/src/{libs → listing/libs}/utils/date-format.ts +0 -0
- /package/src/{libs → listing/libs}/utils/debounce.ts +0 -0
- /package/src/{libs → listing/libs}/utils/make-data.ts +0 -0
- /package/src/{libs → listing/libs}/utils/make-hierar-data.ts +0 -0
- /package/src/{libs → listing/libs}/utils/make-nested-data.ts +0 -0
- /package/src/{libs → listing/libs}/utils/rows-data.ts +0 -0
- /package/src/{types → listing/types}/common.ts +0 -0
- /package/src/{types → listing/types}/filter-settings.ts +0 -0
- /package/src/{types → listing/types}/filter.ts +0 -0
- /package/src/{types → listing/types}/table-options.ts +0 -0
- /package/src/{types → listing/types}/table.ts +0 -0
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,424 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import TableWrapper from "./components/index-table";
|
|
6
|
-
import { entityTableMetaMaster } from "./libs/utils/apiColumn";
|
|
7
|
-
import {
|
|
8
|
-
useCommonDropdownAPI,
|
|
9
|
-
useDeleteFilterAPI,
|
|
10
|
-
useEntityTableAPI,
|
|
11
|
-
useSavedFilterAPI,
|
|
12
|
-
useGetSettingsDataAPI,
|
|
13
|
-
useSettingsDropDownAPI,
|
|
14
|
-
useUpdateFilterAPI,
|
|
15
|
-
useSaveSettingsDataAPI,
|
|
16
|
-
} from "./libs/hooks/useEntityTableAPI";
|
|
17
|
-
import {
|
|
18
|
-
useDetailsQueryAPI,
|
|
19
|
-
useFetchData,
|
|
20
|
-
} from "./libs/hooks/useEntityTableHooks";
|
|
21
|
-
import LoginButton from "./components/login";
|
|
22
|
-
import { CraftTableFilter } from ".";
|
|
23
|
-
import { useCraftTableFilterSettings } from "./libs/hooks/useCraftTableFilterSettings";
|
|
24
|
-
import { QuickFilterSettings } from "./components/table-settings";
|
|
25
|
-
import { SettingsDataProps } from "./types/filter-settings";
|
|
26
|
-
import { FilterMasterStateProps } from "./types/filter";
|
|
27
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
28
|
-
import { ENTITY_TYPE } from "./libs/utils/common";
|
|
29
|
-
import { makeData, Person } from "./libs/utils/make-hierar-data";
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import LoginButton from "./listing/components/login";
|
|
3
|
+
import ListingView from "./view/ListingView";
|
|
4
|
+
import KanbanView from "./view/KanbanView";
|
|
30
5
|
|
|
31
6
|
function App() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const [columns, setColumns] = useState<any[]>([]);
|
|
35
|
-
const [searchTerm, setSearchTerm] = useState("");
|
|
36
|
-
const [data, setData] = useState<Person[]>(() => makeData(200, 3, 2));
|
|
37
|
-
|
|
38
|
-
const [selectedTab, setSelectedTab] = useState("All");
|
|
39
|
-
|
|
40
|
-
const tableStates = useCraftTable();
|
|
41
|
-
const filterSettingStates = useCraftTableFilterSettings();
|
|
42
|
-
|
|
43
|
-
const { filters, setFilters, filterMaster, setFilterMaster, filterToDelete } =
|
|
44
|
-
tableStates;
|
|
45
|
-
|
|
46
|
-
const { showListViewSettings, setShowListViewSettings, setSettingsData } =
|
|
47
|
-
filterSettingStates;
|
|
48
|
-
|
|
49
|
-
const { defaultColumns } = useDefaultColumns();
|
|
50
|
-
|
|
51
|
-
const { metaQuery } = useFetchData(ENTITY_TYPE);
|
|
52
|
-
const { detailsQuery } = useDetailsQueryAPI(
|
|
53
|
-
filterMaster?.saved_filters?.selectedId
|
|
54
|
-
? filterMaster?.saved_filters?.selectedId
|
|
55
|
-
: metaQuery?.data?.default_filter?.value
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
59
|
-
const { deleteMutation } = useDeleteFilterAPI(); //API FOR DELETING FILTER
|
|
60
|
-
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
61
|
-
const { saveSettingsDataMutation } = useSaveSettingsDataAPI(ENTITY_TYPE);
|
|
62
|
-
const { dropdownData } = useCommonDropdownAPI(metaQuery.data);
|
|
63
|
-
const { settingsTabDropdownData, settingsTabDropdownPending } =
|
|
64
|
-
useSettingsDropDownAPI({
|
|
65
|
-
entity_type: ENTITY_TYPE,
|
|
66
|
-
column: filterSettingStates?.quickTabStates?.attribute,
|
|
67
|
-
sort_by: filterSettingStates?.quickTabStates?.sorting,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const { getSettingsAPIData } = useGetSettingsDataAPI(ENTITY_TYPE);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
// setTimeout(() => {
|
|
74
|
-
// setMockLoading(false);
|
|
75
|
-
// }, 1000);
|
|
76
|
-
|
|
77
|
-
const fetchMeta = async () => {
|
|
78
|
-
try {
|
|
79
|
-
const { res: allColumns } = await entityTableMetaMaster(ENTITY_TYPE);
|
|
80
|
-
|
|
81
|
-
const savedColumnSettings = filterSettingStates.settingsData?.column;
|
|
82
|
-
|
|
83
|
-
const getOrderedColumns = (
|
|
84
|
-
showList: { value: string }[],
|
|
85
|
-
filteredColumns: any[]
|
|
86
|
-
) => {
|
|
87
|
-
// Build ordered columns using showList and filteredColumns
|
|
88
|
-
return showList
|
|
89
|
-
?.map((showItem) => {
|
|
90
|
-
return filteredColumns.find(
|
|
91
|
-
(col) => col?.accessorKey === showItem?.value
|
|
92
|
-
);
|
|
93
|
-
})
|
|
94
|
-
?.filter((col): col is ColumnDef<any> => col !== undefined); // Ensure non-undefined columns are returned
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
savedColumnSettings &&
|
|
99
|
-
!savedColumnSettings.isDefault &&
|
|
100
|
-
savedColumnSettings.tabs
|
|
101
|
-
) {
|
|
102
|
-
// Tab-wise view: find the active tab and use its show_list
|
|
103
|
-
const activeTabSettings = savedColumnSettings.tabs.find(
|
|
104
|
-
(tab) => tab.tab_name.toLowerCase() === selectedTab.toLowerCase()
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
if (activeTabSettings?.show_list) {
|
|
108
|
-
const visibleColumns = new Set(
|
|
109
|
-
activeTabSettings.show_list.map((c) => c.value)
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
// First, filter columns based on visibleColumns
|
|
113
|
-
const filteredColumns = allColumns.filter((col: any) =>
|
|
114
|
-
visibleColumns.has(col?.accessorKey)
|
|
115
|
-
);
|
|
116
|
-
setColumns(
|
|
117
|
-
getOrderedColumns(activeTabSettings.show_list, filteredColumns)
|
|
118
|
-
);
|
|
119
|
-
} else {
|
|
120
|
-
// Fallback if no specific settings for the active tab are found
|
|
121
|
-
setColumns(allColumns);
|
|
122
|
-
}
|
|
123
|
-
} else if (savedColumnSettings && savedColumnSettings.show_list) {
|
|
124
|
-
// Default view: use the main show_list
|
|
125
|
-
const visibleColumns = new Set(
|
|
126
|
-
savedColumnSettings.show_list.map((c) => c.value)
|
|
127
|
-
);
|
|
128
|
-
const filtered = allColumns.filter((col: any) =>
|
|
129
|
-
visibleColumns.has(col?.accessorKey)
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
setColumns(
|
|
133
|
-
getOrderedColumns(savedColumnSettings.show_list, filtered)
|
|
134
|
-
);
|
|
135
|
-
} else {
|
|
136
|
-
// No settings found, use all columns
|
|
137
|
-
setColumns(allColumns);
|
|
138
|
-
}
|
|
139
|
-
} catch (error) {
|
|
140
|
-
console.error("Failed to fetch metadata:", error);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
fetchMeta();
|
|
145
|
-
}, [selectedTab]);
|
|
146
|
-
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
setFilters(detailsQuery.data ?? []);
|
|
149
|
-
}, [detailsQuery.data]);
|
|
150
|
-
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
setSettingsData(getSettingsAPIData?.layout_json);
|
|
153
|
-
}, [getSettingsAPIData]);
|
|
154
|
-
|
|
155
|
-
//For server side sorting
|
|
156
|
-
const enableServerSideSorting = true;
|
|
157
|
-
|
|
158
|
-
const { tableData } = useEntityTableAPI({
|
|
159
|
-
page: 0,
|
|
160
|
-
size: 50,
|
|
161
|
-
entity_type: ENTITY_TYPE,
|
|
162
|
-
tabs: {
|
|
163
|
-
columnName:
|
|
164
|
-
getSettingsAPIData?.layout_json?.quick_tab?.attribute || "status",
|
|
165
|
-
sortBy: getSettingsAPIData?.layout_json?.quick_tab?.sorting || "ASC",
|
|
166
|
-
value:
|
|
167
|
-
selectedTab.toLowerCase() === "all" ? "" : selectedTab.toLowerCase(),
|
|
168
|
-
},
|
|
169
|
-
quickFilter: tableStates.filters,
|
|
170
|
-
sortby: [
|
|
171
|
-
{
|
|
172
|
-
sortColum: "name",
|
|
173
|
-
sortType: "ASC",
|
|
174
|
-
},
|
|
175
|
-
],
|
|
176
|
-
attributeFilter: [],
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const newData = useMemo(
|
|
180
|
-
() => tableData?.entity_list || [],
|
|
181
|
-
[tableData?.entity_list]
|
|
7
|
+
const [currentView, setCurrentView] = useState<"listing" | "kanban">(
|
|
8
|
+
"listing"
|
|
182
9
|
);
|
|
183
|
-
const tabsData = tableData?.entity_tabs;
|
|
184
10
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
) {
|
|
194
|
-
// Try to select 'ALL' if it exists
|
|
195
|
-
const allTab = tabsData.find(
|
|
196
|
-
(tab) => tab.tab_value?.toLowerCase() === "all"
|
|
197
|
-
);
|
|
198
|
-
if (allTab) {
|
|
199
|
-
setSelectedTab(allTab.tab_value || "All");
|
|
200
|
-
} else {
|
|
201
|
-
setSelectedTab(tabsData[0].tab_value || "All");
|
|
202
|
-
}
|
|
11
|
+
const renderView = () => {
|
|
12
|
+
switch (currentView) {
|
|
13
|
+
case "listing":
|
|
14
|
+
return <ListingView />;
|
|
15
|
+
case "kanban":
|
|
16
|
+
return <KanbanView />;
|
|
17
|
+
default:
|
|
18
|
+
return <ListingView />;
|
|
203
19
|
}
|
|
204
|
-
}, [tabsData, selectedTab]);
|
|
205
|
-
|
|
206
|
-
const totalCount = useMemo(() => {
|
|
207
|
-
return Number(
|
|
208
|
-
tableData?.entity_tabs?.find((tab) => {
|
|
209
|
-
const activeTab = selectedTab || "All";
|
|
210
|
-
return (
|
|
211
|
-
tab.tab_value?.toLocaleLowerCase() === activeTab.toLocaleLowerCase()
|
|
212
|
-
);
|
|
213
|
-
})?.tab_value_count || "0"
|
|
214
|
-
);
|
|
215
|
-
}, [tableData, selectedTab]);
|
|
216
|
-
|
|
217
|
-
const handleRenderStatus = ({ value }: any) => {
|
|
218
|
-
const statusValue = value?.toUpperCase();
|
|
219
|
-
return (
|
|
220
|
-
<div
|
|
221
|
-
style={{
|
|
222
|
-
backgroundColor: "#F0F0F0",
|
|
223
|
-
color: "#757575",
|
|
224
|
-
textTransform: "capitalize",
|
|
225
|
-
fontSize: "0.75rem",
|
|
226
|
-
fontWeight: 500,
|
|
227
|
-
borderRadius: "4px",
|
|
228
|
-
padding: "4px",
|
|
229
|
-
width: "fit-content",
|
|
230
|
-
}}
|
|
231
|
-
>
|
|
232
|
-
{statusValue}
|
|
233
|
-
</div>
|
|
234
|
-
);
|
|
235
20
|
};
|
|
236
21
|
|
|
237
|
-
const
|
|
238
|
-
|
|
22
|
+
const containedBtn = {
|
|
23
|
+
padding: "6px 14px",
|
|
24
|
+
marginRight: "8px",
|
|
25
|
+
borderRadius: "4px",
|
|
26
|
+
border: "none",
|
|
27
|
+
backgroundColor: "#1976d2",
|
|
28
|
+
color: "#fff",
|
|
29
|
+
cursor: "pointer",
|
|
239
30
|
};
|
|
240
31
|
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
);
|
|
250
|
-
}, [newData, searchTerm]);
|
|
251
|
-
|
|
252
|
-
// API to handle saving a filter
|
|
253
|
-
const handleSaveFilter = (name: string) => {
|
|
254
|
-
const quickFilter = filters.map((f) => ({
|
|
255
|
-
filter_attribute: f.filter_attribute,
|
|
256
|
-
filter_operator: f.filter_operator,
|
|
257
|
-
filter_value: f.filter_value,
|
|
258
|
-
}));
|
|
259
|
-
|
|
260
|
-
const payload = {
|
|
261
|
-
name,
|
|
262
|
-
is_default: false,
|
|
263
|
-
mapped_entity_type: ENTITY_TYPE, // For that entity type
|
|
264
|
-
status: "ACTIVE",
|
|
265
|
-
entity_type: "SFM", // FIXED entity type
|
|
266
|
-
filterDetails: quickFilter,
|
|
267
|
-
};
|
|
268
|
-
const entity_type = "SFM";
|
|
269
|
-
savedMutation.mutate(
|
|
270
|
-
{ entity_type, payload },
|
|
271
|
-
{
|
|
272
|
-
onSuccess: (response) => {
|
|
273
|
-
const newFilterId = response?.id;
|
|
274
|
-
if (newFilterId) {
|
|
275
|
-
setFilterMaster(
|
|
276
|
-
(prev) =>
|
|
277
|
-
({
|
|
278
|
-
...prev,
|
|
279
|
-
saved_filters: {
|
|
280
|
-
...prev?.saved_filters,
|
|
281
|
-
selectedId: newFilterId.toString(),
|
|
282
|
-
selectedName: name,
|
|
283
|
-
},
|
|
284
|
-
activeFilterTabIndex: 1,
|
|
285
|
-
} as FilterMasterStateProps)
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
}
|
|
290
|
-
);
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
// API to handle removing or deleting a filter
|
|
294
|
-
const handleRemoveFilter = () => {
|
|
295
|
-
const payload = {
|
|
296
|
-
name: filterToDelete?.label,
|
|
297
|
-
id: filterToDelete?.value,
|
|
298
|
-
is_default: false,
|
|
299
|
-
mapped_entity_type: ENTITY_TYPE,
|
|
300
|
-
status: "INACTIVE",
|
|
301
|
-
entity_type: "SFM",
|
|
302
|
-
};
|
|
303
|
-
const entity_type = "SFM";
|
|
304
|
-
deleteMutation.mutate({ entity_type, payload });
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
//API to update the filter
|
|
308
|
-
const handleUpdateFilter = () => {
|
|
309
|
-
const quickFilter = filters.map((f) => ({
|
|
310
|
-
filter_attribute: f.filter_attribute,
|
|
311
|
-
filter_operator: f.filter_operator,
|
|
312
|
-
filter_value: f.filter_value,
|
|
313
|
-
}));
|
|
314
|
-
|
|
315
|
-
const payload = {
|
|
316
|
-
name: filterMaster?.saved_filters?.selectedName, // Name of the filter
|
|
317
|
-
is_default: false,
|
|
318
|
-
id: filterMaster?.saved_filters?.selectedId,
|
|
319
|
-
mapped_entity_type: ENTITY_TYPE,
|
|
320
|
-
status: "ACTIVE",
|
|
321
|
-
entity_type: "SFM",
|
|
322
|
-
filterDetails: quickFilter,
|
|
323
|
-
};
|
|
324
|
-
const entity_type = "SFM";
|
|
325
|
-
updateMutation.mutate({ entity_type, payload });
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
|
|
329
|
-
const payload = {
|
|
330
|
-
entity_type: "LAP",
|
|
331
|
-
mapped_entity_type: ENTITY_TYPE,
|
|
332
|
-
layout_json: settingsData,
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
saveSettingsDataMutation.mutate({ payload });
|
|
32
|
+
const outlinedBtn = {
|
|
33
|
+
padding: "6px 14px",
|
|
34
|
+
marginRight: "8px",
|
|
35
|
+
borderRadius: "4px",
|
|
36
|
+
border: "1px solid #1976d2",
|
|
37
|
+
backgroundColor: "transparent",
|
|
38
|
+
color: "#1976d2",
|
|
39
|
+
cursor: "pointer",
|
|
336
40
|
};
|
|
337
41
|
|
|
338
42
|
return (
|
|
339
43
|
<div className="app_wrapper">
|
|
340
44
|
<LoginButton />
|
|
341
45
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
// loadingOptions={{
|
|
358
|
-
// isLoading: isTableDataPending || detailsQuery.isPending,
|
|
359
|
-
// // loaderText: "Loading, Please wait...",
|
|
360
|
-
// }}
|
|
361
|
-
paginationOptions={{
|
|
362
|
-
showPagination: true,
|
|
363
|
-
paginationPosition: "top",
|
|
364
|
-
paginationView: "compact",
|
|
365
|
-
totalRows: totalCount,
|
|
366
|
-
}}
|
|
367
|
-
customRenderFn={{
|
|
368
|
-
renderStatus: handleRenderStatus,
|
|
369
|
-
renderAction: handleRenderAction,
|
|
370
|
-
}}
|
|
371
|
-
// emptyListComponent={<div>No data found</div>}
|
|
372
|
-
filterOptions={{
|
|
373
|
-
show: tableStates?.showTableFilter,
|
|
374
|
-
component: (
|
|
375
|
-
<CraftTableFilter
|
|
376
|
-
tableStates={tableStates}
|
|
377
|
-
onClose={() => tableStates.setShowTableFilter(false)}
|
|
378
|
-
onUpdateFilter={handleUpdateFilter}
|
|
379
|
-
columnsData={metaQuery.data || {}}
|
|
380
|
-
dropdownData={dropdownData || []}
|
|
381
|
-
onDeleteFilter={handleRemoveFilter}
|
|
382
|
-
onSaveFilter={handleSaveFilter}
|
|
383
|
-
/>
|
|
384
|
-
),
|
|
385
|
-
}}
|
|
386
|
-
topbarOptions={{
|
|
387
|
-
tableStates,
|
|
388
|
-
leftSideComponent: (
|
|
389
|
-
<>
|
|
390
|
-
<TableTabs
|
|
391
|
-
columns={columns}
|
|
392
|
-
settingsOptions={{
|
|
393
|
-
showIcon: true,
|
|
394
|
-
onClick: () => setShowListViewSettings(!showListViewSettings),
|
|
395
|
-
}}
|
|
396
|
-
activeTab={selectedTab}
|
|
397
|
-
tableStates={tableStates}
|
|
398
|
-
tabsData={tabsData}
|
|
399
|
-
onClick={(state) => {
|
|
400
|
-
setSelectedTab(state);
|
|
401
|
-
}}
|
|
402
|
-
/>
|
|
46
|
+
{/* View Switch Buttons */}
|
|
47
|
+
<div style={{ marginBottom: "1rem", marginTop: "4px" }}>
|
|
48
|
+
<button
|
|
49
|
+
style={currentView === "listing" ? containedBtn : outlinedBtn}
|
|
50
|
+
onClick={() => setCurrentView("listing")}
|
|
51
|
+
>
|
|
52
|
+
Listing View
|
|
53
|
+
</button>
|
|
54
|
+
<button
|
|
55
|
+
style={currentView === "kanban" ? containedBtn : outlinedBtn}
|
|
56
|
+
onClick={() => setCurrentView("kanban")}
|
|
57
|
+
>
|
|
58
|
+
Kanban View
|
|
59
|
+
</button>
|
|
60
|
+
</div>
|
|
403
61
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
onClose={() => setShowListViewSettings(false)}
|
|
407
|
-
columnsData={metaQuery.data || {}}
|
|
408
|
-
columnsDataLoading={metaQuery.isPending}
|
|
409
|
-
tabsApiData={settingsTabDropdownData || []}
|
|
410
|
-
tabsApiDataLoading={settingsTabDropdownPending}
|
|
411
|
-
onSaveSettingsData={handleSaveSettingsData}
|
|
412
|
-
/>
|
|
413
|
-
</>
|
|
414
|
-
),
|
|
415
|
-
searchValue: searchTerm,
|
|
416
|
-
onSearchChange: (val) => setSearchTerm(val),
|
|
417
|
-
showFilterToggle: true,
|
|
418
|
-
onFilterButtonClick: () =>
|
|
419
|
-
tableStates.setShowTableFilter(!tableStates.showTableFilter),
|
|
420
|
-
}}
|
|
421
|
-
/>
|
|
62
|
+
{/* Conditional Content */}
|
|
63
|
+
{renderView()}
|
|
422
64
|
</div>
|
|
423
65
|
);
|
|
424
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { default as TableWrapper } from "./components/index-table";
|
|
2
|
-
export { useCraftTable } from "./libs/hooks/useCraftTable";
|
|
3
|
-
export { useCraftTableFilterSettings } from "./libs/hooks/useCraftTableFilterSettings";
|
|
4
|
-
export { TableTabs as CraftTableTabs } from "./components/tabs";
|
|
5
|
-
export { TableFilter as CraftTableFilter } from "./components/filter";
|
|
6
|
-
export { QuickFilterSettings as CraftTableSettings } from "./components/table-settings";
|
|
7
|
-
export { TableSearch as CraftTableSearch } from "./components/search";
|
|
1
|
+
export { default as TableWrapper } from "./listing/components/index-table";
|
|
2
|
+
export { useCraftTable } from "./listing/libs/hooks/useCraftTable";
|
|
3
|
+
export { useCraftTableFilterSettings } from "./listing/libs/hooks/useCraftTableFilterSettings";
|
|
4
|
+
export { TableTabs as CraftTableTabs } from "./listing/components/tabs";
|
|
5
|
+
export { TableFilter as CraftTableFilter } from "./listing/components/filter";
|
|
6
|
+
export { QuickFilterSettings as CraftTableSettings } from "./listing/components/table-settings";
|
|
7
|
+
export { TableSearch as CraftTableSearch } from "./listing/components/search";
|
|
8
|
+
export { default as KanbanWrapper } from "./kanban";
|
|
8
9
|
|
|
9
|
-
export * from "./types/table";
|
|
10
|
-
export * from "./types/table-options";
|
|
10
|
+
export * from "./listing/types/table";
|
|
11
|
+
export * from "./listing/types/table-options";
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Avatar,
|
|
3
|
+
Box,
|
|
4
|
+
Card,
|
|
5
|
+
CardContent,
|
|
6
|
+
Typography,
|
|
7
|
+
Tooltip,
|
|
8
|
+
IconButton,
|
|
9
|
+
} from "@mui/material";
|
|
10
|
+
import { LeadCardProps } from "../types/types";
|
|
11
|
+
import { CalendarIcon } from "@mui/x-date-pickers";
|
|
12
|
+
import PhoneOutlinedIcon from "@mui/icons-material/PhoneOutlined";
|
|
13
|
+
import EmailOutlinedIcon from "@mui/icons-material/EmailOutlined";
|
|
14
|
+
import { kanbanStyles } from "../styles/styles";
|
|
15
|
+
|
|
16
|
+
const LeadCard = ({ lead }: LeadCardProps) => {
|
|
17
|
+
const formatEnquiryDate = (enquiryDate: string | null) => {
|
|
18
|
+
if (!enquiryDate) return "N/A";
|
|
19
|
+
const date = new Date(enquiryDate);
|
|
20
|
+
return date.toLocaleDateString("en-GB", {
|
|
21
|
+
day: "numeric",
|
|
22
|
+
month: "short",
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const displayName =
|
|
27
|
+
`${lead.student_first_name || ""} ${lead.student_last_name || ""}`.trim() ||
|
|
28
|
+
"Unknown";
|
|
29
|
+
|
|
30
|
+
// Handle email click to open mailto
|
|
31
|
+
const handleEmailClick = () => {
|
|
32
|
+
if (lead.primary_email) {
|
|
33
|
+
window.open(
|
|
34
|
+
`https://mail.google.com/mail/?view=cm&to=${lead.primary_email}`,
|
|
35
|
+
"_blank"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Card sx={kanbanStyles.cardContainer}>
|
|
42
|
+
<CardContent sx={kanbanStyles.cardContent}>
|
|
43
|
+
{/* Code */}
|
|
44
|
+
<Typography
|
|
45
|
+
// onClick={() => dispatch(openNavigationTab(lead))}
|
|
46
|
+
sx={kanbanStyles.codeStyle}
|
|
47
|
+
>
|
|
48
|
+
{lead.code}
|
|
49
|
+
</Typography>
|
|
50
|
+
|
|
51
|
+
{/* Name + icons */}
|
|
52
|
+
<Box sx={kanbanStyles.nameIconContainer}>
|
|
53
|
+
<Typography variant="body1" sx={kanbanStyles.leadName}>
|
|
54
|
+
{displayName}
|
|
55
|
+
</Typography>
|
|
56
|
+
|
|
57
|
+
<Box sx={{ display: "flex", gap: 1 }}>
|
|
58
|
+
{/* Phone Icon with Tooltip */}
|
|
59
|
+
<Tooltip
|
|
60
|
+
title={lead.primary_mobile || "No phone number available"}
|
|
61
|
+
arrow
|
|
62
|
+
>
|
|
63
|
+
<IconButton
|
|
64
|
+
className="icon-button"
|
|
65
|
+
size="small"
|
|
66
|
+
disabled={!lead.primary_mobile}
|
|
67
|
+
sx={{
|
|
68
|
+
p: 0.5,
|
|
69
|
+
"&:hover": {
|
|
70
|
+
backgroundColor: "rgba(0, 0, 0, 0.04)",
|
|
71
|
+
},
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
<PhoneOutlinedIcon sx={kanbanStyles.iconStyle} />
|
|
75
|
+
</IconButton>
|
|
76
|
+
</Tooltip>
|
|
77
|
+
|
|
78
|
+
{/* Email Icon with Tooltip and Click Handler */}
|
|
79
|
+
<Tooltip title={lead.primary_email || "No email available"} arrow>
|
|
80
|
+
<IconButton
|
|
81
|
+
size="small"
|
|
82
|
+
onClick={handleEmailClick}
|
|
83
|
+
disabled={!lead.primary_email}
|
|
84
|
+
sx={{
|
|
85
|
+
p: 0.5,
|
|
86
|
+
cursor: lead.primary_email ? "pointer" : "default",
|
|
87
|
+
"&:hover": {
|
|
88
|
+
backgroundColor: "rgba(0, 0, 0, 0.04)",
|
|
89
|
+
},
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<EmailOutlinedIcon sx={kanbanStyles.iconStyle} />
|
|
93
|
+
</IconButton>
|
|
94
|
+
</Tooltip>
|
|
95
|
+
</Box>
|
|
96
|
+
</Box>
|
|
97
|
+
|
|
98
|
+
{/* Avatar + owner + date */}
|
|
99
|
+
<Box
|
|
100
|
+
sx={{
|
|
101
|
+
display: "flex",
|
|
102
|
+
justifyContent: "space-between",
|
|
103
|
+
alignItems: "center",
|
|
104
|
+
// mt: 1,
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<Box sx={{ display: "flex", alignItems: "center" }}>
|
|
108
|
+
<Avatar
|
|
109
|
+
src={lead?.profile?.signedUrl}
|
|
110
|
+
sx={kanbanStyles.cardAvatar}
|
|
111
|
+
></Avatar>
|
|
112
|
+
<Typography sx={kanbanStyles.leadOwnerStyle}>
|
|
113
|
+
{lead.lead_owner_name || "N/A"}
|
|
114
|
+
</Typography>
|
|
115
|
+
</Box>
|
|
116
|
+
<Box
|
|
117
|
+
sx={{ display: "flex", alignItems: "center", whiteSpace: "nowrap" }}
|
|
118
|
+
>
|
|
119
|
+
<CalendarIcon sx={kanbanStyles.calendarIcon} />
|
|
120
|
+
<Typography variant="body2" sx={kanbanStyles.dateStyle}>
|
|
121
|
+
{formatEnquiryDate(lead.enquiry_date)}
|
|
122
|
+
</Typography>
|
|
123
|
+
</Box>
|
|
124
|
+
</Box>
|
|
125
|
+
</CardContent>
|
|
126
|
+
</Card>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default LeadCard;
|