Skip to content

Commit 678bd87

Browse files
fixed filters
1 parent 620b215 commit 678bd87

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

src/ui/layouts/common/Table/index.tsx

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,14 @@ export const Table: React.FC<TableProps> = ({
164164
// itemsPerPage: itemPerPage,
165165
// items: tableRows,
166166
// });
167-
const isValidFilter = filters?.map((f) => f.value).join('');
167+
const validFilters = filters?.filter((item) => item.value);
168+
console.log('checkFilter', validFilters, filters);
169+
170+
const isValidFilterFroValue: any = filters?.map((f) => f.value).join('');
171+
const isValidFilterForCategory: any = filters
172+
?.map((f) => f.value && f.type.value)
173+
.join('');
174+
const checkValidFilter = isValidFilterFroValue + isValidFilterForCategory;
168175

169176
const { dispatchStackData } = callActionForStacksForPagination();
170177
const {
@@ -187,7 +194,7 @@ export const Table: React.FC<TableProps> = ({
187194
componentName === 'components'
188195
? locationPath.pathname.split('/')[5]
189196
: locationPath.pathname.split('/')[4];
190-
// console.log(check, '333');
197+
const checkForLocationPath = locationPath.pathname.split('/')[4];
191198
useEffect(() => {
192199
// console.log(locationPath.pathname.split('/')[4], 'locationPath1');
193200
setItemPerPage(itemPerPage);
@@ -201,12 +208,17 @@ export const Table: React.FC<TableProps> = ({
201208
id,
202209
1,
203210
itemPerPage,
204-
filters as any,
211+
checkValidFilter.length ? (validFilters as any) : [],
205212
activeSorting,
206213
);
207214
break;
208215
} else {
209-
dispatchStackData(1, itemPerPage, filters as any, activeSorting);
216+
dispatchStackData(
217+
1,
218+
itemPerPage,
219+
checkValidFilter.length ? (validFilters as any) : [],
220+
activeSorting,
221+
);
210222
break;
211223
}
212224
case 'components':
@@ -215,15 +227,15 @@ export const Table: React.FC<TableProps> = ({
215227
id,
216228
1,
217229
itemPerPage,
218-
filters as any,
230+
checkValidFilter.length ? (validFilters as any) : [],
219231
activeSorting,
220232
);
221233
break;
222234
} else {
223235
dispatchStackComponentsData(
224236
1,
225237
itemPerPage,
226-
filters as any,
238+
checkValidFilter.length ? (validFilters as any) : [],
227239
activeSorting,
228240
);
229241
break;
@@ -234,19 +246,29 @@ export const Table: React.FC<TableProps> = ({
234246
id,
235247
1,
236248
itemPerPage,
237-
filters as any,
249+
checkValidFilter.length ? (validFilters as any) : [],
238250
activeSorting,
239251
);
240252
break;
241253
} else {
242-
console.log(itemPerPage, 'itemPerPage');
254+
// console.log(checkValidFilter, 'checkValidFilter');
243255
if (!renderAfterRow) break;
244-
dispatchPipelineData(1, itemPerPage, filters as any, activeSorting);
256+
dispatchPipelineData(
257+
1,
258+
itemPerPage,
259+
checkValidFilter.length ? (validFilters as any) : [],
260+
activeSorting,
261+
);
245262
break;
246263
}
247264

248265
case 'all-runs':
249-
dispatchAllrunsData(1, itemPerPage, filters as any, activeSorting);
266+
dispatchAllrunsData(
267+
1,
268+
itemPerPage,
269+
checkValidFilter.length ? (validFilters as any) : [],
270+
activeSorting,
271+
);
250272
break;
251273

252274
default:
@@ -267,7 +289,7 @@ export const Table: React.FC<TableProps> = ({
267289
}
268290

269291
// eslint-disable-next-line react-hooks/exhaustive-deps
270-
}, [locationPath.pathname.split('/')[4], isValidFilter, activeSorting]);
292+
}, [checkForLocationPath, checkValidFilter, activeSorting]);
271293
let rowsToDisplay = tableRows;
272294

273295
// function getFetchedState(state: any) {
@@ -472,7 +494,7 @@ export const Table: React.FC<TableProps> = ({
472494
ref={childRef}
473495
// getFetchedState={getFetchedState}
474496
activeSorting={activeSorting}
475-
filters={filters}
497+
filters={validFilters}
476498
itemPerPage={itemPerPage}
477499
pageIndex={pageIndex}
478500
setPageIndex={setPageIndex}
@@ -553,7 +575,7 @@ export const Table: React.FC<TableProps> = ({
553575
childRef?.current?.callOnChange(
554576
1,
555577
parseInt(`${option}`),
556-
filters,
578+
validFilters,
557579
activeSorting,
558580
);
559581
setShowItems(false);

0 commit comments

Comments
 (0)