diff --git a/workloads/ecommerce/components/product/product-card.tsx b/workloads/ecommerce/components/product/product-card.tsx index 2326496..dce0e7a 100644 --- a/workloads/ecommerce/components/product/product-card.tsx +++ b/workloads/ecommerce/components/product/product-card.tsx @@ -16,19 +16,29 @@ export function ProductCard({ product, priority = false }: { product: Product; p const wishlistHydrated = useWishlistStore((state) => state.hasHydrated); const toggleProduct = useWishlistStore((state) => state.toggleProduct); const isFavorite = wishlistHydrated && wishlistProducts.some((item) => item.id === product.id); + const discountPercent = + product.compareAtPrice && product.price + ? Math.round((1 - product.price / product.compareAtPrice) * 100) + : null; return (
{product.name} -
{product.isNew && Nuevo}{product.featured && Top}
+
{discountPercent && discountPercent > 0 && -{discountPercent}%}{product.isNew && Nuevo}{product.featured && Top}
{product.category}{product.collection}

{product.name}

{product.shortDescription}

-
{formatMoney(product.price, product.currency)}
+
+
+ {product.compareAtPrice && {formatMoney(product.compareAtPrice, product.currency)}} + {formatMoney(product.price, product.currency)} +
+ +
);