diff --git a/workloads/ecommerce/components/product/product-card.tsx b/workloads/ecommerce/components/product/product-card.tsx index dce0e7a..d7de6d4 100644 --- a/workloads/ecommerce/components/product/product-card.tsx +++ b/workloads/ecommerce/components/product/product-card.tsx @@ -3,6 +3,7 @@ import Image from "next/image"; import Link from "next/link"; import { Heart, ShoppingBag, Sparkles } from "lucide-react"; +import { useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import type { Product } from "@/lib/headless/types"; @@ -21,6 +22,8 @@ export function ProductCard({ product, priority = false }: { product: Product; p ? Math.round((1 - product.price / product.compareAtPrice) * 100) : null; + const [selectedVariantId, setSelectedVariantId] = useState(product.variants[0]?.id); + return (
@@ -32,12 +35,33 @@ export function ProductCard({ product, priority = false }: { product: Product; p
{product.category}{product.collection}

{product.name}

{product.shortDescription}

+ {product.variants.length > 1 && ( +
+ {product.variants.map((variant) => ( + + ))} +
+ )}
{product.compareAtPrice && {formatMoney(product.compareAtPrice, product.currency)}} {formatMoney(product.price, product.currency)}
- +