Skip to content

Commit

Permalink
Merge pull request #2137 from DharshiBalasubramaniyam/product-detail
Browse files Browse the repository at this point in the history
Fix - Product image not showing in the cart and wishlist
  • Loading branch information
codervivek5 authored Aug 5, 2024
2 parents 2f0bb3a + 2fc54c2 commit a6bf2a8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/User/components/Products/ProductDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/User/pages/Order/Wishlist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const WishlistItem = ({ product, onUpdate, onAddToCart, isExistsInTheCart }) =>
style={{ border: "1px solid black" }}>
<div className="flex items-center">
<img
src={product.thumbnail}
src={product.image}
alt={product.title}
className="w-32 h-32 md:w-20 md:h-20 rounded-lg mr-4"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/User/redux/cartSlice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
: []
)
Expand Down

0 comments on commit a6bf2a8

Please sign in to comment.