From 4decaae3c24b7b0d2beda2a6f2b0ce8cdd605f2c Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Mon, 11 Nov 2024 13:16:42 +0530 Subject: [PATCH] Issue bug:Add no data found according to changed userlist api response --- src/components/UserTable.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index b9c3f7fa..399872b4 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -897,8 +897,11 @@ console.log(code[0]) resp = await userList({ limit, filters, sort, offset, fields }); } - console.log(resp?.getUserDetails); - const result = enableCenterFilter?resp?.userDetails:resp?.getUserDetails; + if (!resp?.getUserDetails) { + setData([]); + //showToastMessage("No data found", "info"); + } + const result = enableCenterFilter?resp?.userDetails:resp?.getUserDetails; console.log(result) console.log(resp?.totalCount) if (resp?.totalCount >= 15) { @@ -1029,7 +1032,7 @@ console.log(code[0]) } console.log(finalResult) - if (filters?.name) { + if (filters?.name && resp?.getUserDetails) { const prioritizedResult = finalResult.sort((a: any, b: any) => { const aStartsWith = a.name.toLowerCase().startsWith(filters?.name); const bStartsWith = b.name.toLowerCase().startsWith(filters?.name); @@ -1040,9 +1043,14 @@ console.log(code[0]) }); setData(prioritizedResult); - } else { + } else if (resp?.getUserDetails){ setData(finalResult); } + else + { + setData([]); + + } setLoading(false); setCohortsFetched(false); @@ -1508,6 +1516,9 @@ console.log(selectedBlockStore) ); + + + console.log("data-----------------------------", data) const userProps = { userType: userType, searchPlaceHolder: searchPlaceholder,