blob: 092b443dbb7b6837822274e8fcdacd873a5c9be4 (
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
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Link from 'next/link';
import Title from './styles/Title';
import ItemStyles from './styles/ItemStyles';
import PriceTag from './styles/PriceTag';
import formatMoney from '../lib/formatMoney';
export default class Item extends Component {
static propTypes = {
item: PropTypes.object.isRequired,
};
render() {
const { item } = this.props;
return (
<ItemStyles>
{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>
<button>Add To Cart</button>
<button>Delete </button>
</div>
</ItemStyles>
);
}
}
|