diff --git a/apps/frontend-mobile/app/product/[source]/[id].tsx b/apps/frontend-mobile/app/product/[source]/[id].tsx index 3659e67..c5f6557 100644 --- a/apps/frontend-mobile/app/product/[source]/[id].tsx +++ b/apps/frontend-mobile/app/product/[source]/[id].tsx @@ -62,7 +62,7 @@ export default function ProductDetailScreen() { {product.name} - {isCima ? 'CIMA' : 'OFF'} + {isCima ? 'CIMA' : 'Parafarmacia'} {product.brand ? ( @@ -92,21 +92,21 @@ export default function ProductDetailScreen() { ) : ( - Información nutricional - {product.nutriscore && ( - + Información del producto + {product.price != null && ( + )} - {product.nova_group != null && ( - + {product.original_price != null && product.original_price > (product.price || 0) && ( + )} - {product.eco_score && ( - + {product.category && ( + )} - {product.ingredients && ( - - Ingredientes - {product.ingredients} - + {product.brand && ( + + )} + {product.source_url && ( + )} )} diff --git a/apps/frontend-mobile/services/products.ts b/apps/frontend-mobile/services/products.ts index 43f85ac..9da3168 100644 --- a/apps/frontend-mobile/services/products.ts +++ b/apps/frontend-mobile/services/products.ts @@ -105,7 +105,12 @@ export async function getParapharmacyBrands(): Promise { export async function getProduct(source: string, id: string): Promise { try { - const { data } = await api.get(`/products/${source}/${id}`); + // Use different endpoint for parapharmacy products + const endpoint = source === 'parapharmacy' + ? `/products/parapharmacy/${id}` + : `/products/${source}/${id}`; + + const { data } = await api.get(endpoint); return data; } catch (error) { console.error('[Products] Detail error:', error); diff --git a/apps/frontend/src/views/ProductView.jsx b/apps/frontend/src/views/ProductView.jsx index 7f31f36..64554ea 100644 --- a/apps/frontend/src/views/ProductView.jsx +++ b/apps/frontend/src/views/ProductView.jsx @@ -17,13 +17,18 @@ export default function ProductView({ source, id, onBack }) { setError(null); setPharmacies([]); try { - const response = await fetch(`/api/products/${source}/${id}`); + // Use different endpoint for parapharmacy products + const apiUrl = source === 'parapharmacy' + ? `/api/products/parapharmacy/${id}` + : `/api/products/${source}/${id}`; + + const response = await fetch(apiUrl); if (!response.ok) { throw new Error('Producto no encontrado'); } const data = await response.json(); setProduct(data); - loadPharmacies(source, data.id); + loadPharmacies(source, data.id || data._id); } catch (err) { setError(err.message); } finally { @@ -71,8 +76,9 @@ export default function ProductView({ source, id, onBack }) { if (!product) return null; const isCima = product.source === 'cima'; + const isParapharmacy = product.source !== 'cima'; const sourceColor = isCima ? '#2563eb' : '#16a34a'; - const sourceLabel = isCima ? 'CIMA' : 'Open Food Facts'; + const sourceLabel = isCima ? 'CIMA' : 'Parafarmacia'; return (
@@ -116,17 +122,20 @@ export default function ProductView({ source, id, onBack }) { ) : ( <> - {product.nutriscore && product.nutriscore !== 'not-applicable' && product.nutriscore !== 'unknown' && ( - + {product.price && ( + )} - {product.nova_group && ( - + {product.original_price && product.original_price > product.price && ( + )} - {product.eco_score && product.eco_score !== 'unknown' && ( - + {product.category && ( + )} - {product.ingredients && ( - + {product.brand && ( + + )} + {product.source_url && ( + )} )}