// ----------------------------------------------------------------------------- // Food-Ka — Agrégateur de produits d'épicerie (province de Québec) // Auteur : Simon-Pierre Boucher — contact@spboucher.ai // components/ProductCard.tsx : carte produit (grille de résultats) // Prix courant + prix régulier barré et badge « -XX % » quand en solde, // prix unitaire comparable, bannière d'origine. // ----------------------------------------------------------------------------- import { Link } from "react-router-dom"; import { Product, discountPct, fmtPrice } from "../api"; import SourceLogo from "./SourceLogo"; export default function ProductCard({ p }: { p: Product }) { const img = p.images && p.images.length > 0 ? p.images[0] : null; const pct = discountPct(p); return (
{img ? ( {p.name} ) : (
🛒
)} {p.on_sale && ( {pct != null ? `−${pct} %` : "En solde"} )} {p.in_stock === false && Rupture}
{fmtPrice(p.price, p.price_label)} {p.on_sale && p.regular_price != null && ( {fmtPrice(p.regular_price)} )}
{p.unit_price_label && (
{p.unit_price_label}
)}
{p.name}
{p.brand && {p.brand}} {p.brand && p.size_label && } {p.size_label && {p.size_label}}
{p.category && {p.category}}
); }