diff --git a/backend/controllers/product.js b/backend/controllers/product.js
index c8f9885..b031c3f 100644
--- a/backend/controllers/product.js
+++ b/backend/controllers/product.js
@@ -14,6 +14,7 @@ exports.addToFavorite = async (req, res) => {
success: true,
message: "Product added to favorites successfully",
});
+ console.log(result);
} catch (error) {
console.error("Error adding favorite product:", error);
return res.json({ error: "Could not add favorite product" });
diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx
index 92f3f3c..555744e 100644
--- a/frontend/src/pages/Home.jsx
+++ b/frontend/src/pages/Home.jsx
@@ -8,6 +8,29 @@ const Home = () => {
const [recommended, setRecommended] = useState([]);
const [history, sethistory] = useState([]);
const [error, setError] = useState(null);
+ const storedUser = JSON.parse(sessionStorage.getItem("user"));
+
+ const handleLinkClick = async (id) => {
+ // Example: append to localStorage or call analytics
+ const response = await fetch(
+ "http://localhost:3030/api/product/add_fav_product",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ userID: storedUser.ID,
+ productsID: id,
+ }),
+ },
+ );
+
+ if (!response.ok) throw new Error("Failed to fetch products");
+
+ console.log(response);
+ console.log(`Add Product -> History: ${id}`);
+ };
useEffect(() => {
const fetchrecomProducts = async () => {
@@ -298,6 +321,7 @@ const Home = () => {
handleLinkClick(listing.id)}
className="bg-white border border-gray-200 hover:shadow-md transition-shadow w-70 flex-shrink-0 relative"
>
diff --git a/frontend/src/pages/ProductDetail.jsx b/frontend/src/pages/ProductDetail.jsx
index b64a998..b8dbc47 100644
--- a/frontend/src/pages/ProductDetail.jsx
+++ b/frontend/src/pages/ProductDetail.jsx
@@ -14,7 +14,7 @@ const ProductDetail = () => {
reviews: null,
});
const [isFavorite, setIsFavorite] = useState(false);
- const [showContactForm, setShowContactForm] = useState(false);
+ const [contactForm, showContactForm, setShowContactForm] = useState(false);
const [currentImage, setCurrentImage] = useState(0);
const [reviews, setReviews] = useState([]);
const [showReviewForm, setShowReviewForm] = useState(false);
@@ -417,81 +417,15 @@ const ProductDetail = () => {
-
-
- {showContactForm && (
-
- )}
+ */}
+ {/* Seller Info */}
@@ -507,19 +441,29 @@ const ProductDetail = () => {
-
-
-
Rating:{" "}
- {product.seller?.rating ? (
-
- {renderStars(product.seller.rating)}
- {product.seller.rating}/5
-
- ) : (
- "N/A"
- )}
+
+ {/* Contact Options */}
+ {showContactForm && (
+
-
+ )}
diff --git a/frontend/src/pages/Settings.jsx b/frontend/src/pages/Settings.jsx
index a7e3992..dfc967e 100644
--- a/frontend/src/pages/Settings.jsx
+++ b/frontend/src/pages/Settings.jsx
@@ -415,6 +415,60 @@ const Settings = () => {
+ {/* Privacy Section */}
+
+
+
+
+
+
+
+
+
+
Search History
+
+ Delete all your search history on StudentMarket
+
+
+
+
+
+
+
+
+
+
+
+ Browsing History
+
+
+ Delete all your browsing history on StudentMarket
+
+
+
+
+
+
+
+
+
{/* Delete Account (Danger Zone) */}
diff --git a/recommondation-engine/app.py b/recommondation-engine/app.py
index 95da178..0deaab8 100644
--- a/recommondation-engine/app.py
+++ b/recommondation-engine/app.py
@@ -1,4 +1,6 @@
# pip install mysql.connector
+#
+
import mysql.connector
from sklearn.metrics.pairwise import cosine_similarity
@@ -15,6 +17,28 @@ def database():
)
return db_connection
+def get_popular_products():
+ pass
+
+
+def delete_user_recommendation(userID, Array):
+ db_con = database()
+ cursor = db_con.cursor()
+
+ try:
+ for item in Array:
+ #Product ID starts form index 1
+ item_value = item + 1
+ print(item_value)
+ # Use parameterized queries to prevent SQL injection
+ cursor.execute(f"INTO Recommendation (UserID, RecommendedProductID) VALUES ({userID}, {item_value});")
+
+ db_con.commit()
+
+ #results = cursor.fetchall()
+ #print(results)
+ except:
+ pass
def get_all_products():
@@ -89,9 +113,9 @@ def get_recommendations(user_id, top_n=10):
# Get all products and user history with their category vectors
all_products = get_all_products()
user_history = get_user_history(user_id)
- # if not user_history:
- # # Cold start: return popular products
- # return get_popular_products(top_n)
+ if not user_history:
+ #Cold start: return popular products
+ return get_popular_products(top_n)
# Calculate similarity between all products and user history
user_profile = np.mean(user_history, axis=0) # Average user preferences
similarities = cosine_similarity([user_profile], all_products)
@@ -128,8 +152,8 @@ def history_upload(userID, anrr):
db_con.commit()
# If you need results, you'd typically fetch them after a SELECT query
- # results = cursor.fetchall()
- # print(results)
+ #results = cursor.fetchall()
+ #print(results)
except Exception as e:
print(f"Error: {e}")
diff --git a/recommondation-engine/server.py b/recommondation-engine/server.py
index 83dbe4d..6e39f71 100644
--- a/recommondation-engine/server.py
+++ b/recommondation-engine/server.py
@@ -1,9 +1,12 @@
+
+
+
+
from flask import Flask, request, jsonify
from flask_cors import CORS
from app import get_recommendations
-from app import history_upload
-import time
+#import time
app = Flask(__name__)