rez-table-listing-mui 1.0.47 → 1.0.49
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 +2 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/App.tsx +25 -13
- package/src/components/filter/components/forms/components/Date.tsx +68 -108
- package/src/components/filter/components/forms/components/Filter-criteria.tsx +13 -5
- package/src/components/filter/components/forms/index.tsx +10 -6
- package/src/components/filter/components/main-filter.tsx +3 -0
- package/src/components/filter/components/saved-edit-filter.tsx +6 -0
- package/src/components/filter/components/saved-filter.tsx +3 -0
- package/src/components/filter/components/search/index.tsx +18 -1
- package/src/components/filter/index.tsx +18 -3
- package/src/components/table-settings/common/listing-values.tsx +60 -27
- package/src/components/table-settings/components/column.tsx +2 -9
- package/src/components/table-settings/components/quick-tab.tsx +4 -0
- package/src/components/table-settings/components/sorting.tsx +0 -11
- package/src/libs/hooks/useCraftTable.tsx +5 -0
- package/src/libs/hooks/useElementWidth.tsx +28 -0
- package/src/libs/hooks/useEntityTableAPI.tsx +1 -1
- package/src/libs/utils/apiColumn.ts +8 -7
- package/src/libs/utils/common.ts +1 -1
- package/src/types/table-options.ts +2 -0
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -31,7 +31,7 @@ function App() {
|
|
|
31
31
|
const [columns, setColumns] = useState<any[]>([]);
|
|
32
32
|
const [searchTerm, setSearchTerm] = useState("");
|
|
33
33
|
// const [data, setData] = useState<Person[]>(() => makeData(50, 3, 2));
|
|
34
|
-
// const [entity_type] = useState(ENTITY_TYPE); //OR UPR
|
|
34
|
+
// const [entity_type] = useState(ENTITY_TYPE); //OR UPR AYR
|
|
35
35
|
|
|
36
36
|
const [selectedTab, setSelectedTab] = useState("ALL");
|
|
37
37
|
|
|
@@ -45,7 +45,7 @@ function App() {
|
|
|
45
45
|
|
|
46
46
|
const { defaultColumns } = useDefaultColumns();
|
|
47
47
|
|
|
48
|
-
const { metaQuery } = useFetchData("
|
|
48
|
+
const { metaQuery } = useFetchData("AYR");
|
|
49
49
|
const { detailsQuery } = useDetailsQueryAPI(
|
|
50
50
|
filterMaster?.saved_filters?.selectedId
|
|
51
51
|
? filterMaster?.saved_filters?.selectedId
|
|
@@ -55,16 +55,16 @@ function App() {
|
|
|
55
55
|
const { savedMutation } = useSavedFilterAPI(); //API CALL FOR SAVED FILTER
|
|
56
56
|
const { deleteMutation } = useDeleteFilterAPI(); //API FOR DELETING FILTER
|
|
57
57
|
const { updateMutation } = useUpdateFilterAPI(); //API FOR UPDATE FILTER
|
|
58
|
-
const { saveSettingsDataMutation } = useSaveSettingsDataAPI("
|
|
58
|
+
const { saveSettingsDataMutation } = useSaveSettingsDataAPI("AYR");
|
|
59
59
|
const { dropdownData } = useCommonDropdownAPI(metaQuery.data);
|
|
60
60
|
const { settingsTabDropdownData, settingsTabDropdownPending } =
|
|
61
61
|
useSettingsDropDownAPI({
|
|
62
|
-
entity_type: "
|
|
62
|
+
entity_type: "AYR",
|
|
63
63
|
column: filterSettingStates?.quickTabStates?.attribute,
|
|
64
64
|
sort_by: filterSettingStates?.quickTabStates?.sorting,
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
const { getSettingsAPIData } = useGetSettingsDataAPI("
|
|
67
|
+
const { getSettingsAPIData } = useGetSettingsDataAPI("AYR");
|
|
68
68
|
|
|
69
69
|
useEffect(() => {
|
|
70
70
|
// setTimeout(() => {
|
|
@@ -73,7 +73,7 @@ function App() {
|
|
|
73
73
|
|
|
74
74
|
const fetchMeta = async () => {
|
|
75
75
|
try {
|
|
76
|
-
const { res: allColumns } = await entityTableMetaMaster("
|
|
76
|
+
const { res: allColumns } = await entityTableMetaMaster("AYR");
|
|
77
77
|
|
|
78
78
|
const savedColumnSettings = filterSettingStates.settingsData?.column;
|
|
79
79
|
|
|
@@ -91,10 +91,22 @@ function App() {
|
|
|
91
91
|
const visibleColumns = new Set(
|
|
92
92
|
activeTabSettings.show_list.map((c) => c.value)
|
|
93
93
|
);
|
|
94
|
-
|
|
94
|
+
|
|
95
|
+
// First, filter columns based on visibleColumns
|
|
96
|
+
const filteredColumns = allColumns.filter((col: any) =>
|
|
95
97
|
visibleColumns.has(col.accessorKey)
|
|
96
98
|
);
|
|
97
|
-
|
|
99
|
+
|
|
100
|
+
// Then, order the filtered columns based on the sequence in show_list
|
|
101
|
+
const orderedColumns = activeTabSettings.show_list
|
|
102
|
+
.map((showItem) =>
|
|
103
|
+
filteredColumns.find(
|
|
104
|
+
(col: any) => col.accessorKey === showItem.value
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
.filter((col: any) => col !== undefined); // To ensure we filter out any undefined columns
|
|
108
|
+
|
|
109
|
+
setColumns(orderedColumns);
|
|
98
110
|
} else {
|
|
99
111
|
// Fallback if no specific settings for the active tab are found
|
|
100
112
|
setColumns(allColumns);
|
|
@@ -134,7 +146,7 @@ function App() {
|
|
|
134
146
|
const { tableData } = useEntityTableAPI({
|
|
135
147
|
page: 0,
|
|
136
148
|
size: 50,
|
|
137
|
-
entity_type: "
|
|
149
|
+
entity_type: "AYR",
|
|
138
150
|
tabs: {
|
|
139
151
|
columnName: "status",
|
|
140
152
|
sortBy: "ASC",
|
|
@@ -213,7 +225,7 @@ function App() {
|
|
|
213
225
|
const payload = {
|
|
214
226
|
name,
|
|
215
227
|
is_default: false,
|
|
216
|
-
mapped_entity_type: "
|
|
228
|
+
mapped_entity_type: "AYR", // For that entity type
|
|
217
229
|
status: "ACTIVE",
|
|
218
230
|
entity_type: "SFM", // FIXED entity type
|
|
219
231
|
filterDetails: quickFilter,
|
|
@@ -237,7 +249,7 @@ function App() {
|
|
|
237
249
|
name: filterToDelete?.label,
|
|
238
250
|
id: filterToDelete?.value,
|
|
239
251
|
is_default: false,
|
|
240
|
-
mapped_entity_type: "
|
|
252
|
+
mapped_entity_type: "AYR",
|
|
241
253
|
status: "INACTIVE",
|
|
242
254
|
entity_type: "SFM",
|
|
243
255
|
};
|
|
@@ -257,7 +269,7 @@ function App() {
|
|
|
257
269
|
name: filterMaster?.saved_filters?.selectedName, // Name of the filter
|
|
258
270
|
is_default: false,
|
|
259
271
|
id: filterMaster?.saved_filters?.selectedId,
|
|
260
|
-
mapped_entity_type: "
|
|
272
|
+
mapped_entity_type: "AYR",
|
|
261
273
|
status: "ACTIVE",
|
|
262
274
|
entity_type: "SFM",
|
|
263
275
|
filterDetails: quickFilter,
|
|
@@ -269,7 +281,7 @@ function App() {
|
|
|
269
281
|
const handleSaveSettingsData = (settingsData: SettingsDataProps) => {
|
|
270
282
|
const payload = {
|
|
271
283
|
entity_type: "LAP",
|
|
272
|
-
mapped_entity_type: "
|
|
284
|
+
mapped_entity_type: "AYR",
|
|
273
285
|
layout_json: settingsData,
|
|
274
286
|
};
|
|
275
287
|
|
|
@@ -18,121 +18,81 @@ const FormDatePicker = ({
|
|
|
18
18
|
filter,
|
|
19
19
|
control,
|
|
20
20
|
sx,
|
|
21
|
-
views = ["day", "month", "year"],
|
|
21
|
+
views = ["day", "month", "year"],
|
|
22
22
|
onValueChange,
|
|
23
23
|
}: FormDatePickerProps) => {
|
|
24
24
|
return (
|
|
25
25
|
<Controller
|
|
26
|
-
name={`${filter?.name}.value`}
|
|
26
|
+
name={`${filter?.name}.value`}
|
|
27
27
|
control={control}
|
|
28
|
-
defaultValue={
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
28
|
+
defaultValue={filter.filter_value || ""}
|
|
29
|
+
render={({ field }) => {
|
|
30
|
+
const isYearOnly = views.length === 1 && views[0] === "year";
|
|
31
|
+
// Convert string year (e.g., "2025") to Date for DatePicker, or null if empty
|
|
32
|
+
const displayValue = isYearOnly
|
|
33
|
+
? field.value
|
|
34
|
+
? new Date(Number(field.value), 0, 1)
|
|
35
|
+
: null
|
|
36
|
+
: field.value
|
|
37
|
+
? moment(field.value, "DD-MM-YYYY").toDate()
|
|
38
|
+
: null;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
42
|
+
<DatePicker
|
|
43
|
+
views={views}
|
|
44
|
+
value={displayValue}
|
|
45
|
+
onChange={(date) => {
|
|
46
|
+
// Handle picker selection or typed input
|
|
47
|
+
const formatted = date
|
|
48
|
+
? isYearOnly
|
|
49
|
+
? moment(date).format("YYYY")
|
|
50
|
+
: moment(date).format("DD-MM-YYYY")
|
|
51
|
+
: "";
|
|
52
|
+
field.onChange(formatted);
|
|
53
|
+
onValueChange?.();
|
|
54
|
+
}}
|
|
55
|
+
format={isYearOnly ? "yyyy" : "dd-MM-yyyy"}
|
|
56
|
+
sx={{
|
|
57
|
+
"& .MuiOutlinedInput-input": {
|
|
58
|
+
padding: "8.5px 14px",
|
|
59
|
+
fontSize: "14px",
|
|
60
|
+
color: "#000",
|
|
61
|
+
},
|
|
62
|
+
"& .MuiInputBase-root": {
|
|
63
|
+
bgcolor: "white",
|
|
64
|
+
},
|
|
65
|
+
...sx,
|
|
66
|
+
}}
|
|
67
|
+
slotProps={{
|
|
68
|
+
textField: {
|
|
69
|
+
size: "small",
|
|
70
|
+
fullWidth: true,
|
|
71
|
+
placeholder: isYearOnly ? "YYYY" : "DD-MM-YYYY",
|
|
72
|
+
inputProps: isYearOnly
|
|
73
|
+
? {
|
|
74
|
+
maxLength: 4, // Limit to 4 digits
|
|
75
|
+
inputMode: "numeric", // Optimize for numeric input
|
|
76
|
+
pattern: "[0-9]*", // Restrict to numbers
|
|
77
|
+
}
|
|
78
|
+
: undefined,
|
|
79
|
+
onBlur: () => {
|
|
80
|
+
if (isYearOnly) {
|
|
81
|
+
const value = field.value;
|
|
82
|
+
if (value && !/^\d{4}$/.test(value)) {
|
|
83
|
+
field.onChange("");
|
|
84
|
+
onValueChange?.();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</LocalizationProvider>
|
|
92
|
+
);
|
|
93
|
+
}}
|
|
75
94
|
/>
|
|
76
95
|
);
|
|
77
96
|
};
|
|
78
97
|
|
|
79
98
|
export default FormDatePicker;
|
|
80
|
-
|
|
81
|
-
// import { Controller } from "react-hook-form";
|
|
82
|
-
// import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
|
83
|
-
// import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
84
|
-
// import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
|
|
85
|
-
// import moment from "moment";
|
|
86
|
-
// import { UpdatedFilterStateProps } from "../../../../../types/filter";
|
|
87
|
-
// import { SxProps, Theme } from "@mui/material";
|
|
88
|
-
|
|
89
|
-
// const FormDatePicker = ({
|
|
90
|
-
// filter,
|
|
91
|
-
// control,
|
|
92
|
-
// sx,
|
|
93
|
-
// }: {
|
|
94
|
-
// filter: UpdatedFilterStateProps;
|
|
95
|
-
// control: any;
|
|
96
|
-
// sx?: SxProps<Theme>;
|
|
97
|
-
// }) => {
|
|
98
|
-
// return (
|
|
99
|
-
// <Controller
|
|
100
|
-
// name={`${filter?.name}.value`} // or use a consistent structure like `filters.${index}.filter_value`
|
|
101
|
-
// control={control}
|
|
102
|
-
// defaultValue={
|
|
103
|
-
// filter.filter_value
|
|
104
|
-
// ? moment(filter.filter_value, "DD-MM-YYYY").toDate()
|
|
105
|
-
// : null
|
|
106
|
-
// }
|
|
107
|
-
// render={({ field }) => (
|
|
108
|
-
// <LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
109
|
-
// <DatePicker
|
|
110
|
-
// sx={{
|
|
111
|
-
// "& .MuiOutlinedInput-input": {
|
|
112
|
-
// padding: "12px 20px",
|
|
113
|
-
// },
|
|
114
|
-
// }}
|
|
115
|
-
// {...field}
|
|
116
|
-
// value={
|
|
117
|
-
// field.value ? moment(field.value, "DD-MM-YYYY").toDate() : null
|
|
118
|
-
// }
|
|
119
|
-
// onChange={(date) => {
|
|
120
|
-
// const formatted = date ? moment(date).format("DD-MM-YYYY") : "";
|
|
121
|
-
// field.onChange(formatted);
|
|
122
|
-
// }}
|
|
123
|
-
// format="dd-MM-yyyy"
|
|
124
|
-
// slotProps={{
|
|
125
|
-
// textField: {
|
|
126
|
-
// size: "small",
|
|
127
|
-
// fullWidth: true,
|
|
128
|
-
// placeholder: "DD-MM-YYYY",
|
|
129
|
-
// },
|
|
130
|
-
// }}
|
|
131
|
-
// />
|
|
132
|
-
// </LocalizationProvider>
|
|
133
|
-
// )}
|
|
134
|
-
// />
|
|
135
|
-
// );
|
|
136
|
-
// };
|
|
137
|
-
|
|
138
|
-
// export default FormDatePicker;
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { CraftTableOptionsProps } from "../../../../../types/table-options";
|
|
18
18
|
import CustomSearch from "../../search";
|
|
19
19
|
import { filterStyles } from "../../../style";
|
|
20
|
+
import useElementWidth from "../../../../../libs/hooks/useElementWidth";
|
|
20
21
|
|
|
21
22
|
const FilterCriteria = ({
|
|
22
23
|
columnsData,
|
|
@@ -44,10 +45,13 @@ const FilterCriteria = ({
|
|
|
44
45
|
},
|
|
45
46
|
}));
|
|
46
47
|
|
|
47
|
-
const
|
|
48
|
-
|
|
48
|
+
const { filters, setFilters, showFilterOptions, setShowFilterOption } =
|
|
49
|
+
tableStates;
|
|
50
|
+
|
|
49
51
|
const filterButtonRef = useRef<HTMLButtonElement>(null);
|
|
50
52
|
|
|
53
|
+
const filterButtonWidth = useElementWidth(filterButtonRef);
|
|
54
|
+
|
|
51
55
|
const handleAddFilter = (column: FilterColumnsListProps) => {
|
|
52
56
|
const dropdownOptions = columnsData.operation_list[column.data_type];
|
|
53
57
|
|
|
@@ -110,7 +114,7 @@ const FilterCriteria = ({
|
|
|
110
114
|
{showFilterOptions && (
|
|
111
115
|
<Paper
|
|
112
116
|
sx={{
|
|
113
|
-
width:
|
|
117
|
+
width: filterButtonWidth || 360, // Dynamic width based on button
|
|
114
118
|
p: 1,
|
|
115
119
|
mt: 2,
|
|
116
120
|
cursor: "pointer",
|
|
@@ -141,8 +145,12 @@ const FilterCriteria = ({
|
|
|
141
145
|
}}
|
|
142
146
|
>
|
|
143
147
|
{columnsData?.column_list
|
|
144
|
-
?.filter(
|
|
145
|
-
column
|
|
148
|
+
?.filter(
|
|
149
|
+
(column) =>
|
|
150
|
+
column.name.toLowerCase() !== "action" && // Exclude Action column in filter criteria options
|
|
151
|
+
column.name
|
|
152
|
+
.toLowerCase()
|
|
153
|
+
.includes(searchTerm.toLowerCase())
|
|
146
154
|
)
|
|
147
155
|
.map((column, index) => {
|
|
148
156
|
const isAlreadySelected = filters?.some(
|
|
@@ -41,6 +41,8 @@ const FilterForm = ({
|
|
|
41
41
|
dropdownData,
|
|
42
42
|
searchTerm = "",
|
|
43
43
|
setSearchTerm,
|
|
44
|
+
criteriaSearchTerm = "",
|
|
45
|
+
setCriteriaSearchTerm,
|
|
44
46
|
selectedFilters,
|
|
45
47
|
setSelectedFilters,
|
|
46
48
|
handleRemoveFilter,
|
|
@@ -53,6 +55,8 @@ const FilterForm = ({
|
|
|
53
55
|
dropdownData: FilterDropdownDataProps;
|
|
54
56
|
searchTerm?: string;
|
|
55
57
|
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
58
|
+
criteriaSearchTerm?: string;
|
|
59
|
+
setCriteriaSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
56
60
|
selectedFilters: UpdatedFilterStateProps[];
|
|
57
61
|
setSelectedFilters: React.Dispatch<
|
|
58
62
|
React.SetStateAction<UpdatedFilterStateProps[]>
|
|
@@ -91,7 +95,7 @@ const FilterForm = ({
|
|
|
91
95
|
control,
|
|
92
96
|
watch,
|
|
93
97
|
reset,
|
|
94
|
-
formState: { isDirty },
|
|
98
|
+
// formState: { isDirty },
|
|
95
99
|
setValue,
|
|
96
100
|
unregister,
|
|
97
101
|
} = useForm<FormValues & { dummyChange: string }>({
|
|
@@ -107,7 +111,7 @@ const FilterForm = ({
|
|
|
107
111
|
|
|
108
112
|
useEffect(() => {
|
|
109
113
|
reset(defaultValues);
|
|
110
|
-
}, [selectedFilters
|
|
114
|
+
}, [selectedFilters]);
|
|
111
115
|
|
|
112
116
|
const debouncedUpdateFilters = useCallback(
|
|
113
117
|
customDebounce((updatedFilters: UpdatedFilterStateProps[]) => {
|
|
@@ -231,8 +235,8 @@ const FilterForm = ({
|
|
|
231
235
|
columnsData={columnsData}
|
|
232
236
|
tableStates={tableStates}
|
|
233
237
|
setSelectedFilters={setSelectedFilters}
|
|
234
|
-
searchTerm={
|
|
235
|
-
setSearchTerm={
|
|
238
|
+
searchTerm={criteriaSearchTerm}
|
|
239
|
+
setSearchTerm={setCriteriaSearchTerm}
|
|
236
240
|
/>
|
|
237
241
|
|
|
238
242
|
{!editMode && (
|
|
@@ -315,7 +319,7 @@ const FilterForm = ({
|
|
|
315
319
|
onValueChange={updateFiltersFromForm}
|
|
316
320
|
/>
|
|
317
321
|
) : filter.data_type === "select" ? (
|
|
318
|
-
<
|
|
322
|
+
<FormMultiSelect
|
|
319
323
|
filter={filter}
|
|
320
324
|
control={control}
|
|
321
325
|
dropdownData={dropdownData}
|
|
@@ -362,7 +366,7 @@ const FilterForm = ({
|
|
|
362
366
|
<Button
|
|
363
367
|
variant="contained"
|
|
364
368
|
fullWidth
|
|
365
|
-
disabled={!isDirty && editMode}
|
|
369
|
+
// disabled={!isDirty && editMode}
|
|
366
370
|
sx={{
|
|
367
371
|
color: "white",
|
|
368
372
|
backgroundColor: "#7A5AF8",
|
|
@@ -16,6 +16,7 @@ const MainFilter = ({
|
|
|
16
16
|
setSavedFilterModalOpen,
|
|
17
17
|
}: FilterFormComponentProps) => {
|
|
18
18
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
19
|
+
const [criteriaSearchTerm, setCriteriaSearchTerm] = useState<string>("");
|
|
19
20
|
|
|
20
21
|
const { setFilters, setFilterMaster } = tableStates;
|
|
21
22
|
|
|
@@ -52,6 +53,8 @@ const MainFilter = ({
|
|
|
52
53
|
columnsData={columnsData}
|
|
53
54
|
searchTerm={searchTerm}
|
|
54
55
|
setSearchTerm={setSearchTerm}
|
|
56
|
+
criteriaSearchTerm={criteriaSearchTerm}
|
|
57
|
+
setCriteriaSearchTerm={setCriteriaSearchTerm}
|
|
55
58
|
selectedFilters={selectedFilters}
|
|
56
59
|
setSelectedFilters={setSelectedFilters}
|
|
57
60
|
handleRemoveFilter={handleRemoveFilter}
|
|
@@ -19,6 +19,8 @@ const SavedFilterEditComponent = ({
|
|
|
19
19
|
setEditMode,
|
|
20
20
|
searchTerm,
|
|
21
21
|
setSearchTerm,
|
|
22
|
+
criteriaSearchTerm,
|
|
23
|
+
setCriteriaSearchTerm,
|
|
22
24
|
setSavedFilterModalOpen,
|
|
23
25
|
setDeleteFilterModalOpen,
|
|
24
26
|
}: {
|
|
@@ -33,6 +35,8 @@ const SavedFilterEditComponent = ({
|
|
|
33
35
|
setEditMode?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
34
36
|
searchTerm?: string;
|
|
35
37
|
setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
38
|
+
criteriaSearchTerm?: string;
|
|
39
|
+
setCriteriaSearchTerm: React.Dispatch<React.SetStateAction<string>>;
|
|
36
40
|
setSavedFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
37
41
|
setDeleteFilterModalOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
38
42
|
}) => {
|
|
@@ -95,6 +99,8 @@ const SavedFilterEditComponent = ({
|
|
|
95
99
|
dropdownData={dropdownData}
|
|
96
100
|
searchTerm={searchTerm}
|
|
97
101
|
setSearchTerm={setSearchTerm}
|
|
102
|
+
criteriaSearchTerm={criteriaSearchTerm}
|
|
103
|
+
setCriteriaSearchTerm={setCriteriaSearchTerm}
|
|
98
104
|
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
99
105
|
setDeleteFilterModalOpen={setDeleteFilterModalOpen}
|
|
100
106
|
/>
|
|
@@ -31,6 +31,7 @@ const SavedFilter = ({
|
|
|
31
31
|
}: FilterFormComponentProps) => {
|
|
32
32
|
const { setFilterMaster, setFilterToDelete } = tableStates;
|
|
33
33
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
34
|
+
const [criteriaSearchTerm, setCriteriaSearchTerm] = useState<string>("");
|
|
34
35
|
|
|
35
36
|
// reset savedFilterEditValue when component unmounts
|
|
36
37
|
useEffect(() => {
|
|
@@ -149,6 +150,8 @@ const SavedFilter = ({
|
|
|
149
150
|
setEditMode={setEditMode}
|
|
150
151
|
searchTerm={searchTerm}
|
|
151
152
|
setSearchTerm={setSearchTerm}
|
|
153
|
+
criteriaSearchTerm={criteriaSearchTerm}
|
|
154
|
+
setCriteriaSearchTerm={setCriteriaSearchTerm}
|
|
152
155
|
setSavedFilterModalOpen={setSavedFilterModalOpen}
|
|
153
156
|
setDeleteFilterModalOpen={setDeleteFilterModalOpen}
|
|
154
157
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { TextField, InputAdornment } from "@mui/material";
|
|
2
|
+
import { TextField, InputAdornment, IconButton } from "@mui/material";
|
|
3
3
|
import SearchIcon from "@mui/icons-material/Search";
|
|
4
|
+
import { CloseIcon } from "../../../../assets/svg";
|
|
4
5
|
|
|
5
6
|
interface SearchInputProps {
|
|
6
7
|
value: string;
|
|
@@ -22,6 +23,11 @@ const CustomSearch = ({
|
|
|
22
23
|
onChange?.(val);
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
const handleClear = () => {
|
|
27
|
+
setSearch(""); // Clear the search value
|
|
28
|
+
onChange?.(""); // Propagate the cleared value
|
|
29
|
+
};
|
|
30
|
+
|
|
25
31
|
return (
|
|
26
32
|
<TextField
|
|
27
33
|
fullWidth
|
|
@@ -39,6 +45,17 @@ const CustomSearch = ({
|
|
|
39
45
|
/>
|
|
40
46
|
</InputAdornment>
|
|
41
47
|
),
|
|
48
|
+
endAdornment: search && ( // Show the clear icon only when there's a value
|
|
49
|
+
<InputAdornment position="end">
|
|
50
|
+
<IconButton
|
|
51
|
+
edge="end"
|
|
52
|
+
onClick={handleClear}
|
|
53
|
+
sx={{ color: "#888888", fontSize: "20px" }}
|
|
54
|
+
>
|
|
55
|
+
<CloseIcon />
|
|
56
|
+
</IconButton>
|
|
57
|
+
</InputAdornment>
|
|
58
|
+
),
|
|
42
59
|
}}
|
|
43
60
|
sx={{
|
|
44
61
|
"& .MuiOutlinedInput-root": {
|
|
@@ -36,8 +36,14 @@ export function TableFilter({
|
|
|
36
36
|
|
|
37
37
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
|
38
38
|
|
|
39
|
-
const {
|
|
40
|
-
|
|
39
|
+
const {
|
|
40
|
+
filters,
|
|
41
|
+
setFilters,
|
|
42
|
+
filterToDelete,
|
|
43
|
+
filterMaster,
|
|
44
|
+
setFilterMaster,
|
|
45
|
+
setShowFilterOption,
|
|
46
|
+
} = tableStates;
|
|
41
47
|
|
|
42
48
|
const filterNameInput: InputField = {
|
|
43
49
|
label: "Filter Name",
|
|
@@ -137,6 +143,7 @@ export function TableFilter({
|
|
|
137
143
|
onClick={(e) => {
|
|
138
144
|
e.stopPropagation();
|
|
139
145
|
onClose && onClose();
|
|
146
|
+
setShowFilterOption(false);
|
|
140
147
|
}}
|
|
141
148
|
aria-label="close"
|
|
142
149
|
>
|
|
@@ -256,11 +263,19 @@ export function TableFilter({
|
|
|
256
263
|
},
|
|
257
264
|
{
|
|
258
265
|
label: "Delete",
|
|
259
|
-
|
|
260
266
|
onClick: () => {
|
|
261
267
|
onDeleteFilter && onDeleteFilter();
|
|
262
268
|
setDeleteFilterModalOpen(false);
|
|
263
269
|
setEditMode && setEditMode(false);
|
|
270
|
+
setSelectedFilters([]);
|
|
271
|
+
setFilters([]);
|
|
272
|
+
setFilterMaster(
|
|
273
|
+
(prev) =>
|
|
274
|
+
({
|
|
275
|
+
...prev,
|
|
276
|
+
activeFilterTabIndex: -1,
|
|
277
|
+
} as FilterMasterStateProps)
|
|
278
|
+
);
|
|
264
279
|
},
|
|
265
280
|
variant: "contained",
|
|
266
281
|
sx: {
|