Skip to content

Commit

Permalink
increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hezronkimutai committed Feb 15, 2020
1 parent 31c8a86 commit f516062
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ export default ({
}) => {
const [pageNo, setPageNo] = useState(0)

const pages = data ? Paginate(data, itemsPerPage) : []
const pages = data.length && Paginate(data, itemsPerPage)

const allPages = pages.map((item, index) => index)
const allPages = data.length && pages.map((item, index) => index)

const allPageNumbers =
pageNo < Math.round(pageButtons / 2)
const allPageNumbers =data.length &&
(pageNo < Math.round(pageButtons / 2)
? allPages.slice(0, pageButtons)
: allPages.slice(
pageNo - Math.round(pageButtons / 2),
pageNo + Math.round(pageButtons / 2)
)
))
return (
<div className="pagination-container">
{(pages[pageNo] || pages[0]).map((item, index) => onePage(item, index))}
{data.length && (pages[pageNo] || pages[0]).map((item, index) => onePage(item, index))}
<div className="pagination-buttons">
<div className="arrows">
<button
Expand All @@ -43,7 +43,7 @@ export default ({
</button>
</div>
<div className="pages">
{allPageNumbers.map((item, index) => (
{data.length && allPageNumbers.map((item, index) => (
<div id={index} key={index}>
<button
id='kill'
Expand Down

0 comments on commit f516062

Please sign in to comment.