-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathMovieCard.js
More file actions
40 lines (38 loc) · 1 KB
/
MovieCard.js
File metadata and controls
40 lines (38 loc) · 1 KB
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
import React from 'react'
import PropTypes from 'prop-types'
export const MovieCard = ({ item, isInCart, addItem, removeItem }) => {
return (
<li key={item.id} className='movies__list-card'>
<ul>
<li>ID: {item.id}</li>
<li>Name: {item.name}</li>
<li>Price: ${item.price}</li>
</ul>
{
isInCart
? (
<div className="movies__cart-card-quantity">
<button onClick={() => removeItem(item)}>
-
</button>
<span>
{item.quantity}
</span>
<button onClick={() => addItem(item)}>
+
</button>
</div>
)
: (
<button onClick={() => addItem(item)}>Add to cart</button>
)
}
</li>
)
}
MovieCard.propTypes = {
item: PropTypes.object.isRequired,
isInCart: PropTypes.bool,
addItem: PropTypes.func.isRequired,
removeItem: PropTypes.func
}