-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathProductsTable.js
More file actions
34 lines (27 loc) · 1.03 KB
/
ProductsTable.js
File metadata and controls
34 lines (27 loc) · 1.03 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
import './ProductsTable.css';
import React from 'react';
import ProductRow from './ProductRow';
export default function ProductsTable(props) {
const products = props.data;
const searchString = props.searchString.toLowerCase();
let filteredProducts = products.filter((product) => {
return product.name.toLowerCase().startsWith(searchString);
});
// let inStockProducts = [];
if (props.isChecked) {
filteredProducts = filteredProducts.filter((product) => product.inStock)
}
return (
<div className='productsTable'>
<div>
<tr className='tableHeader'>
<td className='productInfo'>Product Name</td>
<td className='productInfo productPrice'>Price</td>
</tr>
</div>
<div className='rowContainer'>
{filteredProducts.map((product) => <ProductRow key={product.id} name={product.name} price={product.price} inStock={product.inStock} />)}
</div>
</div>
)
}