From b0d25a9ad3cc1df2fcc11ddb84e4603b94520b09 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Mon, 10 Sep 2018 14:29:32 -0400 Subject: almost done --- stepped-solutions/62/frontend/components/Nav.js | 49 ++++++++++++++++ .../62/frontend/components/Pagination.js | 67 ++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100755 stepped-solutions/62/frontend/components/Nav.js create mode 100755 stepped-solutions/62/frontend/components/Pagination.js (limited to 'stepped-solutions/62/frontend/components') diff --git a/stepped-solutions/62/frontend/components/Nav.js b/stepped-solutions/62/frontend/components/Nav.js new file mode 100755 index 0000000..118db5a --- /dev/null +++ b/stepped-solutions/62/frontend/components/Nav.js @@ -0,0 +1,49 @@ +import Link from 'next/link'; +import { Mutation } from 'react-apollo'; +import { TOGGLE_CART_MUTATION } from './Cart'; +import NavStyles from './styles/NavStyles'; +import User from './User'; +import CartCount from './CartCount'; +import Signout from './Signout'; + +const Nav = () => ( + + {({ data: { me } }) => ( + + + Shop + + {me && ( + <> + + Sell + + + Orders + + + Account + + + + {(toggleCart) => ( + + )} + + + )} + {!me && ( + + Sign In + + + )} + + )} + +); + +export default Nav; diff --git a/stepped-solutions/62/frontend/components/Pagination.js b/stepped-solutions/62/frontend/components/Pagination.js new file mode 100755 index 0000000..b84af76 --- /dev/null +++ b/stepped-solutions/62/frontend/components/Pagination.js @@ -0,0 +1,67 @@ +import React from 'react'; +import gql from 'graphql-tag'; +import { Query } from 'react-apollo'; +import Head from 'next/head'; +import Link from 'next/link'; +import PaginationStyles from './styles/PaginationStyles'; +import { perPage } from '../config'; + +const PAGINATION_QUERY = gql` + query PAGINATION_QUERY { + itemsConnection { + aggregate { + count + } + } + } +`; + +const Pagination = props => ( + + {({ data, loading, error }) => { + if (loading) return

Loading...

; + const count = data.itemsConnection.aggregate.count; + const pages = Math.ceil(count / perPage); + const page = props.page; + return ( + + + + Sick Fits! — Page {page} of {pages} + + + + + ← Prev + + +

+ Page {props.page} of + {pages}! +

+

{count} Items Total

+ + = pages}> + Next → + + +
+ ); + }} +
+); + +export default Pagination; +export { PAGINATION_QUERY }; -- cgit v1.3