import React from 'react'; import { Query, Mutation } from 'react-apollo'; import gql from 'graphql-tag'; import { adopt } from 'react-adopt'; import User from './User'; import CartStyles from './styles/CartStyles'; import Supreme from './styles/Supreme'; import CloseButton from './styles/CloseButton'; import SickButton from './styles/SickButton'; import CartItem from './CartItem'; import calcTotalPrice from '../lib/calcTotalPrice'; import formatMoney from '../lib/formatMoney'; const LOCAL_STATE_QUERY = gql` query { cartOpen @client } `; const TOGGLE_CART_MUTATION = gql` mutation { toggleCart @client } `; /* eslint-disable */ const Composed = adopt({ user: ({ render }) => {render}, toggleCart: ({ render }) => {render}, localState: ({ render }) => {render}, }); /* eslint-enable */ const Cart = () => ( {({ user, toggleCart, localState }) => { const me = user.data.me; if (!me) return null; return (
× {me.name}'s Cart

You Have {me.cart.length} Item{me.cart.length === 1 ? '' : 's'} in your cart.

); }}
); export default Cart; export { LOCAL_STATE_QUERY, TOGGLE_CART_MUTATION };