diff --git a/functions/views/my-products.ejs b/functions/views/my-products.ejs
index c094291..b235fff 100644
--- a/functions/views/my-products.ejs
+++ b/functions/views/my-products.ejs
@@ -52,7 +52,7 @@
-

+
Extras
diff --git a/functions/views/search.ejs b/functions/views/search.ejs
new file mode 100644
index 0000000..3ee9837
--- /dev/null
+++ b/functions/views/search.ejs
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
GG Prototype
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 🔔 | <%= 0%>
+
+
+ 🛒 | <%= 0%>
+
+
+
+
+
+
+
+
+
+
+
+
Search results:
+
+ <% var keys = Object.keys(products) %>
+ <% keys.forEach(function(key){ %>
+
+
![]()
')} title="<%= products[key].img %>" alt="img" src="media/var.png">
+
+
<%= products[key].name%>
+
+
+
Β£ <%= products[key].price%>
+
+
+ <% }) %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/server.js b/server.js
index d148787..a1f6f29 100644
--- a/server.js
+++ b/server.js
@@ -47,10 +47,51 @@ function homePage(request, responce) {
if (request.query.itemAdded == "true") {
x = 'block'
}
+ console.log(data)
responce.render('home.ejs', {products: data, message: x})
})
}
+app.get('/search', function(request, responce){
+ var dbRef = database.ref("/products")
+ if (request.query.search) {
+ let sQuery = request.query.search.toLowerCase()
+ dbRef.orderByChild("status").equalTo("on-sale").once('value', function(snapshot){
+ var data = {
+ 'x': {desc: '',holder: '',id: 999,img: '',location: '',name: 'Nothing found π’',owner: '',price: '',public: '',stock: ''},
+ }
+ if (snapshot.val()) {
+ data = snapshot.val()
+ var sResults = [{desc: '',holder: '',id: 999,img: '',location: '',name: 'Nothing found π’',owner: '',price: '',public: '',stock: ''}]
+
+ var keys = Object.keys(data)
+
+ keys.forEach(key => {
+ if (data[key].name.toLowerCase().includes(sQuery) || data[key].desc.toLowerCase().includes(sQuery)) {
+ sResults[key] = data[key]
+ console.log(sResults)
+ }
+ })
+ if (Object.keys(sResults).length > 1) {
+ delete sResults[0]
+ }
+ console.log(sResults)
+ responce.render('search.ejs', {products: sResults})
+ }
+ else {responce.render('search.ejs', {products: data})}
+ })
+ }
+ else {
+ dbRef.orderByChild("status").equalTo("on-sale").once('value', function(snapshot){
+ var data = {
+ 'x': {desc: '',holder: '',id: 999,img: '',location: '',name: 'Nothing found π’',owner: '',price: '',public: '',stock: ''},
+ }
+ if (snapshot.val()) {data = snapshot.val()}
+ responce.render('search.ejs', {products: data})
+ })
+ }
+})
+
app.get('/additmpage', function(request, responce){
responce.render('add-item.ejs')
})