From 2fc54c221bd10b9f92c6678fb2b8063e531e7a65 Mon Sep 17 00:00:00 2001 From: dharshib Date: Mon, 5 Aug 2024 07:12:21 +0530 Subject: [PATCH] fixed the image not showing issue --- src/User/components/Products/ProductDetails.jsx | 2 +- src/User/pages/Order/Wishlist.jsx | 2 +- src/User/redux/cartSlice.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/User/components/Products/ProductDetails.jsx b/src/User/components/Products/ProductDetails.jsx index 3ecba7e1c..a6d796638 100644 --- a/src/User/components/Products/ProductDetails.jsx +++ b/src/User/components/Products/ProductDetails.jsx @@ -263,8 +263,8 @@ const ProductPage = () => { try { const response = await axios.get(`https://dummyjson.com/products/${productId}`); const requiredProduct = response.data; - console.log(response.data) requiredProduct.newPrice = getNewPrice(requiredProduct.discountPercentage, requiredProduct.price) + requiredProduct.image = requiredProduct.images[0] || requiredProduct.thumbnail setProduct(requiredProduct); } catch (error) { console.error("Axios error:", error); diff --git a/src/User/pages/Order/Wishlist.jsx b/src/User/pages/Order/Wishlist.jsx index 3bff5e537..5fa9fcf46 100644 --- a/src/User/pages/Order/Wishlist.jsx +++ b/src/User/pages/Order/Wishlist.jsx @@ -35,7 +35,7 @@ const WishlistItem = ({ product, onUpdate, onAddToCart, isExistsInTheCart }) => style={{ border: "1px solid black" }}>
{product.title} diff --git a/src/User/redux/cartSlice.jsx b/src/User/redux/cartSlice.jsx index e7e4fd964..1160651d8 100644 --- a/src/User/redux/cartSlice.jsx +++ b/src/User/redux/cartSlice.jsx @@ -29,7 +29,7 @@ const cartSlice = createSlice({ oldPrice: product.price || product.oldPrice, newPrice: product.newPrice, total: newQuantity * product.newPrice, - image: product.thumbnail, + image: product.image, } : [] )