diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
| commit | cd0b07b3adb36fb5ec098f9e511ab45d774fee7b (patch) | |
| tree | a203e5010219ccea1acc6bbd2c0a4bcfa0a78615 /frontend/components/Item.js | |
| parent | 0a1648bf47490b312169c531aeb51ef4725e8d2e (diff) | |
Move to Prisma Backend
Diffstat (limited to 'frontend/components/Item.js')
| -rw-r--r-- | frontend/components/Item.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/frontend/components/Item.js b/frontend/components/Item.js new file mode 100644 index 0000000..1b47fcf --- /dev/null +++ b/frontend/components/Item.js @@ -0,0 +1,61 @@ +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 ItemComponent = ({ item }) => ( + <Item key={item.id}> + {item.image ? <img key={item.image.secret} src={makeImage(item.image)} alt={item.title} /> : null} + <h3> + <Link + route="item" + params={{ + slug: slugify(item.title), + itemId: item.id, + }} + > + <a>{item.title}</a> + </Link> + </h3> + + <p>{item.description}</p> + {/* { + + <Link + href={{ + pathname: '/admin/update', + query: { id: item.id }, + }} + > + <a>Edit ✏️</a> + </Link> + + } */} + + <TakeMyMoney + id={item.id} + amount={item.price} + name={item.title} // the pop-in header title + description={item.description} // the pop-in header subtitle + image={makeImage(item.image)} + > + <button>Buy for {formatMoney(item.price)}</button> + </TakeMyMoney> + + <AddToCart id={item.id} /> + <button onClick={() => this.props.removeItemMutation({ variables: { id: item.id } })}>× Delete item</button> + </Item> +); + +export default ItemComponent; |
