mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-08 17:27:32 +03:00
Simplified Paginator component
This commit is contained in:
parent
6c8e13ebde
commit
9b668f3365
1 changed files with 12 additions and 18 deletions
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||
import { Link } from 'react-router-dom';
|
||||
import { Pagination, PaginationItem, PaginationLink } from 'reactstrap';
|
||||
import PropTypes from 'prop-types';
|
||||
import { range } from 'ramda';
|
||||
|
||||
const propTypes = {
|
||||
serverId: PropTypes.string.isRequired,
|
||||
|
@ -18,24 +19,17 @@ export default function Paginator({ paginator = {}, serverId }) {
|
|||
return null;
|
||||
}
|
||||
|
||||
const renderPages = () => {
|
||||
const pages = [];
|
||||
|
||||
for (let i = 1; i <= pagesCount; i++) {
|
||||
pages.push(
|
||||
<PaginationItem key={i} active={currentPage === i}>
|
||||
<PaginationLink
|
||||
tag={Link}
|
||||
to={`/server/${serverId}/list-short-urls/${i}`}
|
||||
>
|
||||
{i}
|
||||
</PaginationLink>
|
||||
</PaginationItem>
|
||||
);
|
||||
}
|
||||
|
||||
return pages;
|
||||
};
|
||||
const renderPages = () =>
|
||||
range(1, pagesCount + 1).map((i) => (
|
||||
<PaginationItem key={i} active={currentPage === i}>
|
||||
<PaginationLink
|
||||
tag={Link}
|
||||
to={`/server/${serverId}/list-short-urls/${i}`}
|
||||
>
|
||||
{i}
|
||||
</PaginationLink>
|
||||
</PaginationItem>
|
||||
));
|
||||
|
||||
return (
|
||||
<Pagination listClassName="flex-wrap">
|
||||
|
|
Loading…
Reference in a new issue