code clean up
This commit is contained in:
@@ -10,9 +10,12 @@ const Home = () => {
|
|||||||
const [recommended, setRecommended] = useState([]);
|
const [recommended, setRecommended] = useState([]);
|
||||||
const [history, sethistory] = useState([]);
|
const [history, sethistory] = useState([]);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const storedUser = JSON.parse(sessionStorage.getItem("user"));
|
|
||||||
const [showAlert, setShowAlert] = useState(false);
|
const [showAlert, setShowAlert] = useState(false);
|
||||||
|
|
||||||
|
//After user data storing the session.
|
||||||
|
const storedUser = JSON.parse(sessionStorage.getItem("user"));
|
||||||
|
|
||||||
|
|
||||||
const toggleFavorite = async (id) => {
|
const toggleFavorite = async (id) => {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:3030/api/product/addFavorite",
|
"http://localhost:3030/api/product/addFavorite",
|
||||||
@@ -63,8 +66,6 @@ const Home = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchrecomProducts = async () => {
|
const fetchrecomProducts = async () => {
|
||||||
// Get the user's data from localStorage
|
|
||||||
console.log(storedUser);
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
"http://localhost:3030/api/engine/recommended",
|
"http://localhost:3030/api/engine/recommended",
|
||||||
@@ -95,6 +96,7 @@ const Home = () => {
|
|||||||
isFavorite: false, // Default state
|
isFavorite: false, // Default state
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
reloadPage();
|
||||||
} else {
|
} else {
|
||||||
throw new Error(data.message || "Error fetching products");
|
throw new Error(data.message || "Error fetching products");
|
||||||
}
|
}
|
||||||
@@ -104,9 +106,7 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchrecomProducts();
|
fetchrecomProducts();
|
||||||
//reloadPage();
|
|
||||||
}, []);
|
}, []);
|
||||||
reloadPage();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchProducts = async () => {
|
const fetchProducts = async () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { X } from "lucide-react";
|
|
||||||
import { useLocation, Link } from "react-router-dom";
|
import { useLocation, Link } from "react-router-dom";
|
||||||
|
import { X } from "lucide-react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
const SearchPage = () => {
|
const SearchPage = () => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect } from "react";
|
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
|
import FloatingAlert from "../components/FloatingAlert"; // adjust path if needed
|
||||||
|
|
||||||
const Settings = () => {
|
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