Browse Source

add default on no image

master
azri 1 month ago
parent
commit
5c94d1e063

BIN
src/assets/images/default.png View File


+ 2
- 1
src/components/ProductList/ProductList.jsx View File

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

+ 2
- 1
src/components/ProductSelected/ProductSelected.jsx View File

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

Loading…
Cancel
Save