diff --git a/src/App.css b/src/App.css
index 74b5e05..47163f3 100644
--- a/src/App.css
+++ b/src/App.css
@@ -36,3 +36,5 @@
transform: rotate(360deg);
}
}
+
+
diff --git a/src/App.js b/src/App.js
index 3784575..0d6e272 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,25 +1,14 @@
-import logo from './logo.svg';
-import './App.css';
+import React from 'react';
+import ProductsPage from './components/ProductsPage';
+
function App() {
return (
);
}
-export default App;
+export default App;
\ No newline at end of file
diff --git a/src/components/ProductRow.js b/src/components/ProductRow.js
new file mode 100644
index 0000000..93ca602
--- /dev/null
+++ b/src/components/ProductRow.js
@@ -0,0 +1,12 @@
+import React from 'react';
+
+function ProductRow({ product }) {
+ return (
+
+ | {product.name} |
+ {product.price} |
+
+ );
+}
+
+export default ProductRow;
\ No newline at end of file
diff --git a/src/components/ProductTable.js b/src/components/ProductTable.js
new file mode 100644
index 0000000..177730a
--- /dev/null
+++ b/src/components/ProductTable.js
@@ -0,0 +1,24 @@
+import React from 'react';
+import ProductRow from './ProductRow';
+import './css/style.css';
+
+function ProductTable({ products }) {
+ return (
+
+
+
+ | Name |
+ Price |
+
+
+
+
+ {products.map(product => (
+
+ ))}
+
+
+ );
+}
+
+export default ProductTable;
\ No newline at end of file
diff --git a/src/components/ProductsPage.js b/src/components/ProductsPage.js
new file mode 100644
index 0000000..de08202
--- /dev/null
+++ b/src/components/ProductsPage.js
@@ -0,0 +1,45 @@
+import React, { useState } from 'react';
+import SearchBar from './SearchBar';
+import ProductTable from './ProductTable';
+import data from '../data.json'; // Assuming this is the correct path to your data
+import './css/style.css';
+
+function ProductsPage() {
+ const [searchQuery, setSearchQuery] = useState('');
+ const [onlyInStock, setOnlyInStock] = useState(false);
+
+ const handleSearchChange = (query) => {
+ setSearchQuery(query);
+ };
+
+ const handleInStockChange = (event) => {
+ setOnlyInStock(event.target.checked);
+ };
+
+ const filteredProducts = data.filter(product => {
+ const matchesSearchQuery = product.name.toLowerCase().includes(searchQuery.toLowerCase());
+ const matchesStockFilter = !onlyInStock || product.inStock;
+ return matchesSearchQuery && matchesStockFilter;
+ });
+
+ return (
+
+
Search
+
+
+
+
+
+
+
+ );
+}
+
+export default ProductsPage;
\ No newline at end of file
diff --git a/src/components/SearchBar.js b/src/components/SearchBar.js
new file mode 100644
index 0000000..9cdefb6
--- /dev/null
+++ b/src/components/SearchBar.js
@@ -0,0 +1,15 @@
+import React from 'react';
+import './css/style.css';
+function SearchBar({ searchQuery, onSearchChange }) {
+ return (
+
+ onSearchChange(e.target.value)}
+ />
+
+ );
+}
+
+export default SearchBar;
\ No newline at end of file
diff --git a/src/components/css/style.css b/src/components/css/style.css
new file mode 100644
index 0000000..8759518
--- /dev/null
+++ b/src/components/css/style.css
@@ -0,0 +1,71 @@
+.table-wrapper {
+ display: flex;
+ justify-content: center; /* Centers horizontally */
+ align-items: center; /* Centers vertically */
+ width: 1500px;
+ margin-left: 0px;
+ padding-left: 200px;
+ }
+
+ table {
+ width: 100%;
+ max-width: 2000px; /* Adjust this based on your design */
+ border-collapse: collapse; /* Ensures padding adds to cell size */
+ }
+
+ table th:first-child /* Width, Padding and Gap for Name heading */
+ {
+ width: 100%;
+ padding-left: 0px;
+ padding-right: -300px;
+ }
+
+ table th:nth-child(2) {
+ width: 300px; /* Increased width for the Price column */
+ margin-left: 500px;
+}
+
+ table th:first-child, /* Name heading */
+ table th:nth-child(2) /* Price heading */
+ {
+ background-color: lightgrey;
+ color: grey;
+ }
+
+ table th,
+ table td {
+ padding-top: 20px;
+ padding-bottom: 20px;
+ padding-right: 300px;
+ text-align: center; /* Ensures content is aligned as per requirement */
+ }
+
+ td:first-child {
+ width: 300px; /* Width for the Name column */
+ padding-left: 0px; /* Add padding to simulate margin */
+ }
+
+ table th:nth-child(2) {
+ width: 150px; /* Width for the Price column */
+ padding-right: -200px;
+ }
+
+ th:last-child,
+ .search-bar {
+ width: 100%; /* Make the search bar take up 100% of its parent width */
+ margin-bottom: 20px; /* Optional: Adds some space below the search bar */
+}
+
+.search-bar input {
+ width: 80%; /* Make the input inside the search bar take up 100% of the search bar's width */
+ padding: 8px; /* Adjust padding as needed for better spacing */
+ box-sizing: border-box; /* Ensures padding is included in the element's total width and height */
+}
+
+div.search-title {
+ padding-bottom: 15px !important;
+}
+
+.in-stock-filter {
+ padding-bottom: 50px;
+}
\ No newline at end of file
diff --git a/src/index.css b/src/index.css
index ec2585e..ea706c5 100644
--- a/src/index.css
+++ b/src/index.css
@@ -11,3 +11,14 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
+
+div.App {
+ width: 100%;
+ text-align: center;
+}
+
+.store-title {
+ font-weight: 400;
+ font-size: 36px;
+}
+