Skip to content

Commit

Permalink
Merge pull request #1343 from multiversx/mm-add-pagination-items-count
Browse files Browse the repository at this point in the history
Address Table Pagination Count Support
  • Loading branch information
MiroMargineanu authored Dec 9, 2024
2 parents 3a12eed + 751168b commit 818caf9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- [Add pagination item count support to "AddressTable"](https://github.com/multiversx/mx-sdk-dapp/pull/1343)

## [[v3.1.1](https://github.com/multiversx/mx-sdk-dapp/pull/1342)] - 2024-12-09

- [Fix dApp compatibility check (webview provider)](https://github.com/multiversx/mx-sdk-dapp/pull/1341)

## [[v3.1.0](https://github.com/multiversx/mx-sdk-dapp/pull/1339)] - 2024-12-05
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const PaginationComponent = ({
}
}, [currentPage, currentPageIndex]);

if (totalPages === 1) {
if (totalPages <= 1) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { LedgerColumnsEnum } from '../enums';
import { LedgerLoading } from '../LedgerLoading';

const ADDRESSES_PER_PAGE = 10;
const TOTAL_ADDRESSES_PAGES = 500;
const TOTAL_ADDRESSES_COUNT = 5000;

export interface AddressTablePropsType extends WithClassnameType {
accounts: string[];
Expand All @@ -27,6 +27,7 @@ export interface AddressTablePropsType extends WithClassnameType {
ledgerModalTableSelectedItemClassName?: string;
ledgerModalTableNavigationButtonDisabledClassName?: string;
};
addressesCount?: number;
customContentComponent?: ReactNode;
dataTestId?: string;
loading: boolean;
Expand All @@ -42,6 +43,7 @@ export interface AddressTablePropsType extends WithClassnameType {
const AddressTableComponent = ({
accounts,
addressTableClassNames,
addressesCount = TOTAL_ADDRESSES_COUNT,
className = 'dapp-ledger-address-table',
customContentComponent,
dataTestId = DataTestIdsEnum.addressTableContainer,
Expand Down Expand Up @@ -140,6 +142,7 @@ const AddressTableComponent = ({
onGoToSpecificPage(newPage - 1);
};

const totalPages = Math.ceil(addressesCount / ADDRESSES_PER_PAGE);
const columns = [
LedgerColumnsEnum.Address,
LedgerColumnsEnum.Balance,
Expand Down Expand Up @@ -213,7 +216,7 @@ const AddressTableComponent = ({
<Pagination
className={styles?.ledgerAddressTablePagination}
currentPage={startIndex + 1}
totalPages={TOTAL_ADDRESSES_PAGES}
totalPages={totalPages}
onPageChange={handlePageChange}
disabledClassName={ledgerModalTableNavigationButtonDisabledClassName}
buttonsClassNames={ledgerModalTableNavigationButtonClassName}
Expand Down

0 comments on commit 818caf9

Please sign in to comment.