-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItemsDisplay.js
51 lines (48 loc) · 1.28 KB
/
ItemsDisplay.js
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
function ItemsDisplay(props) {
const deleteItem = (item) => {
props.deleteItem(item);
};
const showItems = (item) => {
if (item.id) {
//hotfix. Guess I have an issue with useEffect which leads to double entries in items-table after hitting "Add Item".
return (
<tr>
<th scope="row">{item.id}</th>
<td>{item.name}</td>
<td>{item.price}</td>
<td>{item.type}</td>
<td>{item.brand}</td>
<td>
<button
className="button btn-primary"
onClick={() => deleteItem(item)}
>
Delete
</button>
</td>
</tr>
);
}
};
return (
<div className="container">
<div className="row">Items</div>
<div className="row">
<table className="table table-striped">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Price</th>
<th scope="col">Type</th>
<th scope="col">Brand</th>
<th scope="col">Delete</th>
</tr>
</thead>
<tbody>{props.items.map(showItems)}</tbody>
</table>
</div>
</div>
);
}
export default ItemsDisplay;