From 8f2c595eca30e2d7138c8e8d6685774a8f44e55d Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 15 Feb 2018 16:59:58 -0500 Subject: omg --- frontend/components/CartList.js | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'frontend/components/CartList.js') diff --git a/frontend/components/CartList.js b/frontend/components/CartList.js index bf08f87..1a44012 100644 --- a/frontend/components/CartList.js +++ b/frontend/components/CartList.js @@ -1,21 +1,11 @@ // I THINK THIS CAN BE DELETED import { Component } from 'react'; -import withData from '../lib/withData'; -import Items from '../components/Items'; -import Signup from '../components/Signup'; -import LoginAuth0 from '../components/LoginAuth0'; -import Page from '../components/Page'; -import { USER_ORDERS_QUERY, GET_CART_STATE } from '../queries'; -import { graphql, compose } from 'react-apollo'; -import has from 'lodash.has'; -import get from 'lodash.get'; +import { compose } from 'react-apollo'; import styled from 'styled-components'; +import PropTypes from 'prop-types'; import formatMoney from '../lib/formatMoney'; -import makeImage from '../lib/image'; import TakeMyMoney from './TakeMyMoney'; -import { removeFromCartEnhancer } from '../enhancers/enhancers'; -import { CURRENT_USER_QUERY } from '../queries'; -import PropTypes from 'prop-types'; +import { removeFromCartEnhancer, userEnhancer, uiEnhancer } from '../enhancers/enhancers'; const CartStyles = styled.div` padding: 20px; @@ -44,15 +34,6 @@ class CartList extends Component { client: PropTypes.object, }; - componentDidMount() { - setTimeout(this.props.currentUserQuery.refetch, 1); - // Set the cart state to be closed - this.context.client.writeQuery({ - query: GET_CART_STATE, - data: { ui: { isCartOpen: true, __typename: 'Network' } }, - }); - } - toggleOpen = () => { this.props.uiQuery.updateQuery(() => ({ ui: { isCartOpen: false, __typename: 'Network' } })); }; @@ -66,15 +47,13 @@ class CartList extends Component { return

Error....

; } - // if (!has(this.props, 'currentUserQuery.user.cart')) { // return

Don't have it yet!

; // } // OMG Clean this up - let { user = {} } = this.props.currentUserQuery || {}; + if (!user) user = {}; const cart = user.cart || []; const userId = user.id; - // const userId = this.props.currentUserQuery.user.id; const total = cart.reduce((a, b) => a + b.price, 0); return ( @@ -83,7 +62,6 @@ class CartList extends Component { Open Cart

{cart.length} Items

-