oem-automation-frontend/src/components/products/allProducts.jsx

61 lines
1.5 KiB
React
Raw Normal View History

2021-11-15 17:20:32 -05:00
import React from 'react';
import { useGetProd } from '../api';
import './allProducts.css';
2021-11-15 17:20:32 -05:00
const AllProducts = ( ) => {
const allProducts = useGetProd();
2021-11-15 17:20:32 -05:00
let ProductList = () => {
if (allProducts) {
return (
<table>
<thead>
<tr>
<th></th>
<th>ID</th>
<th>Model #</th>
<th>Description</th>
<th>Price</th>
</tr>
</thead>
<tbody>
{ allProducts.map(product => {
return (
<tr key={product.ID}>
<td>[ ]</td>
<td>{product.ID}</td>
<td>{product.productName}</td>
<td>{product.productDesc}</td>
<td>${product.price}</td>
</tr>
);
})
}
</tbody>
<tfoot></tfoot>
</table>
);
} else {
return (
<>
<p> Loading... </p>
</>
)
}
};
2021-11-15 17:20:32 -05:00
return (
<div className="container">
<hr />
<span className="danger">Fetch product list from https://api.oemautomation.com:3001 </span>
<hr />
<ProductList />
2021-11-15 17:20:32 -05:00
<hr />
</div>
);
}
export default AllProducts;