diff options
Diffstat (limited to 'frontend/components')
| -rw-r--r-- | frontend/components/Cart.js | 7 | ||||
| -rw-r--r-- | frontend/components/CreateItem.js | 4 | ||||
| -rw-r--r-- | frontend/components/Pagination.js | 8 | ||||
| -rw-r--r-- | frontend/components/ResetRequest.js | 2 |
4 files changed, 10 insertions, 11 deletions
diff --git a/frontend/components/Cart.js b/frontend/components/Cart.js index 26f1015..8d57c33 100644 --- a/frontend/components/Cart.js +++ b/frontend/components/Cart.js @@ -6,6 +6,7 @@ import formatMoney from '../lib/formatMoney'; import CartItem from './CartItem'; import { CURRENT_USER_QUERY, LOCAL_STATE_QUERY, TOGGLE_CART_MUTATION } from '../queries/queries'; import calcTotalPrice from '../lib/calcTotalPrice'; +import Error from './ErrorMessage'; const CartStyles = styled.div` padding: 20px; @@ -78,9 +79,11 @@ const Cart = props => ( {toggle => ( <Query query={LOCAL_STATE_QUERY}> {({ data }) => ( - <Query query={CURRENT_USER_QUERY}> + <Query query={CURRENT_USER_QUERY} data-test="cart"> {({ data: { me }, error, loading }) => { - if (loading || error || !me) return null; + if (loading) return <p>Loading...</p>; + if (error) return <Error error={error} />; + if (!me) return <p>Please Sign In!</p>; return ( <CartStyles open={data.cartOpen}> <header> diff --git a/frontend/components/CreateItem.js b/frontend/components/CreateItem.js index 3dd929f..2aabb5b 100644 --- a/frontend/components/CreateItem.js +++ b/frontend/components/CreateItem.js @@ -48,8 +48,8 @@ class CreateItem extends Component { <Mutation mutation={CREATE_ITEM_MUTATION} variables={this.state} - // TODO - update all items - // refetchQueries={[{ query: ALL_ITEMS_QUERY }]} + // TODO - update all items + // refetchQueries={[{ query: ALL_ITEMS_QUERY }]} > {(createItem, { loading, error }) => ( <Form diff --git a/frontend/components/Pagination.js b/frontend/components/Pagination.js index 39de901..1432746 100644 --- a/frontend/components/Pagination.js +++ b/frontend/components/Pagination.js @@ -33,15 +33,14 @@ const PaginationStyles = styled.div` const Pagination = props => ( <Query query={ALL_ITEMS_QUERY}> {({ data, loading, error }) => { - console.log(error); - if (loading) return null; + if (loading || error) return null; const { aggregate } = data.itemsConnection; const { page } = props; const pages = Math.ceil(aggregate.count / perPage); + // TODO prefetch this return ( - <PaginationStyles> + <PaginationStyles data-test="pagination"> <Link - prefetch href={{ pathname: 'items', query: { page: page - 1 }, @@ -58,7 +57,6 @@ const Pagination = props => ( <strong>{aggregate.count}</strong> Items Total </p> <Link - prefetch href={{ pathname: 'items', query: { page: page + 1 }, diff --git a/frontend/components/ResetRequest.js b/frontend/components/ResetRequest.js index 67ab787..d25e94a 100644 --- a/frontend/components/ResetRequest.js +++ b/frontend/components/ResetRequest.js @@ -17,8 +17,6 @@ class ResetRequest extends React.Component { onSubmit={async e => { e.preventDefault(); const res = await resetMutation(); - console.log('HEYY'); - console.log(res); }} data-test="ResetRequest" > |
