import React from 'react'; import { Mutation, Query } from 'react-apollo'; import { adopt } from 'react-adopt'; import gql from 'graphql-tag'; import TakeMyMoney from './TakeMyMoney'; import formatMoney from '../lib/formatMoney'; import CartItem from './CartItem'; import { CURRENT_USER_QUERY } from './User'; 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 LOCAL_STATE_QUERY = gql` query { cartOpen @client } `; const TOGGLE_CART_MUTATION = gql` mutation { toggleCart @client } `; const Composed = adopt({ toggleCart: ({ render }) => ( {(mutate, result) => render({ mutate, result })} ), localState: ({ render }) => , currentUser: ({ render }) => ( ), }); 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; export { LOCAL_STATE_QUERY, TOGGLE_CART_MUTATION };