Skip to content

Commit 241aff3

Browse files
committed
2-DR2-TP3.00-fix
1 parent 3e9e444 commit 241aff3

File tree

4 files changed

+88
-32
lines changed

4 files changed

+88
-32
lines changed
Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
1-
import Product from '../product';
21
import './styles.css';
32

43
export default function ProductList({ products, handleEdit, handleDelete }) {
54
return (
6-
<div className="product-list">
7-
{products.map((product, index) => (
8-
<Product key={index} {...product} index={index} handleDelete={handleDelete} handleEdit={handleEdit} />
9-
))}
10-
</div>
5+
<table className="product-list">
6+
<thead>
7+
<tr>
8+
<th>Nome</th>
9+
<th>Categoria</th>
10+
<th>Preço</th>
11+
<th></th>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
{products.map((product, index) => (
16+
<tr key={index}>
17+
<td>{product.name}</td>
18+
<td>{product.category}</td>
19+
<td>R$ {product.price && !isNaN(product.price) ? Number(product.price).toFixed(2) : product.price}</td>
20+
<td>
21+
<button onClick={() => handleEdit(index)} style={{marginRight: '8px'}}>Editar</button>
22+
<button onClick={() => handleDelete(index)}>Excluir</button>
23+
</td>
24+
</tr>
25+
))}
26+
</tbody>
27+
</table>
1128
)
1229
}
Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,66 @@
11
.product-list {
2-
max-width: 800px;
3-
margin: 0 auto;
4-
padding: 20px;
5-
}
2+
width: 100%;
3+
background-color: white;
4+
border-radius: 12px;
5+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
6+
border-collapse: separate;
7+
border-spacing: 0;
8+
overflow: hidden;
9+
}
10+
11+
.product-list thead {
12+
background-color: #f5f5f5;
13+
}
14+
15+
.product-list th {
16+
padding: 1rem;
17+
text-align: left;
18+
font-weight: 600;
19+
color: #333;
20+
border-bottom: 2px solid #e0e0e0;
21+
}
22+
23+
.product-list tbody tr {
24+
border-bottom: 1px solid #e0e0e0;
25+
transition: background-color 0.2s;
26+
}
27+
28+
.product-list tbody tr:hover {
29+
background-color: #f9f9f9;
30+
}
31+
32+
.product-list tbody tr:last-child {
33+
border-bottom: none;
34+
}
35+
36+
.product-list td {
37+
padding: 1rem;
38+
color: #333;
39+
}
40+
41+
.product-list td:last-child {
42+
white-space: nowrap;
43+
}
44+
45+
.product-list button {
46+
padding: 0.5rem 1rem;
47+
border: none;
48+
border-radius: 6px;
49+
cursor: pointer;
50+
font-size: 14px;
51+
transition: opacity 0.2s;
52+
}
53+
54+
.product-list button:hover {
55+
opacity: 0.8;
56+
}
57+
58+
.product-list button:first-child {
59+
background-color: #4CAF50;
60+
color: white;
61+
}
62+
63+
.product-list button:last-child {
64+
background-color: #f44336;
65+
color: white;
66+
}

2-desenvolvimento-front-end/DR2-fundamentos-de-react/DR2-TP3.00-produtos-crud/src/components/product/index.jsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

2-desenvolvimento-front-end/DR2-fundamentos-de-react/DR2-TP3.00-produtos-crud/src/components/product/styles.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)