-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProductList.js
44 lines (40 loc) · 1.32 KB
/
ProductList.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
import React, { useEffect, useState } from 'react';
const ProductList = () => {
const [products, setProducts] = useState([]);
useEffect(() => {
// Fetch products from the backend
const fetchProducts = async () => {
const response = await fetch('/api/products');
const data = await response.json();
setProducts(data.products);
};
fetchProducts();
}, []);
return (
<div className="product-list">
<h2>Product Management</h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>Halal Certified</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{products.map(product => (
<tr key={product.id}>
<td>{product.name}</td>
<td>{product.halalCertified ? 'Yes' : 'No'}</td>
<td>
<button>Edit</button>
<button>Delete</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
);
};
export default ProductList;