import { Component } from 'react'; import withData from '../lib/withData'; import Items from '../components/Items'; import Signup from '../components/Signup'; import LoginAuth0 from '../components/LoginAuth0'; import Page from '../components/Page'; import { USER_ORDERS_QUERY } from '../queries'; import { graphql, compose } from 'react-apollo' import has from 'lodash.has'; import get from 'lodash.get'; import formatMoney from '../lib/formatMoney'; import makeImage from '../lib/image'; import TakeMyMoney from './TakeMyMoney' import { CURRENT_USER_QUERY, REMOVE_FROM_CART_MUTATION } from '../queries'; class CartList extends Component { componentDidMount() { setTimeout(this.props.currentUserQuery.refetch, 1); } render() { if(this.props.loading) { return
Loading...
} if(this.props.error) { returnError...
} if(!has(this.props, 'currentUserQuery.user.cart')) { returnDon't have it yet!
} const cart = this.props.currentUserQuery.user.cart; const userId = this.props.currentUserQuery.user.id; const total = cart.reduce((a, b) => a + b.price, 0); return (