import { useState } from 'react' import { Link } from 'react-router-dom' import { formatPrice, Product } from '../api' import { IconLeaf } from './Icons' import OriginBadge from './OriginBadge' export default function ProductCard({ product }: { product: Product }) { const [imageFailed, setImageFailed] = useState(false) const image = product.images.length > 0 ? product.images[0] : null const showImage = image !== null && !imageFailed return (
{showImage ? ( {product.title} setImageFailed(true)} /> ) : ( )}

{product.title}

{product.price !== null ? ( {formatPrice(product.price)} ) : ( Prix variable )} {product.compare_at_price !== null && product.price !== null && product.compare_at_price > product.price && ( {formatPrice(product.compare_at_price)} )}

{product.store_name} {product.store_region ? ` ยท ${product.store_region}` : ''}

) }