From 199d52b39fb7a608b92e855456da18c3e9bafe79 Mon Sep 17 00:00:00 2001 From: Rajat Dabade Date: Tue, 23 Jan 2024 16:36:25 +0530 Subject: [PATCH] refactor: added null check while searching for dashboard (#4421) * refactor: added null check while searching for dashboard * refactor: flitering null value out * chore: removed extra space * refactor: remove unnecessary null check --- frontend/src/container/ListOfDashboard/utils.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/container/ListOfDashboard/utils.ts b/frontend/src/container/ListOfDashboard/utils.ts index 199b356581..150aeab6c8 100644 --- a/frontend/src/container/ListOfDashboard/utils.ts +++ b/frontend/src/container/ListOfDashboard/utils.ts @@ -3,16 +3,16 @@ import { Dashboard } from 'types/api/dashboard/getAll'; export const filterDashboard = ( searchValue: string, dashboardList: Dashboard[], -): any[] => { +): Dashboard[] => { // Convert the searchValue to lowercase for case-insensitive search const searchValueLowerCase = searchValue.toLowerCase(); - // Use the filter method to find matching objects return dashboardList.filter((item: Dashboard) => { // Convert each property value to lowercase for case-insensitive search - const itemValues = Object.values(item?.data).map((value) => - value.toString().toLowerCase(), - ); + const itemValues = Object.values(item?.data).map((value) => { + if (value === null || value === undefined) return ''; + return value.toString().toLowerCase(); + }); // Check if any property value contains the searchValue return itemValues.some((value) => value.includes(searchValueLowerCase));