fixed some bugs
This commit is contained in:
@@ -225,6 +225,12 @@ const ProductCard = ({
|
||||
|
||||
const { name, price_amount, old_price_amount, media = [], reviews } = product;
|
||||
|
||||
// Hesaplanmış indirim oranı
|
||||
let calculatedDiscount = null;
|
||||
if (!product.discount && old_price_amount && price_amount && old_price_amount > price_amount) {
|
||||
calculatedDiscount = Math.round(((old_price_amount - price_amount) / old_price_amount) * 100);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
@@ -234,8 +240,10 @@ const ProductCard = ({
|
||||
onMouseLeave={() => setIsHovered(false)}
|
||||
>
|
||||
<div className={styles.imageContainer}>
|
||||
{product.discount && (
|
||||
<span className={styles.discountBadge}>-{product.discount}%</span>
|
||||
{(product.discount || calculatedDiscount) && (
|
||||
<span className={styles.discountBadge}>
|
||||
-{product.discount ? product.discount : calculatedDiscount}%
|
||||
</span>
|
||||
)}
|
||||
{product.stock === 0 && (
|
||||
<span className={`${styles.discountBadge} ${styles.outOfStock}`}>
|
||||
|
||||
Reference in New Issue
Block a user