const NUTRISCORE_DESC = { A: "Qualità nutrizionale eccellente", B: "Buona qualità nutrizionale", C: "Qualità nutrizionale nella media", D: "Scarsa qualità nutrizionale", E: "Cattiva qualità nutrizionale", }; const ECOSCORE_DESC = { A: "Impatto ambientale molto basso", B: "Impatto ambientale basso", C: "Impatto ambientale moderato", D: "Impatto ambientale alto", E: "Impatto ambientale molto alto", }; const NOVA_DESC = { 1: "Alimenti non trasformati o minimamente trasformati", 2: "Ingredienti culinari trasformati", 3: "Alimenti trasformati", 4: "Alimenti ultra-trasformati", }; function ScoreScale({ grade, scale, colorFn, label, subtitle, descriptions }) { grade = !grade || grade.toLowerCase() === "unknown" ? null : grade; if (!grade) return null; return (
{label}
{subtitle}
{scale.map((s) => { const active = s === grade; return (
{s}
); })}
{grade && descriptions?.[grade] ? (
{descriptions[grade]}
) : (
Nessun dato
)}
); } function NutritionPanel({ match }) { if (!match) return (
Nessun prodotto collegato — premi "Trova abbinamento" per cercare su OpenFoodFacts.
); const isWeighted = match.is_weighted; const link = match.off_found ? `https://world.openfoodfacts.org/product/${match.barcode}` : null; const novaGrade = match.nova_group != null ? String(match.nova_group) : null; const levels = match.nutrient_levels || {}; const nutrients = [ [ "Energia", match.energy_kcal != null ? `${Math.round(match.energy_kcal)} kcal` : null, null, ], [ "Carboidrati", match.carbohydrates != null ? `${fmt(match.carbohydrates)} g` : null, null, ], [ "· Zuccheri", match.sugars != null ? `${fmt(match.sugars)} g` : null, levels.sugars, ], ["Grassi", match.fat != null ? `${fmt(match.fat)} g` : null, levels.fat], [ "· Grassi saturi", match.saturated_fat != null ? `${fmt(match.saturated_fat)} g` : null, levels.saturated_fat, ], ["Fibre", match.fiber != null ? `${fmt(match.fiber)} g` : null, null], [ "Proteine", match.proteins != null ? `${fmt(match.proteins)} g` : null, null, ], ["Sale", match.salt != null ? `${fmt(match.salt)} g` : null, levels.salt], ].filter(([, v]) => v != null); const allergens = match.allergens || []; const traces = match.traces || []; const packaging = match.packaging || []; const additives = match.additives || []; return (
{/* Product identity */}
Nome prodotto
{match.product_name || "—"}
{match.brands && (
Marca
{match.brands}
)} {match.quantity && (
Quantità
{match.quantity}
)} {match.barcode && (
{isWeighted ? "Articolo a peso" : "Codice a barre"}
{isWeighted ? `indice articolo ${match.barcode}` : match.barcode}
)} {link && (
Fonte
)}
{match.categories?.length > 0 && (
Categorie
{match.categories.map((cat, i) => ( {i > 0 && ( )} {cat} ))}
)} {match.suggested_from && (
Tipo abbinamento: SUGGERITO DA {match.suggested_from.toUpperCase()}
)} {(match.vegan || match.vegetarian || match.palm_oil || match.additives_n != null) && (
Dieta e lavorazione
{match.additives_n === 0 && ( SENZA ADDITIVI )} {match.additives_n > 0 && ( {match.additives_n}{" "} {match.additives_n > 1 ? "ADDITIVI" : "ADDITIVO"} )}
)}
{/* Score scales */}
novaColor(parseInt(g))} label="NOVA" subtitle="Lavorazione" descriptions={NOVA_DESC} />
{/* Nutrients */} {nutrients.length > 0 && (
{nutrients.map(([label, value, level]) => { const sub = label.startsWith("·"); return (
{sub ? label.slice(1).trim() : label} {value}
); })}
)} {/* Allergens */} {(allergens.length > 0 || traces.length > 0) && ( {allergens.length > 0 && (
{allergens.map((a) => ( {a} ))}
)} {traces.length > 0 && (
Può contenere: {traces.join(", ")}
)}
)} {/* Ingredients */} {match.ingredients_text && (

{match.ingredients_text}

)} {/* Additives */} {additives.length > 0 && (
{additives.map((a) => ( {a} ))}
)} {/* Packaging */} {packaging.length > 0 && (
{packaging.map((p) => ( {p} ))}
)} {/* Origin & Manufacturing */} {(match.origin || match.manufacturing_places) && (
{match.origin && (
Origine ingredienti: {match.origin}
)} {match.manufacturing_places && (
Prodotto in: {match.manufacturing_places}
)}
)}
); }