浏览代码

add default on no image

master
azri 1 个月前
父节点
当前提交
5c94d1e063

二进制
src/assets/images/default.png 查看文件


+ 2
- 1
src/components/ProductList/ProductList.jsx 查看文件

@@ -14,6 +14,7 @@ import { styled } from "@mui/material";
14 14
 import { useSelector, useDispatch } from "react-redux";
15 15
 import { fetchProducts } from "../../redux/slices/productSlice";
16 16
 import { useNavigate } from "react-router-dom";
17
+import defaultImage from "../../assets/images/default.png"
17 18
 
18 19
 //UTIL FUNCTION
19 20
 function getAllTags(data) {
@@ -429,7 +430,7 @@ const ProductList = ({ size = 99999 }) => {
429 430
             let minPriceCurrency = minVariantPrice.currencyCode;
430 431
             let maxPrice = maxVariantPrice.amount;
431 432
             let maxPriceCurrency = maxVariantPrice.currencyCode;
432
-            let img_url = images[0]?.url;
433
+            let img_url = images[0]?.url || defaultImage;
433 434
             let collection_name = collections[0]?.title;
434 435
 
435 436
             if (index < size) {

+ 2
- 1
src/components/ProductSelected/ProductSelected.jsx 查看文件

@@ -9,6 +9,7 @@ import { Scrollbar, A11y } from 'swiper/modules';
9 9
 
10 10
 import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
11 11
 import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
12
+import defaultImage from "../../assets/images/default.png"
12 13
 
13 14
 const ProductSelected = () => {
14 15
 
@@ -195,7 +196,7 @@ const ProductSelected = () => {
195 196
             let maxPrice = maxVariantPrice.amount
196 197
             let maxPriceCurrency = maxVariantPrice.currencyCode
197 198
 
198
-            let img_url = images[0]?.url
199
+            let img_url = images[0]?.url || defaultImage
199 200
             let collection_name = collections[0]?.title
200 201
 
201 202
             return (

正在加载...
取消
保存