From f71bded5e76fd603d9c3560f8d48d8af3a8ec302 Mon Sep 17 00:00:00 2001 From: MazurakIhor <131388095+MazurakIhor@users.noreply.github.com> Date: Fri, 13 Oct 2023 19:57:54 +0300 Subject: [PATCH] Corrected calculation of total pages so that 'Prev' and 'Next' buttons are disabled when table contains less than 10 rows. (#611) --- src/components/molecules/leaderboard/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/molecules/leaderboard/index.tsx b/src/components/molecules/leaderboard/index.tsx index 77af764e..9cb055f0 100644 --- a/src/components/molecules/leaderboard/index.tsx +++ b/src/components/molecules/leaderboard/index.tsx @@ -25,7 +25,7 @@ const Leaderboard: React.FC = ({ userId, list, isLoading, onLoad }) => { const [pageNumber, setPageNumber] = useState(1); const maxUsers = list[0]?.ranking.total; - const maxPage = maxUsers / PAGE_SIZE; + const maxPage = Math.ceil(maxUsers / PAGE_SIZE); const onSort = (val: LeaderboardColumn) => { // if click on current column ? change direction : set default direction