Skip to content

Commit

Permalink
Update pagination of lists on the validator page
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyTripleA committed Oct 16, 2024
1 parent 82d2a12 commit 50045fe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/frontend/src/app/validator/[hash]/Validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,13 @@ function Validator ({ hash }) {
: <ErrorMessageBlock/>
}

{proposedBlocks.data?.resultSet?.length > 0 &&
{proposedBlocks.data?.resultSet &&
<div className={'ValidatorPage__ListPagination'}>
<Pagination
onPageChange={pagination => paginationHandler(setProposedBlocks, pagination.selected)}
pageCount={Math.ceil(proposedBlocks.data?.pagination?.total / pageSize) || 1}
forcePage={currentPage}
pageRangeDisplayed={0}
/>
</div>
}
Expand All @@ -445,13 +446,13 @@ function Validator ({ hash }) {
</div>
: <ErrorMessageBlock/>}

{transactions.data?.resultSet?.length > 0 &&
{transactions.data?.resultSet &&
<div className={'ValidatorPage__ListPagination'}>
<Pagination
className={'ValidatorPage__ListPagination'}
onPageChange={pagination => paginationHandler(setTransactions, pagination.selected)}
pageCount={Math.ceil(transactions.data?.pagination?.total / pageSize) || 1}
forcePage={currentPage}
pageRangeDisplayed={0}
/>
</div>
}
Expand Down
14 changes: 14 additions & 0 deletions packages/frontend/src/app/validator/[hash]/ValidatorPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@

&__ListPagination {
margin-top: 20px;

.PageItem {
&--Previous, &--Next {
display: block;
}

&--Previous {
margin-right: auto;
}

&--Next {
margin-left: auto;
}
}
}

&__List {
Expand Down
12 changes: 9 additions & 3 deletions packages/frontend/src/components/pagination/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ import './Pagination.scss'

import ReactPaginate from 'react-paginate'

function Pagination ({ onPageChange, pageCount, forcePage }) {
function Pagination ({
onPageChange,
pageCount,
forcePage,
pageRangeDisplayed = 2,
marginPagesDisplayed = 1
}) {
pageCount = Math.max(pageCount, 1)

return (
<ReactPaginate
breakLabel={'...'}
nextLabel={'>'}
onPageChange={onPageChange}
pageRangeDisplayed={2}
marginPagesDisplayed={1}
pageRangeDisplayed={pageRangeDisplayed}
marginPagesDisplayed={marginPagesDisplayed}
pageCount={pageCount}
previousLabel={'<'}
pageClassName={'PageItem'}
Expand Down

0 comments on commit 50045fe

Please sign in to comment.