This commit is contained in:
@@ -25,7 +25,8 @@ export default function ProductCard({ product, rating, onPress }) {
|
||||
{rating ? <ProductScoreBadge status={rating.overallStatus} score={rating.overallScore} /> : null}
|
||||
<Text style={styles.openLabel}>Details ansehen ›</Text>
|
||||
</View>
|
||||
{rating?.allergenReviewRequired ? <Text style={styles.allergenWarning}>Allergenangaben fehlen – Verpackung prüfen.</Text> : null}
|
||||
{rating?.allergenReviewRequired ? <Text style={styles.allergenWarning}>{rating.allergenReviewMessage}</Text> : null}
|
||||
{rating?.staleDataReviewRequired ? <Text style={styles.allergenWarning}>Gespeicherte Produktdaten sind veraltet.</Text> : null}
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,24 +69,42 @@ export default function ProductDetailScreen({
|
||||
<Text style={styles.meta}>
|
||||
{product.category || 'Produkt'} · {formatPrice(pricedProduct.price, currency)}
|
||||
</Text>
|
||||
<Text style={styles.source}>{sourceLabel(product.dataSource)}</Text>
|
||||
<Text style={styles.source}>{sourceLabel(product.dataSource)}{product.cacheStale ? ' · Veraltete Daten' : ''}</Text>
|
||||
{['cache', 'open-food-facts'].includes(product.dataSource) ? <Text style={styles.meta}>Produktdaten geprüft: {formatCheckedDate(product.fetchedAt)}</Text> : null}
|
||||
</View>
|
||||
<ProductScoreBadge status={rating.overallStatus} score={rating.overallScore} />
|
||||
</View>
|
||||
<View style={[styles.recommendation, styles[`${rating.overallStatus}Recommendation`]]}>
|
||||
<Text style={[styles.recommendationTitle, styles[`${rating.overallStatus}Text`]]}>{recommendation}</Text>
|
||||
<Text style={styles.recommendationCopy}>
|
||||
{rating.allergenReviewRequired
|
||||
? 'Allergenangaben fehlen oder sind nicht bestätigt. Prüfe vor dem Kauf die Verpackung.'
|
||||
{rating.hasBlockedAllergen
|
||||
? rating.categoryScores.allergies.message
|
||||
: rating.allergenReviewRequired
|
||||
? rating.allergenReviewMessage
|
||||
: rating.staleDataReviewRequired
|
||||
? 'Gespeicherte Produktdaten sind veraltet. Prüfe vor dem Kauf die Verpackung.'
|
||||
: rating.overallStatus === 'unknown'
|
||||
? 'Für eine Empfehlung fehlen belastbare Produktangaben.'
|
||||
: rating.limitedByMissingData
|
||||
? 'Nur ein Teil der Kriterien ist belegt. Die Empfehlung ist deshalb auf „Prüfen“ begrenzt.'
|
||||
: 'Tippe unten auf ein Kriterium, um die Bewertung nachzuvollziehen.'}
|
||||
</Text>
|
||||
<Text style={styles.recommendationCopy}>Bewertbare Daten: {rating.dataCoverage}% der für dein Profil anwendbaren Kriterien (gewichtet).</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{rating.mainFactors.length > 0 || rating.scoreLimitReasons.length > 0 ? (
|
||||
<View style={styles.dataPanel}>
|
||||
<Text style={styles.factorTitle}>Wichtigste Einflüsse auf die App-Bewertung</Text>
|
||||
{rating.scoreLimitReasons.map((reason) => <Text key={reason} style={styles.dataText}>{reason}</Text>)}
|
||||
{rating.mainFactors.map((factor) => (
|
||||
<Text key={factor.category} style={styles.dataText}>
|
||||
{factor.label}: {factor.score}/100 · {factor.message}
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{!hasProductPrice ? (
|
||||
<View style={styles.pricePanel}>
|
||||
<Text style={styles.priceTitle}>Ladenpreis ergänzen</Text>
|
||||
@@ -168,14 +186,22 @@ export default function ProductDetailScreen({
|
||||
</>
|
||||
) : <Text style={styles.dataText}>CO₂-Fussabdruck: Nicht verfügbar.</Text>}
|
||||
<Text style={styles.dataText}>Green-Score (Open Food Facts): {product.sustainability?.ecoScore || 'Nicht verfügbar'}</Text>
|
||||
<Text style={styles.dataText}>Zutatenherkunft: {ingredientOriginLabel(product)}</Text>
|
||||
{(product.sustainability?.sellingCountries || []).length > 0 ? (
|
||||
<Text style={styles.dataText}>Verkaufsländer: {product.sustainability.sellingCountries.map(formatCountryTag).join(', ')}</Text>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<SectionTitle>Produktdaten</SectionTitle>
|
||||
<View style={styles.dataPanel}>
|
||||
<Text style={styles.dataText}>Barcode: {product.barcode}</Text>
|
||||
<Text style={styles.dataText}>Zutaten: {(product.ingredients || []).join(', ') || 'Keine Angaben'}</Text>
|
||||
<Text style={styles.dataText}>Allergene: {(product.allergens || []).join(', ') || 'Keine Angaben'}</Text>
|
||||
<Text style={styles.dataText}>Nutri-Score: {product.nutrition?.nutriScore || 'Keine Angabe'}</Text>
|
||||
<Text style={styles.dataText}>Angegebene Allergene: {(product.allergens || []).join(', ') || 'Keine Angaben'}</Text>
|
||||
<Text style={styles.dataText}>Mögliche Allergenspuren: {(product.allergenTraces || []).join(', ') || 'Keine Angaben'}</Text>
|
||||
<Text style={styles.dataText}>
|
||||
Nutri-Score: {rating.categoryScores.nutrition.nutriScore || 'Keine Angabe'}
|
||||
{rating.categoryScores.nutrition.nutriScoreSource === 'calculated' ? ' (von der App berechnet)' : rating.categoryScores.nutrition.nutriScore ? ' (Open Food Facts)' : ''}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
</ScreenContainer>
|
||||
@@ -203,6 +229,22 @@ function sourceLabel(source) {
|
||||
return labels[source] || 'Quelle: unbekannt';
|
||||
}
|
||||
|
||||
function formatCheckedDate(value) {
|
||||
const date = new Date(value);
|
||||
return Number.isNaN(date.getTime()) ? 'unbekannt' : date.toLocaleDateString('de-CH');
|
||||
}
|
||||
|
||||
function ingredientOriginLabel(product) {
|
||||
const sustainability = product.sustainability || {};
|
||||
if (['cache', 'open-food-facts'].includes(product.dataSource)
|
||||
&& sustainability.originSource !== 'ingredient-origin') return 'Nicht verfügbar';
|
||||
return sustainability.originCountry || 'Nicht verfügbar';
|
||||
}
|
||||
|
||||
function formatCountryTag(tag) {
|
||||
return tag.replace(/^[a-z]{2}:/, '').replace(/-/g, ' ');
|
||||
}
|
||||
|
||||
function formatImpact(value, maximumFractionDigits = 2) {
|
||||
return new Intl.NumberFormat('de-CH', { maximumFractionDigits, minimumFractionDigits: value < 0.01 ? 3 : 0 }).format(value);
|
||||
}
|
||||
@@ -222,6 +264,7 @@ function matchLabel(method) {
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
factorTitle: { color: colors.text, fontSize: 16, fontWeight: '800' },
|
||||
productPanel: {
|
||||
backgroundColor: colors.surface,
|
||||
borderColor: colors.border,
|
||||
|
||||
@@ -16,8 +16,8 @@ const labels = {
|
||||
|
||||
const defaultDetails = {
|
||||
allergies: {
|
||||
positive: 'Keine blockierten Allergene und vollständige Allergenangaben verbessern diese Bewertung.',
|
||||
penalty: 'Treffer mit deinen vermiedenen Allergenen setzen diese Kategorie hart nach unten. Fehlende Allergenangaben werden als Unsicherheit markiert.'
|
||||
positive: 'Eine ausdrücklich bestätigte Abwesenheit deiner vermiedenen Allergene verbessert diese Bewertung.',
|
||||
penalty: 'Ein angegebenes vermiedenes Allergen blockiert die Empfehlung. Mögliche Spuren und nicht bestätigte Abwesenheit erfordern eine Prüfung der Verpackung.'
|
||||
},
|
||||
budget: {
|
||||
positive: 'Ein niedriger Anteil am Budget pro Zeitraum verbessert diese Bewertung.',
|
||||
@@ -28,8 +28,8 @@ const defaultDetails = {
|
||||
penalty: 'Kritische Zusatzstoffe, Palmöl, viele Zusatzstoffe oder ein Konflikt mit deinem Ernährungsziel reduzieren diese Bewertung.'
|
||||
},
|
||||
nutrition: {
|
||||
positive: 'Guter Nutri-Score, niedrige kritische Nährwert-Level und passende Werte für dein Ernährungsziel verbessern diese Bewertung.',
|
||||
penalty: 'Hohe Werte bei Zucker, Salz, Fett oder gesättigten Fettsäuren sowie Konflikte mit Low-Sugar- oder High-Protein-Zielen reduzieren diese Bewertung.'
|
||||
positive: 'Ein guter Nutri-Score und passende Werte für dein gewähltes Ernährungsziel verbessern diese Bewertung.',
|
||||
penalty: 'Ein schwacher Nutri-Score oder ein Konflikt mit deinem Zucker- oder Proteinziel reduziert diese Bewertung. Nährwerte im Nutri-Score werden nicht nochmals abgezogen.'
|
||||
},
|
||||
sustainability: {
|
||||
positive: 'Guter Eco-Score, niedriger CO2-Fussabdruck, regionale Herkunft, bessere Verpackung und Bio bei Bio-Präferenz verbessern diese Bewertung.',
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { searchProducts } from './productApi.js';
|
||||
import { calculateProductRating } from './ratingService.js';
|
||||
|
||||
const MIN_SCORE_IMPROVEMENT = 5;
|
||||
const MIN_SCORE_IMPROVEMENT = 10;
|
||||
const MIN_CATEGORY_IMPROVEMENT = 10;
|
||||
const INTERNAL_ALTERNATIVE_LIMIT = 8;
|
||||
|
||||
const improvementLabels = {
|
||||
@@ -53,7 +54,9 @@ export async function findAlternatives(product, preferences, productCache = {})
|
||||
.filter((item) => !item.rating.allergenReviewRequired)
|
||||
.filter((item) => productRating.overallScore !== null
|
||||
&& item.rating.overallScore !== null
|
||||
&& item.rating.overallScore >= productRating.overallScore + MIN_SCORE_IMPROVEMENT)
|
||||
&& item.rating.overallScore >= productRating.overallScore + MIN_SCORE_IMPROVEMENT
|
||||
&& item.rating.dataCoverage >= productRating.dataCoverage
|
||||
&& (strongestCategoryImprovement(item.rating, productRating)?.improvement || 0) >= MIN_CATEGORY_IMPROVEMENT)
|
||||
.map((item) => ({
|
||||
...item,
|
||||
reason: buildReason(item.rating, productRating, categoryTerms)
|
||||
|
||||
@@ -49,9 +49,10 @@ const productFields = [
|
||||
export async function lookupProductByBarcode(barcode, productCache = {}, offlineModeEnabled = false) {
|
||||
const normalizedBarcode = normalizeBarcode(barcode);
|
||||
const cachedProduct = productCache[normalizedBarcode] || productCache[barcode];
|
||||
const cacheIsFresh = cachedProduct && isFreshCacheEntry(cachedProduct);
|
||||
|
||||
if (cachedProduct && (offlineModeEnabled || isFreshCacheEntry(cachedProduct))) {
|
||||
return cachedResult(cachedProduct);
|
||||
if (cachedProduct && (offlineModeEnabled || cacheIsFresh)) {
|
||||
return cachedResult(cachedProduct, !cacheIsFresh);
|
||||
}
|
||||
|
||||
if (offlineModeEnabled) {
|
||||
@@ -163,6 +164,7 @@ export function mapOpenFoodFactsProduct(product = {}, fallbackBarcode) {
|
||||
const agribalyseCode = product.environmental_score_data?.agribalyse?.code
|
||||
|| product.ecoscore_data?.agribalyse?.code || product.agribalyse?.code;
|
||||
const footprint = productSpecificFootprint(nutriments, product.quantity, product.last_modified_datetime, product.categories_tags);
|
||||
const originCountry = firstOrigin(product.origins, product.origins_tags);
|
||||
const now = new Date().toISOString();
|
||||
|
||||
return enrichEnvironmentalProduct({
|
||||
@@ -217,8 +219,8 @@ export function mapOpenFoodFactsProduct(product = {}, fallbackBarcode) {
|
||||
footprint,
|
||||
carbonFootprintKgCo2ePerKg: footprint.status === 'product-specific' ? footprint.valueKgCo2ePerKg : undefined,
|
||||
isBio: Array.isArray(product.labels_tags) ? hasOrganicLabel(product.labels_tags) : undefined,
|
||||
originCountry: firstOrigin(product.origins, product.origins_tags),
|
||||
originSource: firstOrigin(product.origins, product.origins_tags) ? 'ingredient-origin' : undefined,
|
||||
originCountry,
|
||||
originSource: originCountry ? 'ingredient-origin' : undefined,
|
||||
sellingCountries: normalizeTags(product.countries_tags),
|
||||
packaging: firstTextValue(product.packaging)
|
||||
},
|
||||
|
||||
@@ -23,6 +23,14 @@ const ecoScoreValues = {
|
||||
E: 15
|
||||
};
|
||||
|
||||
const categoryLabels = {
|
||||
allergies: 'Allergien',
|
||||
budget: 'Budget',
|
||||
ingredients: 'Zutaten',
|
||||
nutrition: 'Ernährung',
|
||||
sustainability: 'Nachhaltigkeit'
|
||||
};
|
||||
|
||||
const additiveRiskGroups = [
|
||||
{
|
||||
id: 'nitrite-nitrate-curing-salts',
|
||||
@@ -134,11 +142,20 @@ export function calculateProductRating(product, preferences) {
|
||||
: Math.min(
|
||||
capOverallScoreForCriticalAdditives(weightedScore, criticalAdditiveCount),
|
||||
coverageCap,
|
||||
allergenReviewRequired ? 77 : 100
|
||||
allergenReviewRequired ? 77 : 100,
|
||||
product.cacheStale ? 77 : 100
|
||||
);
|
||||
const limitedByMissingData = !hasBlockedAllergen && weightedScore !== null
|
||||
&& weightedScore > coverageCap && overallScore === coverageCap;
|
||||
const overallStatus = overallScore === null ? 'unknown' : statusFromScore(overallScore);
|
||||
const scoreLimitReasons = [];
|
||||
if (hasBlockedAllergen) scoreLimitReasons.push('Ein vermiedenes Allergen ist angegeben.');
|
||||
if (allergenReviewRequired) scoreLimitReasons.push(categoryScores.allergies.reviewMessage);
|
||||
if (product.cacheStale) scoreLimitReasons.push('Gespeicherte Produktdaten sind veraltet. Verpackung prüfen.');
|
||||
if (criticalAdditiveCount > 0 && weightedScore > capOverallScoreForCriticalAdditives(weightedScore, criticalAdditiveCount)) {
|
||||
scoreLimitReasons.push('Die Regel für kritische Zusatzstoffe begrenzt die Gesamtwertung.');
|
||||
}
|
||||
if (limitedByMissingData) scoreLimitReasons.push('Fehlende Daten begrenzen die Gesamtwertung.');
|
||||
|
||||
const reasons = Object.entries(categoryScores).map(([category, value]) => ({
|
||||
category,
|
||||
@@ -153,6 +170,11 @@ export function calculateProductRating(product, preferences) {
|
||||
limitedByMissingData,
|
||||
dataCoverage: Math.round(coverage * 100),
|
||||
allergenReviewRequired,
|
||||
staleDataReviewRequired: product.cacheStale === true,
|
||||
hasBlockedAllergen,
|
||||
allergenReviewMessage: categoryScores.allergies.reviewMessage,
|
||||
mainFactors: ratingFactors(categoryScores, weights, preferences),
|
||||
scoreLimitReasons,
|
||||
reasons,
|
||||
categoryScores
|
||||
};
|
||||
@@ -170,12 +192,7 @@ function ratingWeights(preferences) {
|
||||
}
|
||||
|
||||
function weightedCategoryScore(categoryScores, weights, preferences) {
|
||||
const applicableEntries = Object.entries(categoryScores).filter(([category]) => (
|
||||
category !== 'allergies' || (preferences.avoidAllergens || []).length > 0
|
||||
) && (
|
||||
category !== 'budget' || Number.isFinite(preferences.maxBudgetPerShoppingTrip)
|
||||
&& preferences.maxBudgetPerShoppingTrip > 0
|
||||
));
|
||||
const applicableEntries = applicableCategoryEntries(categoryScores, preferences);
|
||||
const knownEntries = applicableEntries.filter(([, value]) => value.hasKnownFacts !== false);
|
||||
const totalWeight = knownEntries.reduce((sum, [category]) => sum + weights[category], 0);
|
||||
const applicableWeight = applicableEntries.reduce((sum, [category]) => sum + weights[category], 0);
|
||||
@@ -192,6 +209,29 @@ function weightedCategoryScore(categoryScores, weights, preferences) {
|
||||
), coverage };
|
||||
}
|
||||
|
||||
function applicableCategoryEntries(categoryScores, preferences) {
|
||||
return Object.entries(categoryScores).filter(([category]) => (
|
||||
category !== 'allergies' || (preferences.avoidAllergens || []).length > 0
|
||||
) && (
|
||||
category !== 'budget' || Number.isFinite(preferences.maxBudgetPerShoppingTrip)
|
||||
&& preferences.maxBudgetPerShoppingTrip > 0
|
||||
));
|
||||
}
|
||||
|
||||
function ratingFactors(categoryScores, weights, preferences) {
|
||||
return applicableCategoryEntries(categoryScores, preferences)
|
||||
.filter(([, value]) => value.hasKnownFacts !== false)
|
||||
.map(([category, value]) => ({
|
||||
category,
|
||||
label: categoryLabels[category],
|
||||
score: value.score,
|
||||
message: value.message,
|
||||
impact: Math.round((100 - value.score) * weights[category])
|
||||
}))
|
||||
.sort((left, right) => right.impact - left.impact)
|
||||
.slice(0, 2);
|
||||
}
|
||||
|
||||
function capOverallScoreForCriticalAdditives(score, criticalAdditiveCount) {
|
||||
if (criticalAdditiveCount >= 3) {
|
||||
return Math.min(score, 35);
|
||||
@@ -213,18 +253,27 @@ function rateAllergies(product, preferences) {
|
||||
const matchingAllergens = (product.allergens || []).filter((allergen) =>
|
||||
avoidAllergens.some((blockedAllergen) => blockedAllergen.toLowerCase() === allergen.toLowerCase())
|
||||
);
|
||||
const matchingTraces = (product.allergenTraces || []).filter((allergen) =>
|
||||
avoidAllergens.some((blockedAllergen) => blockedAllergen.toLowerCase() === allergen.toLowerCase())
|
||||
);
|
||||
const completeness = product.dataCompleteness || {};
|
||||
const allergenDataMissing = completeness.allergens !== true || !Array.isArray(product.allergens) || product.allergens.length === 0;
|
||||
const allergenDataUnverified = completeness.allergensVerified !== true;
|
||||
const missingData = missingMessages([
|
||||
[avoidAllergens.length > 0 && allergenDataMissing, 'Allergenangaben fehlen oder sind nicht bestätigt. Verpackung prüfen.']
|
||||
[avoidAllergens.length > 0 && allergenDataUnverified, 'Allergenfreiheit ist nicht bestätigt. Verpackung prüfen.']
|
||||
]);
|
||||
|
||||
if (matchingAllergens.length > 0) {
|
||||
return withScore(0, `Enthält: ${matchingAllergens.join(', ')}.`, missingData);
|
||||
}
|
||||
|
||||
if (avoidAllergens.length > 0 && allergenDataMissing) {
|
||||
return withScore(50, 'Allergenangaben fehlen – Verpackung prüfen.', missingData, { needsReview: true, hasKnownFacts: false });
|
||||
if (matchingTraces.length > 0) {
|
||||
const reviewMessage = `Mögliche Spuren von ${matchingTraces.join(', ')}. Verpackung prüfen.`;
|
||||
return withScore(50, reviewMessage, missingData, { needsReview: true, reviewMessage, hasKnownFacts: false });
|
||||
}
|
||||
|
||||
if (avoidAllergens.length > 0 && allergenDataUnverified) {
|
||||
const reviewMessage = 'Allergenfreiheit ist nicht bestätigt. Verpackung prüfen.';
|
||||
return withScore(50, reviewMessage, missingData, { needsReview: true, reviewMessage, hasKnownFacts: false });
|
||||
}
|
||||
|
||||
return withScore(100, avoidAllergens.length > 0
|
||||
@@ -245,14 +294,14 @@ function rateIngredients(product, preferences) {
|
||||
const vegetarian = ingredientFlag(analysis.vegetarian, hasAnimalIngredient(ingredients, false) ? false : undefined);
|
||||
const components = [
|
||||
scoreComponent(palmOil === true ? 22 : palmOil === false ? 92 : null, 2),
|
||||
scoreComponent(additiveScore(additives, completeness.additives, harmfulAdditives), harmfulAdditives.length > 0 ? 3 : 1)
|
||||
scoreComponent(additiveScore(additives, completeness.additives === true && (hasIngredientText || additives.length > 0), harmfulAdditives), harmfulAdditives.length > 0 ? 3 : 1)
|
||||
];
|
||||
const missingData = missingMessages([
|
||||
[!hasIngredientText, 'Zutatenliste fehlt in Open Food Facts.'],
|
||||
[palmOil === undefined, 'Palmöl-Analyse fehlt in Open Food Facts.'],
|
||||
[preferences.preferredDiet === 'vegan' && vegan === undefined, 'Vegan-Analyse fehlt in Open Food Facts.'],
|
||||
[preferences.preferredDiet === 'vegetarian' && vegetarian === undefined, 'Vegetarisch-Analyse fehlt in Open Food Facts.'],
|
||||
[completeness.additives === false, 'Zusatzstoffangaben fehlen in Open Food Facts.']
|
||||
[completeness.additives !== true || (!hasIngredientText && additives.length === 0), 'Zusatzstoffangaben reichen für eine Bewertung nicht aus.']
|
||||
]);
|
||||
const scoreDetails = ingredientScoreDetails({
|
||||
additives,
|
||||
@@ -327,7 +376,12 @@ function rateNutrition(product, preferences) {
|
||||
const nutrientLevelMessage = messageFromNutrientLevels(highLevels, moderateLevels);
|
||||
const baseScore = nutritionScoreFromData(product, nutrition, nutrientLevels);
|
||||
const details = nutritionScoreDetails(product, preferences, nutrition, nutrientLevels, baseScore, Boolean(calculated));
|
||||
const options = { details, hasKnownFacts: Boolean(nutrition.nutriScore) };
|
||||
const options = {
|
||||
details,
|
||||
hasKnownFacts: Boolean(nutrition.nutriScore),
|
||||
nutriScore: nutrition.nutriScore,
|
||||
nutriScoreSource: calculated ? 'calculated' : 'official'
|
||||
};
|
||||
|
||||
if (!nutrition.nutriScore) {
|
||||
return withScore(50, 'Nutri-Score und ausreichende Nährwerte fehlen.', missingData, options);
|
||||
@@ -386,10 +440,11 @@ function rateSustainability(product, preferences) {
|
||||
const sustainability = product.sustainability || {};
|
||||
const carbonFootprint = carbonFootprintValue(sustainability);
|
||||
const hasEcoScore = Boolean(ecoScoreValues[sustainability.ecoScore]);
|
||||
const originCountry = scoredOriginCountry(product);
|
||||
const missingData = missingMessages([
|
||||
[!sustainability.ecoScore, 'Eco-Score fehlt in Open Food Facts.'],
|
||||
[!hasEcoScore && typeof carbonFootprint !== 'number', 'CO2-Fussabdruck ist nicht verfügbar.'],
|
||||
[!hasEcoScore && !sustainability.originCountry, 'Herkunftsland fehlt in Open Food Facts.'],
|
||||
[!hasEcoScore && !originCountry, 'Zutatenherkunft fehlt in Open Food Facts.'],
|
||||
[!hasEcoScore && !sustainability.packaging, 'Verpackungsangabe fehlt in Open Food Facts.']
|
||||
]);
|
||||
const components = sustainabilityScoreComponents(product, preferences);
|
||||
@@ -773,7 +828,7 @@ function sustainabilityScoreComponents(product, preferences) {
|
||||
? [scoreComponent(ecoScore, 3)]
|
||||
: [
|
||||
scoreComponent(carbonFootprintScore(carbonFootprintValue(sustainability)), 2),
|
||||
scoreComponent(originScore(sustainability.originCountry), 1),
|
||||
scoreComponent(originScore(scoredOriginCountry(product)), 1),
|
||||
scoreComponent(packagingScore(sustainability.packaging), 1)
|
||||
];
|
||||
|
||||
@@ -1134,6 +1189,13 @@ function hasAnimalIngredient(ingredients, includeDairyAndEggs) {
|
||||
});
|
||||
}
|
||||
|
||||
function scoredOriginCountry(product) {
|
||||
const sustainability = product.sustainability || {};
|
||||
if (['open-food-facts', 'cache'].includes(product.dataSource)
|
||||
&& sustainability.originSource !== 'ingredient-origin') return undefined;
|
||||
return sustainability.originCountry;
|
||||
}
|
||||
|
||||
function isWaterLike(product) {
|
||||
const terms = productTerms(product);
|
||||
const nutrition = product.nutrition || {};
|
||||
|
||||
Reference in New Issue
Block a user