diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-04-19 13:29:25 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-04-19 13:29:25 -0400 |
| commit | e018f5482e550a49535f4df990d3bfc09128f5d8 (patch) | |
| tree | d8058ac92f68a487c985553cff26650f040cdd11 /frontend/components | |
| parent | e91740e812080fafa058b13b63218eeda4449135 (diff) | |
Add to cart tests
Diffstat (limited to 'frontend/components')
| -rw-r--r-- | frontend/components/AddToCart.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/frontend/components/AddToCart.js b/frontend/components/AddToCart.js index eead8f0..e2770cb 100644 --- a/frontend/components/AddToCart.js +++ b/frontend/components/AddToCart.js @@ -1,7 +1,7 @@ import { Component } from 'react'; -import { Mutation } from 'react-apollo'; +import { Mutation, Query } from 'react-apollo'; import PropTypes from 'prop-types'; -import { ADD_TO_CART_MUTATION, CURRENT_USER_QUERY } from 'queries'; +import { ADD_TO_CART_MUTATION, CURRENT_USER_QUERY } from '../queries/queries'; class AddToCart extends Component { static propTypes = { @@ -29,13 +29,17 @@ class AddToCart extends Component { render() { const { id } = this.props; return ( - <Mutation mutation={ADD_TO_CART_MUTATION} variables={{ id }} update={this.update}> - {(addToCart, { loading }) => ( - <button disabled={loading} onClick={addToCart}> - 🛒 Add{loading && 'ing'} To Cart - </button> + <Query query={CURRENT_USER_QUERY}> + {() => ( + <Mutation mutation={ADD_TO_CART_MUTATION} variables={{ id }} update={this.update}> + {(addToCart, { loading }) => ( + <button disabled={loading} onClick={addToCart}> + 🛒 Add{loading && 'ing'} To Cart + </button> + )} + </Mutation> )} - </Mutation> + </Query> ); } } |
