Skip to content

Commit

Permalink
no items + scroll on other tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiolalombardim committed May 26, 2024
1 parent ccc06d2 commit 12ae5c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/modules/explorer/pages/NFTs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const NFTs: React.FC = () => {
const onCloseTransfer = () => {
setOpenTransfer(false)
}
const value = isMobileSmall ? 6 : 3
const value = isMobileSmall ? 6 : 4
const shouldDisable = useIsProposalButtonDisabled(daoId)

const [currentPage, setCurrentPage] = useState(0)
Expand All @@ -105,6 +105,7 @@ export const NFTs: React.FC = () => {
const newOffset = (event.selected * value) % nftHoldings.length
setOffset(newOffset)
setCurrentPage(event.selected)
window.scrollTo({ top: 0, behavior: "smooth" })
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ const BalancesList: React.FC<TableProps> = ({
}) => {
const [currentPage, setCurrentPage] = useState(0)
const [offset, setOffset] = useState(0)
const value = isMobileSmall ? 6 : 2
const value = isMobileSmall ? 6 : 5
// Invoke when user click to request another page.
const handlePageClick = (event: { selected: number }) => {
if (rows) {
const newOffset = (event.selected * value) % rows.length
setOffset(newOffset)
setCurrentPage(event.selected)
window.scrollTo({ top: 0, behavior: "smooth" })
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,6 @@ const TransfersTableItems: React.FC<{ data: RowData[]; network: Network }> = ({
}

export const TransfersTable: React.FC<{ transfers: TransferWithBN[] }> = ({ transfers }) => {
const theme = useTheme()
const isSmall = useMediaQuery(theme.breakpoints.down("sm"))

const rows = useMemo(() => {
if (!transfers) {
return []
Expand All @@ -332,7 +329,11 @@ export const TransfersTable: React.FC<{ transfers: TransferWithBN[] }> = ({ tran

return (
<TableContainer>
<TransfersTableItems data={rows} network={network} />
{rows && rows.length > 0 ? (
<TransfersTableItems data={rows} network={network} />
) : (
<Typography color="textPrimary">No items</Typography>
)}
</TableContainer>
)
}

0 comments on commit 12ae5c0

Please sign in to comment.