product: fix count badge

This commit is contained in:
2025-11-11 18:20:17 +03:00
parent 73504dd583
commit 724f201d47
2 changed files with 33 additions and 98 deletions

View File

@@ -230,48 +230,40 @@ export function MenuList({ data, categoryRefs }: MenuListProps) {
style={{ width: 24, height: 24 }}
/>
)}
<ImageWithFallback
src={item.image_small || "/default.png"}
fallbackSrc="/default.png"
alt={item.name}
className={`${styles.popularMenuItemImage} ${
isMobile
? styles.popularMenuItemImageMobile
: isTablet
? styles.popularMenuItemImageTablet
: styles.popularMenuItemImageDesktop
}`}
width={90}
height={90}
/>
<AddToCartButton />
{items.some((i) => i.id === item.id) && (
<Badge
count={
items
.filter((i) => i.id === item.id)
.reduce((total, item) => total + item.quantity, 0)
}
className={
styles.cartBadge +
" " +
(isRTL
? styles.cartBadgeRTL
: styles.cartBadgeLTR)
}
style={{
backgroundColor: colors.primary,
}}
title={`${
items
.filter((i) => i.id === item.id)
.reduce((total, item) => total + item.quantity, 0)
} in cart`}
<Badge
size="default"
offset={[-3, 3]}
count={items
.filter((i) => i.id === item.id)
.reduce(
(total, item) => total + item.quantity,
0,
)}
color={colors.primary}
title={`${items
.filter((i) => i.id === item.id)
.reduce(
(total, item) => total + item.quantity,
0,
)} in cart`}
>
<ImageWithFallback
src={item.image_small || "/default.png"}
fallbackSrc="/default.png"
alt={item.name}
className={`${styles.popularMenuItemImage} ${
isMobile
? styles.popularMenuItemImageMobile
: isTablet
? styles.popularMenuItemImageTablet
: styles.popularMenuItemImageDesktop
}`}
width={90}
height={90}
/>
)}
<AddToCartButton />
</Badge>
</div>
</div>
</Card>