From af29139af3fb8a4b7af0de6b255d1a336e946923 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Mon, 13 Nov 2023 10:24:07 -0300 Subject: [PATCH] fix(StorePage): update totalRowsCount logic to consider filteredCategories length The logic for setting the totalRowsCount in the StorePage component has been updated. Previously, it was only considering the count returned from the API response. Now, it takes into account the length of the filteredCategories array as well. If the filteredCategories array is empty, the totalRowsCount is set to the count returned from the API response. Otherwise, it is set to the length of the results array in the API response. This change ensures that the totalRowsCount accurately reflects the number of rows in the search results, taking into account any applied filters. Also, the condition for rendering the PaginatorComponent has been updated. Previously, it was checking if the loading state is false or the searchData array is not empty. Now, it only checks if the loading state is false and the searchData array is not empty. This change ensures that the PaginatorComponent is only rendered when the loading state is false and there are search results available. --- src/frontend/src/pages/StorePage/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/pages/StorePage/index.tsx b/src/frontend/src/pages/StorePage/index.tsx index 304a025a0..b6c465716 100644 --- a/src/frontend/src/pages/StorePage/index.tsx +++ b/src/frontend/src/pages/StorePage/index.tsx @@ -84,7 +84,11 @@ export default function StorePage(): JSX.Element { .then((res) => { setLoading(false); setSearchData(res?.results ?? []); - setTotalRowsCount(Number(res?.count ?? 0)); + setTotalRowsCount( + filteredCategories?.length === 0 + ? Number(res?.count ?? 0) + : res?.results?.length ?? 0 + ); }) .catch((err) => { setSearchData([]); @@ -291,7 +295,7 @@ export default function StorePage(): JSX.Element { - {(!loading || searchData.length !== 0) && ( + {!loading && searchData.length !== 0 && (