import Image from "next/image"; import Link from "next/link"; import MixedText from "@/components/MixedText"; import { formatPrice, toFaDigits } from "@/lib/format"; import type { ProductCardData } from "@/lib/types"; export default function ProductCard({ product }: { product: ProductCardData }) { const { href, title, image, price, oldPrice, percent, inStock } = product; const hasOldPrice = price !== null && oldPrice !== null && oldPrice > price; return ( {image ? ( {title} ) : ( بدون تصویر )} {percent > 0 && ( {toFaDigits(percent)}٪ )} {title} {/* The old-price line always occupies its row — rendered empty when there is no discount — so a discounted card is exactly as tall as the rest and every card in a carousel lines up. */} {price !== null && inStock ? ( <> {hasOldPrice ? formatPrice(oldPrice) : ""} {formatPrice(price)} تومان ) : ( <> ناموجود )} ); }