code clean up

This commit is contained in:
Mann Patel
2025-04-14 22:18:56 -06:00
parent b142610d50
commit fdf63f4e6a
7 changed files with 7 additions and 13 deletions

View File

@@ -10,9 +10,12 @@ const Home = () => {
const [recommended, setRecommended] = useState([]);
const [history, sethistory] = useState([]);
const [error, setError] = useState(null);
const storedUser = JSON.parse(sessionStorage.getItem("user"));
const [showAlert, setShowAlert] = useState(false);
//After user data storing the session.
const storedUser = JSON.parse(sessionStorage.getItem("user"));
const toggleFavorite = async (id) => {
const response = await fetch(
"http://localhost:3030/api/product/addFavorite",
@@ -63,8 +66,6 @@ const Home = () => {
useEffect(() => {
const fetchrecomProducts = async () => {
// Get the user's data from localStorage
console.log(storedUser);
try {
const response = await fetch(
"http://localhost:3030/api/engine/recommended",
@@ -95,6 +96,7 @@ const Home = () => {
isFavorite: false, // Default state
})),
);
reloadPage();
} else {
throw new Error(data.message || "Error fetching products");
}
@@ -104,9 +106,7 @@ const Home = () => {
}
};
fetchrecomProducts();
//reloadPage();
}, []);
reloadPage();
useEffect(() => {
const fetchProducts = async () => {

View File

@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { X } from "lucide-react";
import { useLocation, Link } from "react-router-dom";
import { X } from "lucide-react";
import axios from "axios";
const SearchPage = () => {

View File

@@ -1,5 +1,5 @@
import { useState, useEffect } from "react";
import { User, Lock, Trash2, History, Search, Shield } from "lucide-react";
import { User, Lock, Trash2, History, Shield } from "lucide-react";
import FloatingAlert from "../components/FloatingAlert"; // adjust path if needed
const Settings = () => {

6
package-lock.json generated
View File

@@ -1,6 +0,0 @@
{
"name": "Campus-Plug",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}