fixed some bugs

This commit is contained in:
@jcarymuhammedow
2026-04-17 18:38:16 +05:00
parent 68382648a8
commit 6ef7aa3c47
15 changed files with 171 additions and 39 deletions

View File

@@ -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}`}>