Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix position list pagination bugs #571

Merged
merged 11 commits into from
Jan 31, 2024
4 changes: 4 additions & 0 deletions src/components/PositionsList/PositionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const PositionsList: React.FC<IProp> = ({
setPage(initialPage)
}, [])

useEffect(() => {
handleChangePagination(initialPage)
}, [initialPage])

return (
<Grid container direction='column' className={classes.root}>
<Grid
Expand Down
8 changes: 7 additions & 1 deletion src/containers/WrappedPositionsList/WrappedPositionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@selectors/positions'
import { status } from '@selectors/solanaWallet'
import { openWalletSelectorModal } from '@web3/selector'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'

Expand All @@ -34,6 +34,12 @@ export const WrappedPositionsList: React.FC = () => {
dispatch(actions.setLastPage(page))
}

useEffect(() => {
if (lastPage > Math.ceil(list.length / 5)) {
zielvna marked this conversation as resolved.
Show resolved Hide resolved
setLastPage(Math.ceil(list.length / 5))
}
}, [list])

return (
<PositionsList
initialPage={lastPage}
Expand Down
Loading