import { Component } from 'react'; import { graphql, compose } from 'react-apollo'; import styled from 'styled-components'; import { CURRENT_USER_QUERY } from '../queries'; import RemoveFromCart from './RemoveFromCart'; const CartStyles = styled.div` background: white; border-radius: 10px; padding: 20px; overflow: hidden; display: flex; align-items: center; `; class Cart extends Component { componentDidMount() { console.log('refetching..'); setTimeout(this.props.currentUser.refetch, 10); } render() { if (!this.props.currentUser.me) { return null; } // Check for loading state.. // const { loading, error } = this.props.currentUserQuery; // const { user } = this.props.currentUserQuery; // if (loading || error || !user) return
Cart Loading...
; // const total = user.cart.reduce((a, b) => a + b.price, 0); const { me } = this.props.currentUser; console.log(me); return (🛒: {me.cart.length} Items