From f02a5dc73ac4a14c1d641a6ddbfcd2f1bd2ea0b5 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Wed, 2 May 2018 14:45:20 -0400 Subject: TESTS --- frontend/components/Nav.js | 21 +++++++++------------ frontend/components/Pagination.js | 3 ++- frontend/components/PleaseSignIn.js | 5 +++-- frontend/components/RemoveFromCart.js | 4 +++- 4 files changed, 17 insertions(+), 16 deletions(-) (limited to 'frontend/components') diff --git a/frontend/components/Nav.js b/frontend/components/Nav.js index acfdfd1..1e39762 100644 --- a/frontend/components/Nav.js +++ b/frontend/components/Nav.js @@ -2,12 +2,12 @@ import React, { Fragment } from 'react'; import Link from 'next/link'; import styled from 'styled-components'; import { Query } from 'react-apollo'; -import { CURRENT_USER_QUERY, LOCAL_STATE_QUERY } from '../queries/queries'; +import { CURRENT_USER_QUERY } from '../queries/queries'; import CartCount from './CartCount'; import Signout from './Signout'; import { ApolloConsumer } from 'react-apollo'; -const StyledUl = styled.ul` +const StyledNav = styled.ul` margin: 0; padding: 0; display: flex; @@ -69,23 +69,20 @@ const StyledUl = styled.ul` `; class Nav extends React.Component { - componentDidMount() { - console.log('NAV MOUNTED'); - } render() { return ( - - {({ data: { me }, refetch }) => ( - - + + {({ data: { me } }) => ( + + Shop - + Sell {!me && ( - + Sign In )} @@ -112,7 +109,7 @@ class Nav extends React.Component { )} - + )} ); diff --git a/frontend/components/Pagination.js b/frontend/components/Pagination.js index 53ad36f..39de901 100644 --- a/frontend/components/Pagination.js +++ b/frontend/components/Pagination.js @@ -4,7 +4,7 @@ import styled from 'styled-components'; import Link from 'next/link'; import PropTypes from 'prop-types'; import { perPage } from '../config'; -import { ALL_ITEMS_QUERY, ITEM_COUNT_QUERY } from '../queries/queries'; +import { ALL_ITEMS_QUERY } from '../queries/queries'; const PaginationStyles = styled.div` text-align: center; @@ -33,6 +33,7 @@ const PaginationStyles = styled.div` const Pagination = props => ( {({ data, loading, error }) => { + console.log(error); if (loading) return null; const { aggregate } = data.itemsConnection; const { page } = props; diff --git a/frontend/components/PleaseSignIn.js b/frontend/components/PleaseSignIn.js index 4a2eabe..6be17cb 100644 --- a/frontend/components/PleaseSignIn.js +++ b/frontend/components/PleaseSignIn.js @@ -5,7 +5,8 @@ import Dump from './Dump'; const PleaseSignIn = props => ( - {({ data }) => { + {({ data, loading }) => { + if (loading) return

Loading...

; // check if they are signed in if (!data.me) { return ( @@ -24,7 +25,7 @@ const PleaseSignIn = props => ( ) { return (

- Insufficient Permissions to Manage Permissions. You have: + Insufficient Permissions. You have: {data.me.permissions} and you need {props.allowedPermissions.join(' OR ')} diff --git a/frontend/components/RemoveFromCart.js b/frontend/components/RemoveFromCart.js index 9cd3a07..fee423b 100644 --- a/frontend/components/RemoveFromCart.js +++ b/frontend/components/RemoveFromCart.js @@ -21,6 +21,7 @@ class RemoveFromCart extends Component { update = (proxy, payload) => { const data = proxy.readQuery({ query: CURRENT_USER_QUERY }); + console.log(data); const cartItemId = payload.data.removeFromCart.id; data.me.cart = data.me.cart.filter(item => item.id !== cartItemId); proxy.writeQuery({ query: CURRENT_USER_QUERY, data }); @@ -32,7 +33,8 @@ class RemoveFromCart extends Component { mutation={REMOVE_FROM_CART_MUTATION} variables={{ id: this.props.id }} update={this.update} - refetchQueries={[{ query: CURRENT_USER_QUERY }]} + // TODO - we should be able to remove this because we remove the item above + // refetchQueries={[{ query: CURRENT_USER_QUERY }]} > {removeFromCart => ( -- cgit v1.3