From eabff7cd396d1f37ceb929e666f082ce57f07919 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 2 Feb 2018 15:23:20 -0500 Subject: updateS --- frontend/components/Pagination.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'frontend/components/Pagination.js') diff --git a/frontend/components/Pagination.js b/frontend/components/Pagination.js index dedd231..28785be 100644 --- a/frontend/components/Pagination.js +++ b/frontend/components/Pagination.js @@ -1,17 +1,19 @@ -import React, { Component } from 'react'; -import { graphql, gql, compose } from 'react-apollo'; -import { ALL_ITEMS_QUERY } from '../queries'; -import withData from '../lib/withData'; -import { Link } from '../routes'; +import React, { Component } from "react"; +import { graphql, gql, compose } from "react-apollo"; +import { ALL_ITEMS_QUERY } from "../queries"; +import withData from "../lib/withData"; +import { Link } from "../routes"; +import { itemEnhancer } from "../enhancers/enhancers"; const Pagination = props => { const { loading, error } = props.allItemsQuery; if (loading) return

Loading Item...

; - const meta = props.allItemsQuery._allItemsMeta; + const { aggregate, pageInfo } = props.allItemsQuery.itemsConnection; + const { page } = props; - const pages = Math.floor(meta.count / 3); + const pages = Math.floor(aggregate.count / 3); return (

@@ -19,17 +21,16 @@ const Pagination = props => { of {pages} - - {meta.count} + {aggregate.count} total

- - {page > 1 ? ( + {pageInfo.hasPreviousPage ? ( ←Prev ) : null} - {page < pages ? ( + {pageInfo.hasNextPage ? ( Next → @@ -38,6 +39,6 @@ const Pagination = props => { ); }; -const ComponentWithMutations = compose(graphql(ALL_ITEMS_QUERY, { name: 'allItemsQuery' }))(Pagination); +const ComponentWithMutations = compose(itemEnhancer)(Pagination); export default ComponentWithMutations; -- cgit v1.3