code clean up
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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
6
package-lock.json
generated
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "Campus-Plug",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user