From e4d662521c660325b3cf6655f3aa6058e0a3198a Mon Sep 17 00:00:00 2001 From: zielvna Date: Fri, 26 Jan 2024 12:30:56 +0100 Subject: [PATCH 1/3] fix position list pagination bugs --- src/components/PositionsList/PositionsList.tsx | 4 ++++ .../WrappedPositionsList/WrappedPositionsList.tsx | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/PositionsList/PositionsList.tsx b/src/components/PositionsList/PositionsList.tsx index eece6edeb..972431156 100644 --- a/src/components/PositionsList/PositionsList.tsx +++ b/src/components/PositionsList/PositionsList.tsx @@ -70,6 +70,10 @@ export const PositionsList: React.FC = ({ setPage(initialPage) }, []) + useEffect(() => { + handleChangePagination(initialPage) + }, [initialPage]) + return ( { dispatch(actions.setLastPage(page)) } + useEffect(() => { + if (lastPage > Math.ceil(list.length / 5)) { + setLastPage(Math.ceil(list.length / 5)) + } + }, [list]) + return ( Date: Mon, 29 Jan 2024 11:29:55 +0100 Subject: [PATCH 2/3] make pagination reset to page 1 when position list is empty --- src/containers/WrappedPositionsList/WrappedPositionsList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/containers/WrappedPositionsList/WrappedPositionsList.tsx b/src/containers/WrappedPositionsList/WrappedPositionsList.tsx index d522a0b71..840b60115 100644 --- a/src/containers/WrappedPositionsList/WrappedPositionsList.tsx +++ b/src/containers/WrappedPositionsList/WrappedPositionsList.tsx @@ -35,8 +35,8 @@ export const WrappedPositionsList: React.FC = () => { } useEffect(() => { - if (lastPage > Math.ceil(list.length / 5)) { - setLastPage(Math.ceil(list.length / 5)) + if (list.length === 0) { + setLastPage(1) } }, [list]) From 2aa1b95a6bab82fc8bde27644f2ee713c5cf8609 Mon Sep 17 00:00:00 2001 From: zielvna Date: Tue, 30 Jan 2024 18:40:02 +0100 Subject: [PATCH 3/3] fix pagination when removing position --- src/containers/WrappedPositionsList/WrappedPositionsList.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/containers/WrappedPositionsList/WrappedPositionsList.tsx b/src/containers/WrappedPositionsList/WrappedPositionsList.tsx index 840b60115..1455a67c8 100644 --- a/src/containers/WrappedPositionsList/WrappedPositionsList.tsx +++ b/src/containers/WrappedPositionsList/WrappedPositionsList.tsx @@ -38,6 +38,10 @@ export const WrappedPositionsList: React.FC = () => { if (list.length === 0) { setLastPage(1) } + + if (lastPage > Math.ceil(list.length / 5)) { + setLastPage(lastPage - 1) + } }, [list]) return (