From 3b45dd7b593825721ec9ee9f6a49c732601b1ae0 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 21 Sep 2017 15:39:12 -0400 Subject: Cha Ching --- components/Item.js | 92 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 32 deletions(-) (limited to 'components/Item.js') diff --git a/components/Item.js b/components/Item.js index 66ca66f..1b47fcf 100644 --- a/components/Item.js +++ b/components/Item.js @@ -1,33 +1,61 @@ -import React, { Component } from 'react' -import { graphql, gql, compose } from 'react-apollo' -import { SINGLE_ITEM_QUERY } from '../queries'; -import withData from '../lib/withData'; - -class Item extends Component { - render() { - if(!this.props.findItem.Item) return

Not ready

- console.log(this.props.findItem.Item); - - if(this.props.loading) return

Loading...

- if(this.props.error) return

Error...

- - const item = this.props.findItem.Item; - return ( -
-

Viewing {item.title}

-
- ) +import styled from 'styled-components'; +import slugify from 'slugify'; +import { Link } from '../routes'; +import AddToCart from './AddToCart'; +import makeImage from '../lib/image'; +import TakeMyMoney from './TakeMyMoney'; +import formatMoney from '../lib/formatMoney'; + +const Item = styled.div` + background: #f3f3f3; + padding: 5px; + img { + width: 100%; } -} - -const ComponentWithMutations = compose( - graphql(SINGLE_ITEM_QUERY, { - name: 'findItem', - // This comes from Props - options: ({ id }) => ({ - variables: { id } - }) - }) -)(Item); - -export default ComponentWithMutations; +`; + +const ItemComponent = ({ item }) => ( + + {item.image ? {item.title} : null} +

+ + {item.title} + +

+ +

{item.description}

+ {/* { + + + Edit ✏️ + + + } */} + + + + + + + +
+); + +export default ItemComponent; -- cgit v1.3