fix: product detail view for parapharmacy products
- Updated ProductView to use correct endpoint for parapharmacy - Updated getProduct service to handle parapharmacy products - Shows price, category, brand, source for parapharmacy products - Updated labels from 'OFF' to 'Parafarmacia'
This commit is contained in:
@@ -62,7 +62,7 @@ export default function ProductDetailScreen() {
|
||||
<View style={styles.nameRow}>
|
||||
<Text style={[styles.name, { color: colors.text }]}>{product.name}</Text>
|
||||
<View style={[styles.badge, { backgroundColor: isCima ? '#2b5bb5' : '#4caf50' }]}>
|
||||
<Text style={styles.badgeText}>{isCima ? 'CIMA' : 'OFF'}</Text>
|
||||
<Text style={styles.badgeText}>{isCima ? 'CIMA' : 'Parafarmacia'}</Text>
|
||||
</View>
|
||||
</View>
|
||||
{product.brand ? (
|
||||
@@ -92,21 +92,21 @@ export default function ProductDetailScreen() {
|
||||
</View>
|
||||
) : (
|
||||
<View style={[styles.infoSection, { backgroundColor: colors.card }]}>
|
||||
<Text style={[styles.sectionTitle, { color: colors.text }]}>Información nutricional</Text>
|
||||
{product.nutriscore && (
|
||||
<InfoRow label="Nutri-Score" value={product.nutriscore.toUpperCase()} colors={colors} />
|
||||
<Text style={[styles.sectionTitle, { color: colors.text }]}>Información del producto</Text>
|
||||
{product.price != null && (
|
||||
<InfoRow label="Precio" value={`${product.price} €`} colors={colors} />
|
||||
)}
|
||||
{product.nova_group != null && (
|
||||
<InfoRow label="Grupo NOVA" value={String(product.nova_group)} colors={colors} />
|
||||
{product.original_price != null && product.original_price > (product.price || 0) && (
|
||||
<InfoRow label="Precio anterior" value={`${product.original_price} €`} colors={colors} />
|
||||
)}
|
||||
{product.eco_score && (
|
||||
<InfoRow label="Eco-Score" value={product.eco_score.toUpperCase()} colors={colors} />
|
||||
{product.category && (
|
||||
<InfoRow label="Categoría" value={product.category} colors={colors} />
|
||||
)}
|
||||
{product.ingredients && (
|
||||
<View style={[styles.infoRow, { borderBottomColor: colors.border }]}>
|
||||
<Text style={[styles.infoLabel, { color: colors.textSecondary }]}>Ingredientes</Text>
|
||||
<Text style={[styles.infoValueMultiline, { color: colors.text }]}>{product.ingredients}</Text>
|
||||
</View>
|
||||
{product.brand && (
|
||||
<InfoRow label="Marca" value={product.brand} colors={colors} />
|
||||
)}
|
||||
{product.source_url && (
|
||||
<InfoRow label="Fuente" value={product.source || 'Parafarmacia'} colors={colors} />
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -105,7 +105,12 @@ export async function getParapharmacyBrands(): Promise<string[]> {
|
||||
|
||||
export async function getProduct(source: string, id: string): Promise<Product | null> {
|
||||
try {
|
||||
const { data } = await api.get<Product>(`/products/${source}/${id}`);
|
||||
// Use different endpoint for parapharmacy products
|
||||
const endpoint = source === 'parapharmacy'
|
||||
? `/products/parapharmacy/${id}`
|
||||
: `/products/${source}/${id}`;
|
||||
|
||||
const { data } = await api.get<Product>(endpoint);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('[Products] Detail error:', error);
|
||||
|
||||
Reference in New Issue
Block a user