react-version #1

Merged
memartel_loc merged 290 commits from react-version into main 2023-11-04 09:48:15 -04:00
2 changed files with 7 additions and 28 deletions
Showing only changes of commit c7070de05e - Show all commits

View File

@ -14,7 +14,7 @@ const FeaturedList = ({ products }) => {
<FeaturedImage productId={product.id}/>
<Carousel.Caption className="featured-info">
<h3>{product.title}</h3>
<p>{product.description}</p>
<p>{(product.description).substring(0,100)}...</p>
<h5>Seulement</h5>
<h4 className="featured-prc">{product.promoPrice} $ CA</h4>
</Carousel.Caption>

View File

@ -8,31 +8,15 @@ const MorceauDetail = () => {
const { id } = useParams();
const [item, setItem] = useState({});
const [isLoading, setIsLoading] = useState(false);
const [imageSrc, setImageSrc] = useState(null);
const [itemQty, setItemQty] = useState(0);
const updateQty = () => {
window.setTimeout(() => {
fetch(`https://localhost:7292/api/Product/Quantity?id=${id}`)
.then(async (response) => {
if (response.ok) {
const qty = await response.json();
setItemQty(qty);
}
else {
console.log("Un erreur est survenu lors de l'appelle de: "
+ `https://localhost:7292/api/Product/Quantity?id=${id}`);
}
updateQty();
})
}, 10000);
const isNoStock = () => {
return item.status == 1 || item.status == 2 || item.status == 5;
}
useEffect(() => {
document.title = 'Morceaux';
setIsLoading(true);
async function fetchData() {
const response = await fetch(`https://localhost:7292/api/Product?id=${id}`);
const json = await response.json();
@ -48,13 +32,8 @@ const MorceauDetail = () => {
.then(blob => {
const imageUrl = URL.createObjectURL(blob);
setImageSrc(imageUrl);
})
});
setIsLoading(false);
});
useEffect(() => {
}, []);
@ -150,15 +129,15 @@ const MorceauDetail = () => {
</div>
<h5>
Qté. restante: {item.status == 1 || item.status == 2 || item.status == 5 ? "Aucun" : itemQty}
Qté. restante: {isNoStock() ? "Aucun" : itemQty}
</h5>
<p className="detail-description">{item.description}</p>
</div>
<div className="detail-container-controls">
<QtySelect
qty={itemQty}
qty={isNoStock() ? 0 : itemQty}
/>
<Button className="add-to-cart">
<Button disabled={isNoStock()} className="add-to-cart">
Ajouter au panier
</Button>