diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-06-14 16:44:21 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-06-14 16:44:21 -0400 |
| commit | b1600adec47a04f60e1da07d94a3ed3906ff5aee (patch) | |
| tree | 828f786da6806d7237ee5cbc5df61e552353b85b /finished-application/frontend/components/Item.js | |
| parent | a95e08cd2dd5d7ec0a0412adae02515a5f9cec4f (diff) | |
starter files
Diffstat (limited to 'finished-application/frontend/components/Item.js')
| -rw-r--r-- | finished-application/frontend/components/Item.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/finished-application/frontend/components/Item.js b/finished-application/frontend/components/Item.js new file mode 100644 index 0000000..d6b339e --- /dev/null +++ b/finished-application/frontend/components/Item.js @@ -0,0 +1,53 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import Link from 'next/link'; +import Title from './styles/Title'; +import AddToCart from './AddToCart'; +import DeleteItem from './DeleteItem'; +import formatMoney from '../lib/formatMoney'; +import ItemStyles from './styles/ItemStyles'; +import PriceTag from './styles/PriceTag'; + +class Item extends React.Component { + static propTypes = { + item: PropTypes.object.isRequired, + }; + + render() { + const item = this.props.item; + return ( + <ItemStyles key={item.id}> + {item.image && <img src={item.image} alt={item.title} />} + <Title> + <Link + href={{ + pathname: '/item', + query: { id: item.id }, + }} + > + <a>{item.title}</a> + </Link> + </Title> + + <PriceTag>{formatMoney(item.price)}</PriceTag> + + <p>{item.description}</p> + + <div className="buttonList"> + <Link + href={{ + pathname: '/update', + query: { id: item.id }, + }} + > + <a>Edit ✏️</a> + </Link> + <AddToCart id={item.id} /> + <DeleteItem id={item.id} /> + </div> + </ItemStyles> + ); + } +} + +export default Item; |
