Skip to content

Commit

Permalink
setting next page indexs
Browse files Browse the repository at this point in the history
  • Loading branch information
freddiemixell committed Jul 7, 2019
1 parent 2f45370 commit 135940a
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions public/js/Pagination.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
function Pagination() {
return <p>Pagination Area</p>;
import styled from 'styled-components';

const { Fragment } = wp.element;

const Button = styled.button.attrs(() => ({
type: "button",
}))``;

function Pagination(props) {
let nextIndex = null;
let prevIndex = null;

// Finding Next Page Start Index
if (props.results !== null && typeof props.results.queries.nextPage !== 'undefined') {
nextIndex = props.results.queries.nextPage[0].startIndex;
console.log(nextIndex);
}

// Finding Prev Page Start Index
if (props.results !== null && typeof props.results.queries.previousPage !== 'undefined') {
prevIndex = props.results.queries.previousPage[0].startIndex;
console.log(prevIndex);
}

return (
<Fragment>
{ prevIndex !== null
? <Button>&lt;</Button>
: null
}
{ nextIndex !== null
? <Button>&gt;</Button>
: null
}
</Fragment>
);
}

export default Pagination;

0 comments on commit 135940a

Please sign in to comment.