Skip to content

Commit

Permalink
fix position list pagination bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zielvna committed Jan 26, 2024
1 parent a6d3cfb commit e4d6625
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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)) {
setLastPage(Math.ceil(list.length / 5))
}
}, [list])

return (
<PositionsList
initialPage={lastPage}
Expand Down

0 comments on commit e4d6625

Please sign in to comment.