From 2d145b026cfdf54a63bef0b9d6324b6785390307 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Fri, 14 Sep 2018 12:18:12 -0400 Subject: move finished folder --- finished-application/frontend/components/Cart.js | 66 ++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 finished-application/frontend/components/Cart.js (limited to 'finished-application/frontend/components/Cart.js') diff --git a/finished-application/frontend/components/Cart.js b/finished-application/frontend/components/Cart.js new file mode 100644 index 0000000..2a72b38 --- /dev/null +++ b/finished-application/frontend/components/Cart.js @@ -0,0 +1,66 @@ +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'; +import TakeMyMoney from './TakeMyMoney'; + +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. +

+
+
    {me.cart.map(cartItem => )}
+ +
+ ); + }} +
+); + +export default Cart; +export { LOCAL_STATE_QUERY, TOGGLE_CART_MUTATION }; -- cgit v1.3