mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-24 16:53:45 +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 { 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">
|
||||||
|
|
Loading…
Add table
Reference in a new issue