Loading cat for images.
This commit is contained in:
@@ -2,24 +2,33 @@ import { useState, useEffect } from "react";
|
||||
|
||||
const FeaturedImage = ({ productId }) => {
|
||||
|
||||
const [imageSrc, setImageSrc] = useState("/images/default_thumbnail.jpg");
|
||||
const [imageSrc, setImageSrc] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(`https://localhost:7292/api/Image?id=${productId}`)
|
||||
.then(response => response.blob())
|
||||
.then(blob => {
|
||||
const imageUrl = URL.createObjectURL(blob);
|
||||
setImageSrc(imageUrl);
|
||||
})
|
||||
},[]);
|
||||
.then(response => response.blob())
|
||||
.then(blob => {
|
||||
const imageUrl = URL.createObjectURL(blob);
|
||||
setImageSrc(imageUrl);
|
||||
})
|
||||
}, []);
|
||||
|
||||
|
||||
return (
|
||||
<img
|
||||
className="featured-img"
|
||||
src={imageSrc}
|
||||
alt={productId + "_image"}
|
||||
/>
|
||||
<>
|
||||
{!imageSrc ?
|
||||
<div
|
||||
className="cat-load" /> :
|
||||
|
||||
<img
|
||||
className="featured-img"
|
||||
src={imageSrc}
|
||||
alt={productId + "_image"}
|
||||
/>
|
||||
}
|
||||
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -83,7 +83,7 @@ function renderPrice(price, newPrice, status) {
|
||||
|
||||
const Item = ({ productId, name, price, newPrice, status }) => {
|
||||
|
||||
const [imageSrc, setImageSrc] = useState("/images/default_thumbnail.jpg");
|
||||
const [imageSrc, setImageSrc] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(`https://localhost:7292/api/Image?id=${productId}&thumbnail=true`)
|
||||
@@ -99,6 +99,7 @@ const Item = ({ productId, name, price, newPrice, status }) => {
|
||||
return (
|
||||
|
||||
<Card className="item">
|
||||
<div className={!imageSrc ? "cat-load" : "d-none cat-load"} />
|
||||
<Card.Img className="item-img" variant="top" src={imageSrc} />
|
||||
<Card.Body className="item-info">
|
||||
<div className="item-name-container">
|
||||
|
Reference in New Issue
Block a user