diff --git a/src/App.js b/src/App.js
index 3784575..7d16233 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,25 +1,12 @@
-import logo from './logo.svg';
-import './App.css';
+import React from 'react'
+import ProductsPage from './components/ProductsPage'
-function App() {
+const 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..74f5360
--- /dev/null
+++ b/src/components/ProductRow.js
@@ -0,0 +1,16 @@
+import React from "react";
+
+const ProductRow = ({ product }) => {
+ return (
+
+
+ |
+ {product.name}
+ |
+ {product.price} |
+
+
+ );
+};
+
+export default ProductRow;
diff --git a/src/components/ProductTable.js b/src/components/ProductTable.js
new file mode 100644
index 0000000..4621dce
--- /dev/null
+++ b/src/components/ProductTable.js
@@ -0,0 +1,22 @@
+import React from 'react'
+import ProductRow from './ProductRow'
+
+const 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..1608cc7
--- /dev/null
+++ b/src/components/ProductsPage.js
@@ -0,0 +1,32 @@
+import React, { useState } from "react";
+import jsonData from "../data.json";
+import SearchBar from "./SearchBar";
+import ProductTable from "./ProductTable";
+
+const ProductsPage = () => {
+ const [products, setProducts] = useState(jsonData);
+ const [searchQuery, setSearchQuery] = useState("");
+ const [showInStock, setShowInStock] = useState(false);
+
+ const filteredProducts = products.filter((product) => {
+ const matchesSearch = product.name
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase());
+ const matchesStock = !showInStock || product.inStock;
+ return matchesSearch && matchesStock;
+ });
+ return (
+
+ );
+};
+
+export default ProductsPage;
diff --git a/src/components/SearchBar.js b/src/components/SearchBar.js
new file mode 100644
index 0000000..4764f6a
--- /dev/null
+++ b/src/components/SearchBar.js
@@ -0,0 +1,25 @@
+import React from 'react'
+
+const SearchBar = ({searchQuery, setSearchQuery, showInStock, setShowInStock}) => {
+ return (
+
+ setSearchQuery(e.target.value)}
+ className="border p-2 w-full mb-2"
+ />
+
+
+ )
+}
+
+export default SearchBar
\ No newline at end of file
diff --git a/src/index.css b/src/index.css
index ec2585e..e69de29 100644
--- a/src/index.css
+++ b/src/index.css
@@ -1,13 +0,0 @@
-body {
- margin: 0;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
- sans-serif;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
-}
-
-code {
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
- monospace;
-}