fix: use _id for MongoDB products in frontend

- SearchView now uses p._id || p.id for product navigation
- ProductResults uses product._id || product.id for React key
- Fixes 'undefined' error when clicking parapharmacy products
This commit is contained in:
Antoni Nuñez Romeu
2026-07-16 16:18:22 +02:00
parent e5dcfbd2f5
commit 63b25e3f4f
2 changed files with 4 additions and 3 deletions
@@ -39,7 +39,7 @@ function ProductResults({ products, onSelect }) {
<div className="product-results">
{products.map((product) => (
<ProductCard
key={product.id}
key={product._id || product.id}
product={product}
onSelect={onSelect}
/>
+3 -2
View File
@@ -322,10 +322,11 @@ function SearchView({ currentUser, onLoginRequest, initialQuery = '', onNavigate
<ProductResults
products={products}
onSelect={(p) => {
const productId = p._id || p.id;
if (onNavigateToProduct) {
onNavigateToProduct(p.source, p.id);
onNavigateToProduct(p.source, productId);
} else {
window.location.href = `/product/${p.source}/${p.id}`;
window.location.href = `/product/${p.source}/${productId}`;
}
}}
/>