'use client'; import { Image as ImageIcon } from 'lucide-react'; import { Link } from '@/core/lib/navigation'; import { CdnImage as Image } from '@/ui/shared/cdn-image'; import type { ProductRecommendation } from 'brainerce'; import { PriceDisplay } from '@/ui/product/price-display'; import { cn } from '@/core/lib/utils'; interface RecommendationCardProps { item: ProductRecommendation; className?: string; } function RecommendationCard({ item, className }: RecommendationCardProps) { const firstImage = item.images?.[0]; const imageUrl = typeof firstImage === 'string' ? firstImage : firstImage?.url || null; const slug = item.slug || item.id; // ⛔ NOT region-converted, and it cannot be. `ProductRecommendation` is a // trimmed shape that carries `basePrice` / `salePrice` only: the backend // attaches no displayPrice/displayCurrency to it, so there is no converted // amount to render and converting here would mean inventing an FX rate. // These tiles stay in the store currency on a multi-region store. Do not // "fix" it with a client-side conversion. const basePrice = parseFloat(item.basePrice); const salePrice = item.salePrice ? parseFloat(item.salePrice) : undefined; const isOnSale = salePrice != null && salePrice < basePrice; // ⛔ No price on a KIT tile. The recommendations endpoint does not resolve // kits, so `item.basePrice` here is the kit's stored PLACEHOLDER — right only // for FIXED pricing and wrong for every SUM / SUM_MINUS_PERCENT kit. Showing // it would quote a price the product page then contradicts. The tile still // links through, and the product page reads the resolved price from the API. // Do NOT recompute a kit price on the client. const priceIsUnresolved = item.type === 'KIT'; return (