diff --git a/src/components/projects/ListProjects.jsx b/src/components/projects/ListProjects.jsx index 734bb35..581e8cd 100644 --- a/src/components/projects/ListProjects.jsx +++ b/src/components/projects/ListProjects.jsx @@ -1,9 +1,10 @@ -import React, { Fragment, useContext } from 'react' +import React, { Fragment, useContext, useState } from 'react' import useWindowSize from '@rehooks/window-size' import { Link } from 'react-router-dom' import Typography from '@material-ui/core/Typography' import Divider from '@material-ui/core/Divider' import Fab from '@material-ui/core/Fab' +import Button from '@material-ui/core/Button' import AddIcon from '@material-ui/icons/Add' import classnames from 'classnames' import { useQuery } from '@apollo/react-hooks' @@ -119,8 +120,17 @@ function TableCards({ profiles, classes }) { function ListProjects() { const classes = useStyles() + const [offset, setOffset] = useState(2) const windowSize = useWindowSize() - const { loading, error, data } = useQuery(getProjects) + const { loading, error, data, fetchMore } = useQuery( + getProjects, + { + variables: { + offset: 0, + limit: 5 + } + } + ) if (loading) return if (error) return
{`Error! ${error.message}`}
const { profiles } = data @@ -128,6 +138,7 @@ 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 (
@@ -142,6 +153,21 @@ function ListProjects() { {!isSmall && } {!isSmall ? : } + diff --git a/src/components/projects/queries.js b/src/components/projects/queries.js index 0e3f745..5d1a9a9 100644 --- a/src/components/projects/queries.js +++ b/src/components/projects/queries.js @@ -51,8 +51,8 @@ query Profile($id: ID!) { export const getProjects = gql` ${pledgesInfosFields} -query Projects($type: String! = "PROJECT"){ - profiles(where: {type: $type, projectInfo_not: null}) { +query Projects($type: String! = "PROJECT", $limit: Int, $offset: Int){ + profiles(where: {type: $type, projectInfo_not: null}, first: $limit, skip: $offset) { id addr canceled