blob: d6b339e35fde58de973f64bc1b3a35d74c7271ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
|