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 { Link } from 'react-router-dom';
import { Pagination, PaginationItem, PaginationLink } from 'reactstrap'; import { Pagination, PaginationItem, PaginationLink } from 'reactstrap';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { range } from 'ramda';
const propTypes = { const propTypes = {
serverId: PropTypes.string.isRequired, serverId: PropTypes.string.isRequired,
@ -18,24 +19,17 @@ export default function Paginator({ paginator = {}, serverId }) {
return null; return null;
} }
const renderPages = () => { const renderPages = () =>
const pages = []; range(1, pagesCount + 1).map((i) => (
<PaginationItem key={i} active={currentPage === i}>
for (let i = 1; i <= pagesCount; i++) { <PaginationLink
pages.push( tag={Link}
<PaginationItem key={i} active={currentPage === i}> to={`/server/${serverId}/list-short-urls/${i}`}
<PaginationLink >
tag={Link} {i}
to={`/server/${serverId}/list-short-urls/${i}`} </PaginationLink>
> </PaginationItem>
{i} ));
</PaginationLink>
</PaginationItem>
);
}
return pages;
};
return ( return (
<Pagination listClassName="flex-wrap"> <Pagination listClassName="flex-wrap">