Simplified Paginator component

This commit is contained in:
Alejandro Celaya 2018-08-25 23:45:03 +02:00
parent 6c8e13ebde
commit 9b668f3365

View file

@ -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">