"use client"; import { Button, Caption, Text } from "@/components/atoms"; import Image from "next/image"; import type { ProductCardProps } from "./Card.types"; /** * Product card — fills the parent grid cell width (w-full). * * Layout (top → bottom): * 1. Image area (fixed height h-36) with coffee-mug fallback icon * 2. Name + description (flex-1, grows to fill space) * 3. Price + Buy button row (pinned to bottom) * * Responsive: card width is controlled by the parent grid, not the card itself. */ export default function ProductCard({ image, imageAlt = "Ảnh sản phẩm", productName, price, description, onBuy, }: ProductCardProps) { const formattedPrice = typeof price === "number" ? price.toLocaleString("vi-VN", { style: "currency", currency: "VND" }) : price; return (
{/* ── Image area ── */}
{/* Fallback icon (shown when image fails or is missing) */}
{/* Product image */} {imageAlt} { (e.currentTarget as HTMLImageElement).style.display = "none"; }} />
{/* ── Name + description ── */}

{productName}

{description}
{/* ── Price + Buy button ── */}
{formattedPrice}
); }