From fde54a48a20a15b3ae69b43219550137aac03855 Mon Sep 17 00:00:00 2001 From: Vishesh Tripathi Date: Wed, 17 Jul 2024 17:29:08 +0530 Subject: [PATCH 1/2] correcting cartItems number --- Frontend/src/Components/CartContext.jsx | 1 + Frontend/src/Pages/Cart.jsx | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Frontend/src/Components/CartContext.jsx b/Frontend/src/Components/CartContext.jsx index ee955fd..6ba618b 100644 --- a/Frontend/src/Components/CartContext.jsx +++ b/Frontend/src/Components/CartContext.jsx @@ -36,6 +36,7 @@ export const CartProvider = ({ children }) => { { + const context = useCart() + const {cart,setCart} = context; const navigate = useNavigate(); const [error, setError] = useState(null); const [cartItems, setCartItems] = useState([]); @@ -34,6 +37,7 @@ const Cart = () => { .then((response) => { const shoppingCart = response.data.shoppingCart; setCartItems(shoppingCart); + setCart(shoppingCart); const initialQuantities = {}; shoppingCart.forEach((item) => { From 0f58b4a9facd9fb41ee9a469af692e93f7880915 Mon Sep 17 00:00:00 2001 From: Vishesh Tripathi Date: Wed, 17 Jul 2024 17:32:24 +0530 Subject: [PATCH 2/2] Fix CartItems issue --- Frontend/src/Components/CartContext.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/Frontend/src/Components/CartContext.jsx b/Frontend/src/Components/CartContext.jsx index 6ba618b..047466c 100644 --- a/Frontend/src/Components/CartContext.jsx +++ b/Frontend/src/Components/CartContext.jsx @@ -4,6 +4,7 @@ import { createContext, useContext, useState } from 'react'; const CartContext = createContext(); export const CartProvider = ({ children }) => { + //changes const [cart, setCart] = useState([]); const [userData, setUserData] = useState(''); // Add user data state const addToCart = (product) => {