rez-table-listing-mui 0.0.24 → 0.0.26
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/.env.uat +1 -0
- package/.eslintrc.cjs +11 -9
- package/dist/index.d.ts +104 -11
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -10
- package/src/App.tsx +185 -142
- package/src/assets/svg.tsx +33 -2
- package/src/components/common/confirm-modal/index.tsx +200 -0
- package/src/components/filter/components/attributes-filter.tsx +26 -0
- package/src/components/filter/components/forms/components/Attributes-select.tsx +180 -0
- package/src/components/filter/components/forms/components/Date.tsx +58 -0
- package/src/components/filter/components/forms/components/Dropdown.tsx +62 -0
- package/src/components/filter/components/forms/components/Filter-criteria.tsx +164 -0
- package/src/components/filter/components/forms/components/Multi-Select.tsx +57 -0
- package/src/components/filter/components/forms/components/Select.tsx +53 -0
- package/src/components/filter/components/forms/components/Textfield.tsx +43 -0
- package/src/components/filter/components/forms/components/styles.tsx +11 -0
- package/src/components/filter/components/forms/index.tsx +424 -0
- package/src/components/filter/components/main-filter.tsx +53 -0
- package/src/components/filter/components/saved-edit-filter.tsx +101 -0
- package/src/components/filter/components/saved-filter.tsx +148 -0
- package/src/components/filter/components/search/index.tsx +56 -0
- package/src/components/filter/components/tabs/custom-tab-panel.tsx +29 -0
- package/src/components/filter/components/tabs/index.tsx +52 -0
- package/src/components/filter/index.tsx +258 -0
- package/src/components/index-table.tsx +20 -14
- package/src/components/index.scss +4 -0
- package/src/components/login/index.tsx +49 -0
- package/src/components/search/index.tsx +0 -1
- package/src/components/table-body-dnd-cell.tsx +3 -3
- package/src/components/table-body.tsx +8 -5
- package/src/components/table-head-popover.tsx +2 -1
- package/src/components/table-head.tsx +0 -10
- package/src/components/topbar/index.scss +6 -1
- package/src/components/topbar/index.tsx +59 -33
- package/src/components/viewmore/index.tsx +33 -17
- package/src/libs/hooks/useCraftTable.tsx +32 -6
- package/src/libs/hooks/useDefaultColumns.tsx +6 -5
- package/src/libs/hooks/useEntityTableAPI.tsx +183 -0
- package/src/libs/hooks/useEntityTableHooks.ts +25 -0
- package/src/libs/utils/apiColumn.ts +123 -0
- package/src/libs/utils/common.ts +42 -0
- package/src/main.tsx +6 -3
- package/src/types/common.ts +67 -0
- package/src/types/filter.ts +211 -0
- package/src/types/table-options.ts +15 -2
- package/src/types/table.ts +7 -6
- package/tsconfig.json +1 -1
- package/vite.config.ts +3 -3
|
@@ -17,13 +17,13 @@ interface DragAlongCellProps<T> {
|
|
|
17
17
|
|
|
18
18
|
function DragAlongCell<T>({
|
|
19
19
|
cell,
|
|
20
|
-
featureOptions,
|
|
20
|
+
// featureOptions,
|
|
21
21
|
tableStates,
|
|
22
22
|
}: DragAlongCellProps<T>) {
|
|
23
23
|
const { isDragging, setNodeRef, transform } = useSortable({
|
|
24
24
|
id: cell.column.id,
|
|
25
25
|
});
|
|
26
|
-
const { enableWordBreakAll } = featureOptions;
|
|
26
|
+
// const { enableWordBreakAll } = featureOptions;
|
|
27
27
|
const { wrapColumns } = tableStates;
|
|
28
28
|
|
|
29
29
|
const isPinned = cell.column.getIsPinned();
|
|
@@ -34,7 +34,7 @@ function DragAlongCell<T>({
|
|
|
34
34
|
transition: "width transform 0.2s ease-in-out",
|
|
35
35
|
width: cell.column.getSize(),
|
|
36
36
|
...getColumnPinningStylesBody(cell.column),
|
|
37
|
-
...(wrapColumns[cell.column.id] && {
|
|
37
|
+
...((wrapColumns.all_wrap || wrapColumns[cell.column.id]) && {
|
|
38
38
|
wordBreak: "break-all",
|
|
39
39
|
// whiteSpace: "normal",
|
|
40
40
|
}),
|
|
@@ -64,7 +64,7 @@ function TableBody<T>({
|
|
|
64
64
|
style: {
|
|
65
65
|
...getColumnPinningStylesBody(cell.column),
|
|
66
66
|
width: cell.column.getSize(),
|
|
67
|
-
...(wrapColumns[cell.column.id] && {
|
|
67
|
+
...((wrapColumns.all_wrap || wrapColumns[cell.column.id]) && {
|
|
68
68
|
wordBreak: "break-all",
|
|
69
69
|
// whiteSpace: "normal",
|
|
70
70
|
}),
|
|
@@ -97,11 +97,14 @@ function TableBody<T>({
|
|
|
97
97
|
return (
|
|
98
98
|
<React.Fragment key={row.id}>
|
|
99
99
|
{renderedRow}
|
|
100
|
-
|
|
101
|
-
<
|
|
100
|
+
{NestedComponent && (
|
|
101
|
+
<tr>
|
|
102
|
+
{/* <td colSpan={table.getAllLeafColumns().length}>//commented out to remove extra line on opening of
|
|
102
103
|
{NestedComponent && <NestedComponent {...{ row }} />}
|
|
103
|
-
</td>
|
|
104
|
-
|
|
104
|
+
</td> */}
|
|
105
|
+
{<NestedComponent {...{ row }} />}
|
|
106
|
+
</tr>
|
|
107
|
+
)}
|
|
105
108
|
</React.Fragment>
|
|
106
109
|
);
|
|
107
110
|
} else {
|
|
@@ -39,6 +39,7 @@ function TableHeadPopover<T>({
|
|
|
39
39
|
setWrapColumns((prev: Record<string, boolean>) => ({
|
|
40
40
|
...prev,
|
|
41
41
|
[columnId]: !prev[columnId],
|
|
42
|
+
all_wrap: false,
|
|
42
43
|
}));
|
|
43
44
|
};
|
|
44
45
|
|
|
@@ -84,7 +85,7 @@ function TableHeadPopover<T>({
|
|
|
84
85
|
<ListItemButton>
|
|
85
86
|
<ListItemText primary="Wrap Cell" />
|
|
86
87
|
<Switch
|
|
87
|
-
checked={wrapColumns[column.id]}
|
|
88
|
+
checked={wrapColumns.all_wrap || wrapColumns[column.id]}
|
|
88
89
|
onChange={() => toggleWrapForColumn(column.id)}
|
|
89
90
|
/>
|
|
90
91
|
</ListItemButton>
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
import DraggableTableHeader from "./table-head-dnd-cell";
|
|
18
18
|
import TableHeadPin from "./table-head-pin";
|
|
19
19
|
import Checkbox from "./inputs/checkbox";
|
|
20
|
-
import TableHeadPopover from "./table-head-popover";
|
|
21
20
|
|
|
22
21
|
interface TableHeadProps<T> {
|
|
23
22
|
table: Table<T>;
|
|
@@ -41,15 +40,6 @@ function TableHead<T>({
|
|
|
41
40
|
|
|
42
41
|
// Popover
|
|
43
42
|
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
|
44
|
-
const [wrap, setWrap] = useState(false);
|
|
45
|
-
|
|
46
|
-
const handleClose = () => {
|
|
47
|
-
setAnchorEl(null);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const toggleWrap = () => {
|
|
51
|
-
setWrap((prev) => !prev);
|
|
52
|
-
};
|
|
53
43
|
|
|
54
44
|
const handleHover = (event: React.MouseEvent<HTMLElement>) => {
|
|
55
45
|
setAnchorEl((prev) => (prev ? null : event.currentTarget));
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect } from "react";
|
|
2
2
|
import {
|
|
3
3
|
ChangeLayoutIcon,
|
|
4
|
-
SearchIcon,
|
|
5
4
|
SortingIcon,
|
|
6
|
-
|
|
5
|
+
FilterationIcon,
|
|
7
6
|
HideColumnIcon,
|
|
8
7
|
} from "../../assets/svg";
|
|
9
8
|
import { Popover } from "@mui/material";
|
|
@@ -18,9 +17,11 @@ import SortPopover from "../sorting-modal.tsx";
|
|
|
18
17
|
import ColumnToggle from "../column-visibility-modal/index.tsx";
|
|
19
18
|
import { CraftTableOptionsProps } from "../../types/table-options.ts";
|
|
20
19
|
import TableSearch from "../search/index.tsx";
|
|
20
|
+
import FilterDrawer from "../filter/index.tsx";
|
|
21
21
|
|
|
22
22
|
interface TopbarProps<T> {
|
|
23
23
|
table: Table<T>;
|
|
24
|
+
isFullscreen: boolean;
|
|
24
25
|
fullscreenToggle: () => void;
|
|
25
26
|
isCompactTable: boolean;
|
|
26
27
|
setIsCompactTable: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -28,7 +29,7 @@ interface TopbarProps<T> {
|
|
|
28
29
|
topbarOptions?: TopbarOptionsProps;
|
|
29
30
|
columnOrder?: string[];
|
|
30
31
|
setColumnOrder?: React.Dispatch<React.SetStateAction<string[]>>;
|
|
31
|
-
tableStates
|
|
32
|
+
tableStates: CraftTableOptionsProps;
|
|
32
33
|
searchValue?: string;
|
|
33
34
|
onSearchChange?: (val: string) => void;
|
|
34
35
|
}
|
|
@@ -36,15 +37,14 @@ interface TopbarProps<T> {
|
|
|
36
37
|
function Topbar<T>({
|
|
37
38
|
table,
|
|
38
39
|
isCompactTable,
|
|
40
|
+
isFullscreen,
|
|
39
41
|
fullscreenToggle,
|
|
40
42
|
setIsCompactTable,
|
|
41
43
|
paginationComponent,
|
|
42
44
|
topbarOptions,
|
|
43
|
-
|
|
44
|
-
onSearchChange,
|
|
45
|
+
tableStates,
|
|
45
46
|
}: TopbarProps<T>) {
|
|
46
|
-
const [
|
|
47
|
-
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
47
|
+
const [isFullscreenState, setIsFullscreenState] = useState(isFullscreen);
|
|
48
48
|
const [sortAnchorEl, setSortAnchorEl] = useState<HTMLElement | null>(null);
|
|
49
49
|
const [groupBy, setGroupBy] = useState<string>("None");
|
|
50
50
|
|
|
@@ -60,7 +60,12 @@ function Topbar<T>({
|
|
|
60
60
|
table.getAllLeafColumns().map((col) => col.id)
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
//
|
|
63
|
+
//Filter
|
|
64
|
+
const [showFilterInput, setShowFilterInput] = useState(false);
|
|
65
|
+
|
|
66
|
+
// search
|
|
67
|
+
const [showSearchInput, setShowSearchInput] = useState(false);
|
|
68
|
+
const searchContainerRef = useRef<HTMLDivElement>(null);
|
|
64
69
|
|
|
65
70
|
// sync column order with table instance
|
|
66
71
|
useEffect(() => {
|
|
@@ -73,9 +78,22 @@ function Topbar<T>({
|
|
|
73
78
|
showColumnToggle,
|
|
74
79
|
showChangeLayoutToggle,
|
|
75
80
|
viewMoreToggle,
|
|
81
|
+
showSortingToggle,
|
|
82
|
+
showFilterToggle,
|
|
76
83
|
showSearch,
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
searchValue,
|
|
85
|
+
onSearchChange,
|
|
86
|
+
filterOptions = {
|
|
87
|
+
columnsData: {
|
|
88
|
+
column_list: [],
|
|
89
|
+
operation_list: {},
|
|
90
|
+
saved_filter: [],
|
|
91
|
+
},
|
|
92
|
+
onDeleteFilter: () => {},
|
|
93
|
+
onSaveFilter: () => {},
|
|
94
|
+
dropdownData: [],
|
|
95
|
+
onUpdateFilter: () => {},
|
|
96
|
+
},
|
|
79
97
|
} = topbarOptions ?? {};
|
|
80
98
|
|
|
81
99
|
const { container: fullscreenContainer } = useFullscreenPopoverContainer();
|
|
@@ -95,15 +113,15 @@ function Topbar<T>({
|
|
|
95
113
|
setLayoutAnchorEl(null);
|
|
96
114
|
};
|
|
97
115
|
|
|
98
|
-
// search
|
|
99
|
-
const [showSearchInput, setShowSearchInput] = useState(false);
|
|
100
|
-
const searchContainerRef = useRef<HTMLDivElement>(null);
|
|
101
|
-
|
|
102
116
|
useOutsideClick({
|
|
103
117
|
ref: searchContainerRef,
|
|
104
118
|
handler: () => setShowSearchInput(false),
|
|
105
119
|
});
|
|
106
120
|
|
|
121
|
+
const handleFilterDrawer = () => {
|
|
122
|
+
setShowFilterInput((prev) => !prev);
|
|
123
|
+
};
|
|
124
|
+
|
|
107
125
|
return (
|
|
108
126
|
<div className="ts-topbar">
|
|
109
127
|
<div className="tabs-section">{leftSideComponent}</div>
|
|
@@ -112,18 +130,13 @@ function Topbar<T>({
|
|
|
112
130
|
{rightSideComponent}
|
|
113
131
|
{paginationComponent}
|
|
114
132
|
|
|
115
|
-
{/* {showSearch && (
|
|
116
|
-
<div className="search ts--button" title="Search">
|
|
117
|
-
<SearchIcon />
|
|
118
|
-
|
|
119
|
-
</div>
|
|
120
|
-
)} */}
|
|
121
|
-
|
|
122
133
|
{showSearch && (
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
<div title="Search">
|
|
135
|
+
<TableSearch
|
|
136
|
+
value={searchValue ?? ""}
|
|
137
|
+
onChange={onSearchChange ?? (() => {})}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
127
140
|
)}
|
|
128
141
|
|
|
129
142
|
{showChangeLayoutToggle && (
|
|
@@ -176,7 +189,7 @@ function Topbar<T>({
|
|
|
176
189
|
</>
|
|
177
190
|
)}
|
|
178
191
|
|
|
179
|
-
{
|
|
192
|
+
{showSortingToggle && (
|
|
180
193
|
<>
|
|
181
194
|
<div
|
|
182
195
|
className="filter ts--button"
|
|
@@ -197,28 +210,41 @@ function Topbar<T>({
|
|
|
197
210
|
</>
|
|
198
211
|
)}
|
|
199
212
|
|
|
200
|
-
{
|
|
201
|
-
<div
|
|
202
|
-
|
|
213
|
+
{showFilterToggle && (
|
|
214
|
+
<div
|
|
215
|
+
className="filter ts--button"
|
|
216
|
+
title="Filter"
|
|
217
|
+
onClick={() => setShowFilterInput(true)}
|
|
218
|
+
>
|
|
219
|
+
<FilterationIcon />
|
|
220
|
+
<FilterDrawer
|
|
221
|
+
tableStates={tableStates}
|
|
222
|
+
open={showFilterInput}
|
|
223
|
+
onClose={handleFilterDrawer}
|
|
224
|
+
onDeleteFilter={filterOptions?.onDeleteFilter}
|
|
225
|
+
columnsData={filterOptions.columnsData} // @ts-ignore
|
|
226
|
+
onSaveFilter={filterOptions?.onSaveFilter}
|
|
227
|
+
dropdownData={filterOptions.dropdownData}
|
|
228
|
+
onUpdateFilter={filterOptions?.onUpdateFilter}
|
|
229
|
+
/>
|
|
203
230
|
</div>
|
|
204
231
|
)}
|
|
205
232
|
|
|
206
233
|
{viewMoreToggle && (
|
|
207
234
|
<div className="view-more ts--button" title="View More">
|
|
208
235
|
<ViewMore
|
|
209
|
-
wrapCell={wrapCell}
|
|
210
|
-
onWrapCellToggle={() => setWrapCell((prev) => !prev)}
|
|
211
236
|
compactMode={isCompactTable}
|
|
212
237
|
onCompactToggle={(value: string) =>
|
|
213
238
|
setIsCompactTable(value === "Compact")
|
|
214
239
|
}
|
|
215
|
-
isFullscreen={
|
|
240
|
+
isFullscreen={isFullscreenState}
|
|
216
241
|
onFullscreenToggle={() => {
|
|
217
242
|
fullscreenToggle();
|
|
218
|
-
|
|
243
|
+
setIsFullscreenState((prev) => !prev);
|
|
219
244
|
}}
|
|
220
245
|
groupBy={groupBy}
|
|
221
246
|
onGroupByChange={(value: string) => setGroupBy(value)}
|
|
247
|
+
tableStates={tableStates}
|
|
222
248
|
/>
|
|
223
249
|
</div>
|
|
224
250
|
)}
|
|
@@ -10,28 +10,26 @@ import {
|
|
|
10
10
|
} from "@mui/material";
|
|
11
11
|
import { CloseIcon, ViewMoreIcon } from "../../assets/svg";
|
|
12
12
|
import { useFullscreenPopoverContainer } from "../../libs/hooks/useFullScreen";
|
|
13
|
+
import { CraftTableOptionsProps } from "../../types/table-options";
|
|
13
14
|
|
|
14
15
|
interface ViewMorePopoverProps {
|
|
15
|
-
wrapCell: boolean;
|
|
16
|
-
onWrapCellToggle: () => void;
|
|
17
16
|
compactMode: boolean;
|
|
18
17
|
onCompactToggle: (value: string) => void;
|
|
19
18
|
isFullscreen: boolean;
|
|
20
19
|
onFullscreenToggle: () => void;
|
|
21
20
|
groupBy: string;
|
|
22
21
|
onGroupByChange: (value: string) => void;
|
|
23
|
-
|
|
22
|
+
tableStates: CraftTableOptionsProps;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
const ViewMore = ({
|
|
27
|
-
wrapCell,
|
|
28
|
-
onWrapCellToggle,
|
|
29
26
|
compactMode,
|
|
30
27
|
onCompactToggle,
|
|
31
28
|
isFullscreen,
|
|
32
29
|
onFullscreenToggle,
|
|
33
|
-
groupBy,
|
|
34
|
-
onGroupByChange,
|
|
30
|
+
// groupBy,
|
|
31
|
+
// onGroupByChange,
|
|
32
|
+
tableStates,
|
|
35
33
|
}: ViewMorePopoverProps) => {
|
|
36
34
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
37
35
|
|
|
@@ -46,16 +44,13 @@ const ViewMore = ({
|
|
|
46
44
|
setAnchorEl(null);
|
|
47
45
|
};
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
const { wrapColumns, setWrapColumns } = tableStates;
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// globalWrapColumns !== null
|
|
57
|
-
// ? globalWrapColumns
|
|
58
|
-
// : !!wrapColumns[cell.column.id];
|
|
49
|
+
const onWrapCellToggle = () => {
|
|
50
|
+
setWrapColumns((prev: Record<string, boolean>) => ({
|
|
51
|
+
all_wrap: !prev["all_wrap"],
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
59
54
|
|
|
60
55
|
return (
|
|
61
56
|
<>
|
|
@@ -112,7 +107,10 @@ const ViewMore = ({
|
|
|
112
107
|
<Typography fontSize="14px" fontWeight={400} color="#000000DE">
|
|
113
108
|
Wrap Cell
|
|
114
109
|
</Typography>
|
|
115
|
-
<MUISwitch
|
|
110
|
+
<MUISwitch
|
|
111
|
+
checked={wrapColumns?.all_wrap || false}
|
|
112
|
+
onChange={onWrapCellToggle}
|
|
113
|
+
/>
|
|
116
114
|
</Box>
|
|
117
115
|
|
|
118
116
|
{/* List View */}
|
|
@@ -135,6 +133,15 @@ const ViewMore = ({
|
|
|
135
133
|
color: "#000",
|
|
136
134
|
fontSize: "13px",
|
|
137
135
|
}}
|
|
136
|
+
MenuProps={{
|
|
137
|
+
container: fullscreenContainer,
|
|
138
|
+
disablePortal: false,
|
|
139
|
+
PaperProps: {
|
|
140
|
+
style: {
|
|
141
|
+
zIndex: 1500,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
}}
|
|
138
145
|
>
|
|
139
146
|
<MenuItem value="Comfy">Comfy</MenuItem>
|
|
140
147
|
<MenuItem value="Compact">Compact</MenuItem>
|
|
@@ -161,6 +168,15 @@ const ViewMore = ({
|
|
|
161
168
|
color: "#000",
|
|
162
169
|
fontSize: "13px",
|
|
163
170
|
}}
|
|
171
|
+
MenuProps={{
|
|
172
|
+
container: fullscreenContainer,
|
|
173
|
+
disablePortal: false,
|
|
174
|
+
PaperProps: {
|
|
175
|
+
style: {
|
|
176
|
+
zIndex: 1500,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
}}
|
|
164
180
|
>
|
|
165
181
|
<MenuItem value="None">None</MenuItem>
|
|
166
182
|
<MenuItem value="Status">Status</MenuItem>
|
|
@@ -6,6 +6,11 @@ import {
|
|
|
6
6
|
} from "@tanstack/react-table";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { CraftTableOptionsProps } from "../../types/table-options";
|
|
9
|
+
import {
|
|
10
|
+
FilterMasterStateProps,
|
|
11
|
+
FilterOperationListProps,
|
|
12
|
+
FilterStateProps,
|
|
13
|
+
} from "../../types/filter";
|
|
9
14
|
|
|
10
15
|
export function useCraftTable(paginationPageSize: number = 25) {
|
|
11
16
|
const [pagination, setPagination] = useState<PaginationState>({
|
|
@@ -15,10 +20,23 @@ export function useCraftTable(paginationPageSize: number = 25) {
|
|
|
15
20
|
const [sorting, setSorting] = useState<SortingState>([]);
|
|
16
21
|
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
|
17
22
|
const [expanded, setExpanded] = useState<ExpandedState>({});
|
|
18
|
-
const [wrapColumns, setWrapColumns] = useState<Record<string, boolean>>({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
const [wrapColumns, setWrapColumns] = useState<Record<string, boolean>>({
|
|
24
|
+
all_wrap: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Filters to be rendered in form
|
|
28
|
+
const [filters, setFilters] = useState<FilterStateProps[]>([]);
|
|
29
|
+
// Saved filter Component - savedFilterEditValue is set on list click
|
|
30
|
+
const [savedFilterEditValue, setSavedFilterEditValue] = useState<
|
|
31
|
+
string | number
|
|
32
|
+
>("");
|
|
33
|
+
const [filterToDelete, setFilterToDelete] =
|
|
34
|
+
useState<FilterOperationListProps | null>(null);
|
|
35
|
+
const [filterSelectedAttributeValue, setFilterSelectedAttributeValue] =
|
|
36
|
+
useState<string>("");
|
|
37
|
+
|
|
38
|
+
const [filterMaster, setFilterMaster] =
|
|
39
|
+
useState<FilterMasterStateProps | null>(null);
|
|
22
40
|
|
|
23
41
|
if (pagination.pageIndex < 0 || pagination.pageSize <= 0) {
|
|
24
42
|
throw new Error(
|
|
@@ -37,8 +55,16 @@ export function useCraftTable(paginationPageSize: number = 25) {
|
|
|
37
55
|
setExpanded: setExpanded,
|
|
38
56
|
wrapColumns: wrapColumns,
|
|
39
57
|
setWrapColumns: setWrapColumns,
|
|
40
|
-
|
|
41
|
-
|
|
58
|
+
filters: filters,
|
|
59
|
+
setFilters: setFilters,
|
|
60
|
+
savedFilterEditValue: savedFilterEditValue,
|
|
61
|
+
setSavedFilterEditValue: setSavedFilterEditValue,
|
|
62
|
+
filterToDelete: filterToDelete,
|
|
63
|
+
setFilterToDelete: setFilterToDelete,
|
|
64
|
+
filterSelectedAttributeValue: filterSelectedAttributeValue,
|
|
65
|
+
setFilterSelectedAttributeValue: setFilterSelectedAttributeValue,
|
|
66
|
+
filterMaster: filterMaster,
|
|
67
|
+
setFilterMaster: setFilterMaster,
|
|
42
68
|
};
|
|
43
69
|
|
|
44
70
|
return craftTableOptions;
|
|
@@ -11,7 +11,7 @@ export const useDefaultColumns = () => {
|
|
|
11
11
|
header: "First Name",
|
|
12
12
|
id: "firstName",
|
|
13
13
|
accessorKey: "firstName",
|
|
14
|
-
|
|
14
|
+
meta: { label: "First Name" },
|
|
15
15
|
// header: ({ table }) => (
|
|
16
16
|
// <>
|
|
17
17
|
// <button
|
|
@@ -26,11 +26,12 @@ export const useDefaultColumns = () => {
|
|
|
26
26
|
// ),
|
|
27
27
|
cell: ({ row, getValue }) => {
|
|
28
28
|
return (
|
|
29
|
-
<div
|
|
29
|
+
<div
|
|
30
|
+
style={{ paddingLeft: `${row.depth * 2}rem`, display: "flex" }}
|
|
31
|
+
>
|
|
30
32
|
{row.getCanExpand() ? (
|
|
31
33
|
<button
|
|
32
34
|
style={{
|
|
33
|
-
// marginRight: "0.8rem",
|
|
34
35
|
cursor: "pointer",
|
|
35
36
|
background: "none",
|
|
36
37
|
border: "none",
|
|
@@ -48,7 +49,7 @@ export const useDefaultColumns = () => {
|
|
|
48
49
|
) : (
|
|
49
50
|
<span style={{ marginRight: "0.8rem" }}></span>
|
|
50
51
|
)}
|
|
51
|
-
{getValue<boolean>()}
|
|
52
|
+
<span style={{ marginTop: "0.2rem" }}>{getValue<boolean>()}</span>
|
|
52
53
|
</div>
|
|
53
54
|
);
|
|
54
55
|
},
|
|
@@ -57,7 +58,7 @@ export const useDefaultColumns = () => {
|
|
|
57
58
|
header: "Last Name",
|
|
58
59
|
accessorKey: "lastName",
|
|
59
60
|
size: 100,
|
|
60
|
-
meta: {
|
|
61
|
+
meta: { label: "Last Name" },
|
|
61
62
|
},
|
|
62
63
|
{
|
|
63
64
|
header: "Email Id",
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useMutation,
|
|
3
|
+
useQueries,
|
|
4
|
+
useQuery,
|
|
5
|
+
useQueryClient,
|
|
6
|
+
} from "@tanstack/react-query";
|
|
7
|
+
import { api, ENTITY_TYPE } from "../utils/common";
|
|
8
|
+
import {
|
|
9
|
+
APIParamsProps,
|
|
10
|
+
EntityListingResponse,
|
|
11
|
+
EntityTableAPIProps,
|
|
12
|
+
} from "../../types/common";
|
|
13
|
+
import {
|
|
14
|
+
commonGetDropdownDataAPI,
|
|
15
|
+
createSavedFilter,
|
|
16
|
+
deleteSavedFilter,
|
|
17
|
+
updateSavedFilter,
|
|
18
|
+
} from "../utils/apiColumn";
|
|
19
|
+
import { FilterColumnsDataProps } from "../../types/filter";
|
|
20
|
+
|
|
21
|
+
const entityListingCall = async ({
|
|
22
|
+
page,
|
|
23
|
+
size,
|
|
24
|
+
entity_type = ENTITY_TYPE,
|
|
25
|
+
tabs = {
|
|
26
|
+
columnName: "status",
|
|
27
|
+
sortBy: "ASC",
|
|
28
|
+
value: "",
|
|
29
|
+
},
|
|
30
|
+
sortby = [
|
|
31
|
+
{
|
|
32
|
+
sortColum: "name",
|
|
33
|
+
sortType: "ASC",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
sortColum: "status",
|
|
37
|
+
sortType: "DSC",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
quickFilter = [],
|
|
41
|
+
attributeFilter = [],
|
|
42
|
+
}: EntityTableAPIProps): Promise<{
|
|
43
|
+
responseStatus: number;
|
|
44
|
+
data: EntityListingResponse;
|
|
45
|
+
}> => {
|
|
46
|
+
const url = `filter`;
|
|
47
|
+
|
|
48
|
+
const body = {
|
|
49
|
+
entity_type,
|
|
50
|
+
tabs,
|
|
51
|
+
sortby,
|
|
52
|
+
quickFilter,
|
|
53
|
+
attributeFilter,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const params: APIParamsProps = {
|
|
57
|
+
page,
|
|
58
|
+
size,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const response = await api.post(url, body, { params });
|
|
62
|
+
|
|
63
|
+
return { responseStatus: response.status, data: response.data };
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const useEntityTableAPI = ({
|
|
67
|
+
page = 0,
|
|
68
|
+
size = 50,
|
|
69
|
+
quickFilter,
|
|
70
|
+
}: EntityTableAPIProps) => {
|
|
71
|
+
const { data, isPending: isTableDataPending } = useQuery({
|
|
72
|
+
queryKey: [page, size, quickFilter],
|
|
73
|
+
queryFn: () =>
|
|
74
|
+
entityListingCall({
|
|
75
|
+
page,
|
|
76
|
+
size,
|
|
77
|
+
quickFilter,
|
|
78
|
+
}),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
tableData: data?.data.data,
|
|
83
|
+
status: data?.responseStatus,
|
|
84
|
+
isTableDataPending,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
//for saved filter API
|
|
89
|
+
export const useSavedFilterAPI = () => {
|
|
90
|
+
const queryClient = useQueryClient();
|
|
91
|
+
const savedMutation = useMutation({
|
|
92
|
+
mutationKey: ["savedFilter"],
|
|
93
|
+
mutationFn: ({
|
|
94
|
+
entity_type,
|
|
95
|
+
payload,
|
|
96
|
+
}: {
|
|
97
|
+
entity_type: string;
|
|
98
|
+
payload: any;
|
|
99
|
+
}) => {
|
|
100
|
+
return createSavedFilter(entity_type, payload);
|
|
101
|
+
},
|
|
102
|
+
onSuccess: () => {
|
|
103
|
+
queryClient.invalidateQueries({ queryKey: ["meta"] });
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return { savedMutation };
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
//for delete filter API
|
|
111
|
+
export const useDeleteFilterAPI = () => {
|
|
112
|
+
const queryClient = useQueryClient();
|
|
113
|
+
const deleteMutation = useMutation({
|
|
114
|
+
mutationKey: ["deleteFilter"],
|
|
115
|
+
mutationFn: ({
|
|
116
|
+
entity_type,
|
|
117
|
+
payload,
|
|
118
|
+
}: {
|
|
119
|
+
entity_type: string;
|
|
120
|
+
payload: any;
|
|
121
|
+
}) => {
|
|
122
|
+
return deleteSavedFilter(entity_type, payload);
|
|
123
|
+
},
|
|
124
|
+
onSuccess: () => {
|
|
125
|
+
queryClient.invalidateQueries({ queryKey: ["meta"] });
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return { deleteMutation };
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// for updating saved filter API
|
|
133
|
+
export const useUpdateFilterAPI = () => {
|
|
134
|
+
const queryClient = useQueryClient();
|
|
135
|
+
|
|
136
|
+
const updateMutation = useMutation({
|
|
137
|
+
mutationKey: ["updateFilter"],
|
|
138
|
+
mutationFn: ({
|
|
139
|
+
entity_type,
|
|
140
|
+
payload,
|
|
141
|
+
}: {
|
|
142
|
+
entity_type: string;
|
|
143
|
+
payload: any;
|
|
144
|
+
}) => {
|
|
145
|
+
return updateSavedFilter(entity_type, payload);
|
|
146
|
+
},
|
|
147
|
+
onSuccess: () => {
|
|
148
|
+
queryClient.invalidateQueries({ queryKey: ["meta"] });
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return { updateMutation };
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const useCommonDropdownAPI = (
|
|
156
|
+
metaData?: FilterColumnsDataProps,
|
|
157
|
+
value?: string
|
|
158
|
+
) => {
|
|
159
|
+
// Step 1: Extract all keys and query types
|
|
160
|
+
const dropdownConfigs = (metaData?.column_list || [])
|
|
161
|
+
.filter((col) => col?.datasource_list)
|
|
162
|
+
.map((col) => ({
|
|
163
|
+
key: col.attribute_key,
|
|
164
|
+
dataSourceType: value ?? col.datasource_list ?? "STS",
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
// Step 2: Use useQueries to fetch them all in parallel
|
|
168
|
+
const dropdownResults = useQueries({
|
|
169
|
+
queries: dropdownConfigs.map((cfg) => ({
|
|
170
|
+
queryKey: ["commonDropdown", cfg.dataSourceType],
|
|
171
|
+
queryFn: () => commonGetDropdownDataAPI(cfg.dataSourceType, null),
|
|
172
|
+
enabled: !!cfg.dataSourceType,
|
|
173
|
+
})),
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Step 3: Map results to keys
|
|
177
|
+
const dropdownData: Record<string, any> = {};
|
|
178
|
+
dropdownConfigs.forEach((cfg, idx) => {
|
|
179
|
+
dropdownData[cfg.key] = dropdownResults[idx].data;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
return { dropdownData };
|
|
183
|
+
};
|