From 9679d2ad1cb0446fa196f59a3189c97a568b0bef Mon Sep 17 00:00:00 2001 From: KunalOfficial Date: Sat, 21 Oct 2023 02:17:21 +0530 Subject: [PATCH] feat(web/dashboard/mycases): Add dynamic total pages calculation In this commit, I've added the logic to calculate the total number of pages dynamically for the "My Cases" section on the dashboard. The total number of cases is now divided by the cases per page to determine the correct number of pages to display. Fixes #1285 --- web/src/pages/Dashboard/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/pages/Dashboard/index.tsx b/web/src/pages/Dashboard/index.tsx index 2684b38cc..8361b4a4c 100644 --- a/web/src/pages/Dashboard/index.tsx +++ b/web/src/pages/Dashboard/index.tsx @@ -54,6 +54,7 @@ const Dashboard: React.FC = () => { ); const { data: userData } = useUserQuery(address, decodedFilter); const totalCases = userData?.user?.disputes.length; + const totalPages = Math.ceil(totalCases / casesPerPage); return ( @@ -66,7 +67,7 @@ const Dashboard: React.FC = () => { disputes={disputesData?.user?.disputes as DisputeDetailsFragment[]} numberDisputes={totalCases} numberClosedDisputes={0} - totalPages={10} + totalPages={totalPages} currentPage={pageNumber} setCurrentPage={(newPage: number) => navigate(`${location}/${newPage}/${order}/${filter}`)} {...{ casesPerPage }}