Просмотр исходного кода

Hide pagination when not needed

arvid-e 4 месяцев назад
Родитель
Сommit
5fab149c50
1 измененных файлов с 12 добавлено и 10 удалено
  1. 12 10
      apps/app/src/client/components/RecentActivity/RecentActivity.tsx

+ 12 - 10
apps/app/src/client/components/RecentActivity/RecentActivity.tsx

@@ -55,8 +55,8 @@ export const RecentActivity = (props: RecentActivityProps): JSX.Element => {
     }
   }, [paginatedData, error]);
 
-  const totalPageCount = paginatedData?.totalDocs || 0;
-
+  const totalItemsCount = paginatedData?.totalDocs || 0;
+  const needsPagination = totalItemsCount > limit;
 
   return (
     <div className="page-list-container-activity">
@@ -68,14 +68,16 @@ export const RecentActivity = (props: RecentActivityProps): JSX.Element => {
         ))}
       </ul>
 
-      <PaginationWrapper
-        activePage={activePage}
-        changePage={handlePage}
-        totalItemsCount={totalPageCount}
-        pagingLimit={limit}
-        align="center"
-        size="sm"
-      />
+      {needsPagination && (
+        <PaginationWrapper
+          activePage={activePage}
+          changePage={handlePage}
+          totalItemsCount={totalItemsCount}
+          pagingLimit={limit}
+          align="center"
+          size="sm"
+        />
+      )}
     </div>
   );
 };