From c741b64d46e51a5678706b07741bc51fea2e7df8 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Thu, 19 Sep 2019 07:02:44 -0400 Subject: [PATCH] add previous button for pagination --- src/components/projects/ListProjects.jsx | 29 ++++++++++++++----- .../projects/styles/ListProjects.js | 6 ++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/components/projects/ListProjects.jsx b/src/components/projects/ListProjects.jsx index 581e8cd..0ef5d15 100644 --- a/src/components/projects/ListProjects.jsx +++ b/src/components/projects/ListProjects.jsx @@ -118,15 +118,16 @@ function TableCards({ profiles, classes }) { ) } +const OFFSET = 5 function ListProjects() { const classes = useStyles() - const [offset, setOffset] = useState(2) + const [offset, setOffset] = useState(0) const windowSize = useWindowSize() const { loading, error, data, fetchMore } = useQuery( getProjects, { variables: { - offset: 0, + offset, limit: 5 } } @@ -138,7 +139,6 @@ function ListProjects() { const isSmall = innerWidth < 800 const fabStyle = isSmall ? classnames(classes.fabLink, classes.fabSmall) : classes.fabLink const titleStyle = isSmall ? classes.tableTitleSmall : classes.tableTitle - console.log({data}) return (
@@ -153,21 +153,34 @@ function ListProjects() { {!isSmall && } {!isSmall ? : } - + setOffset(offset-offset) + }} className={classnames(classes.previousButton, classes.blue)}>{'< Previous'}} + {profiles.length === OFFSET && } diff --git a/src/components/projects/styles/ListProjects.js b/src/components/projects/styles/ListProjects.js index 2eb2b45..ee102c4 100644 --- a/src/components/projects/styles/ListProjects.js +++ b/src/components/projects/styles/ListProjects.js @@ -147,6 +147,12 @@ const useStyles = makeStyles(theme => ({ dateCreated: { gridColumn: '40 / 44' }, + previousButton: { + gridColumn: '3 / 9' + }, + nextButton: { + gridColumn: '42 / 48' + }, readMore: { gridColumn: '44 / 48', fontSize: '0.94rem',