Skip to content

Commit

Permalink
Main page groceries, electronics, fashion buttons Not Working Fixed (#…
Browse files Browse the repository at this point in the history
…137)

* New branch

* Issue fixed
  • Loading branch information
Hemu21 authored May 15, 2024
1 parent 86602c9 commit 9f5c52d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
7 changes: 0 additions & 7 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@ function App() {
};

const fetchWishlistProducts = async () => {
console.log("fetchWishlistProducts");
try {
const wishlistRef = doc(db, "wishlists", localStorage.getItem("uid"));
const productsCollectionRef = collection(wishlistRef, "products");
const querySnapshot = await getDocs(productsCollectionRef);
console.log(querySnapshot);
const products = [];
querySnapshot.forEach((doc) => {
products.push({ id: doc.id, ...doc.data() });
});
console.log(products);
setWishlistItems(products);
setWishlistCount(products.length); // Set the product count
} catch (error) {
Expand All @@ -102,7 +99,6 @@ function App() {
throw new Error("Network response was not ok");
}
const data = await response.json();
// //console.log("fetced data", data)
setData(data);
} catch (error) {
console.error("Error fetching data:", error);
Expand Down Expand Up @@ -138,7 +134,6 @@ function App() {
(snapshot) => {
const data = snapshot.val();
setCartItems(data);
//console.log("Data fetched successfully:", data);
},
(error) => {
console.error("Error fetching data:", error);
Expand All @@ -163,7 +158,6 @@ function App() {
(snapshot) => {
const data = snapshot.val();
setCartItems(data);
//console.log("Data fetched successfully:", data);
},
(error) => {
console.error("Error fetching data:", error);
Expand All @@ -184,7 +178,6 @@ function App() {
const uniqueKey = user + item.id; // Modify as per your requirement
// Add item to the cart in Firebase
setCartItems([...cartItems, { ...item, quantity: 1 }]);
//console.log('Item added to cart successfully');
} catch (error) {
console.error("Error adding item to cart:", error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const Header = (props) => {
}
});
} catch (error) {
//console.log(error.message);
console.log(error);
}
};

Expand Down
7 changes: 3 additions & 4 deletions src/components/header/nav/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const Nav = (props) => {
const [openDropdownMenuIndex, setDropdownMenuIndex] = useState(null);

const [openMegaMenu, setOpenMegaMenu] = useState(false);

const context = useContext(MyContext);

useEffect(() => {
Expand Down Expand Up @@ -67,7 +66,7 @@ const Nav = (props) => {
navData.map((item, index) => {
return (
<li className='list-inline-item' key={index}>
<Button onClick={()=>openDropdownFun(index)}><a href={`${windowWidth>992 ? `/cat/${item.cat_name.toLowerCase()}` : '#'}`}
<Button onClick={()=>openDropdownFun(index)}><a href={`${windowWidth>992 ? `#/cat/${item.cat_name.toLowerCase()}` : '#'}`}
onClick={() => sessionStorage.setItem('cat', item.cat_name.toLowerCase())}
>{item.cat_name} <KeyboardArrowDownIcon className={`${openDropdownMenu===true && openDropdownMenuIndex===index && 'rotateIcon'}`}/></a></Button>
{
Expand All @@ -79,8 +78,8 @@ const Nav = (props) => {
item.items.map((item_, index_) => {
return (
<li key={index_}>
<Button onClick={props.closeNav}>
<a href={`/cat/${item.cat_name.toLowerCase()}/${item_.cat_name.replace(/\s/g, '-').toLowerCase()}`}
<Button onClick={()=>{props.closeNav();setDropdownMenu(!openDropdownMenu);setDropdownMenuIndex(null)}}>
<a href={`#/cat/${item.cat_name.toLowerCase()}/${item_.cat_name.replace(/\s/g, '-').toLowerCase()}`}
onClick={() => sessionStorage.setItem('cat', item.cat_name.toLowerCase())}>
{
item_.cat_name
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const DetailsPage = (props) => {
}));
});
} catch (error) {
//console.log(error.message);
console.log(error);
}

showReviews();
Expand All @@ -245,7 +245,7 @@ const DetailsPage = (props) => {
}
});
} catch (error) {
//console.log(error.message);
console.log(error);
}

if (reviews_Arr2.length !== 0) {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/wishList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const WishList = () => {
const navigate = useNavigate();
const [uid, setUid] = useState(localStorage.getItem("uid"));

console.log(wishlistItems);

useEffect(() => {
try {
if (context.isLogin === "true") {
Expand Down Expand Up @@ -64,7 +64,6 @@ const WishList = () => {
price += parseInt(doc.data()?.price) * doc.data()?.quantity;
});
context.setWishlistCount(products.length);
console.log(products);
setWishlistItems(products);
setTotalPrice(price);
} catch (error) {
Expand Down

0 comments on commit 9f5c52d

Please sign in to comment.