import React from 'react'; import { Mutation, Query } from 'react-apollo'; import { adopt } from 'react-adopt'; import TakeMyMoney from './TakeMyMoney'; import formatMoney from '../lib/formatMoney'; import CartItem from './CartItem'; import { CURRENT_USER_QUERY, LOCAL_STATE_QUERY, TOGGLE_CART_MUTATION, } from '../queries/queries.graphql'; import calcTotalPrice from '../lib/calcTotalPrice'; import Error from './ErrorMessage'; import CartStyles from './styles/CartStyles'; import Supreme from './styles/Supreme'; import CloseButton from './styles/CloseButton'; import SickButton from './styles/SickButton'; const Composed = adopt({ toggleCart: ({ render }) => ( {(mutate, result) => render({ mutate, result })} ), localState: , currentUser: , }); const Cart = () => ( {({ toggleCart, localState, currentUser }) => { const { data: { me }, error, loading, } = currentUser; if (loading) return Loading...; if (error) return ; if (!me) return null; return ( × {me.name}'s Cart. You have {me.cart.length} item{me.cart.length === 1 ? '' : 's'} in your cart. {me.cart.map(cartItem => ( ))} ); }} ); export default Cart;
Loading...
You have {me.cart.length} item{me.cart.length === 1 ? '' : 's'} in your cart.