From 135940a37c2e3c022bc1118c8798c2515cf1fb45 Mon Sep 17 00:00:00 2001 From: freddiemixell Date: Sun, 7 Jul 2019 14:56:27 -0400 Subject: [PATCH] setting next page indexs --- public/js/Pagination.js | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/public/js/Pagination.js b/public/js/Pagination.js index ef7594e..54166ca 100644 --- a/public/js/Pagination.js +++ b/public/js/Pagination.js @@ -1,5 +1,39 @@ -function Pagination() { - return

Pagination Area

; +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 ( + + { prevIndex !== null + ? + : null + } + { nextIndex !== null + ? + : null + } + + ); } export default Pagination;