This commit is contained in:
@@ -35,7 +35,10 @@ export default function ProductDetailScreen({
|
||||
price: hasProductPrice ? product.price : parsedManualPrice
|
||||
}), [currency, hasProductPrice, parsedManualPrice, product]);
|
||||
const rating = useMemo(() => calculateProductRating(pricedProduct, preferences), [pricedProduct, preferences]);
|
||||
const recommendation = rating.overallStatus === 'good' ? 'Passt gut zu dir' : rating.overallStatus === 'medium' ? 'Genauer prüfen' : 'Lieber meiden';
|
||||
const footprint = product.sustainability?.footprint;
|
||||
const recommendation = rating.overallStatus === 'good' ? 'Passt gut zu dir'
|
||||
: rating.overallStatus === 'critical' ? 'Lieber meiden'
|
||||
: rating.overallStatus === 'unknown' ? 'Zu wenig Daten' : 'Genauer prüfen';
|
||||
|
||||
function addToList() {
|
||||
if (!hasProductPrice && manualPrice.trim() && parsedManualPrice === undefined) {
|
||||
@@ -75,7 +78,11 @@ export default function ProductDetailScreen({
|
||||
<Text style={styles.recommendationCopy}>
|
||||
{rating.allergenReviewRequired
|
||||
? 'Allergenangaben fehlen oder sind nicht bestätigt. Prüfe vor dem Kauf die Verpackung.'
|
||||
: 'Tippe unten auf ein Kriterium, um die Bewertung nachzuvollziehen.'}
|
||||
: 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>
|
||||
</View>
|
||||
</View>
|
||||
@@ -127,13 +134,48 @@ export default function ProductDetailScreen({
|
||||
/>
|
||||
))}
|
||||
|
||||
<SectionTitle>Umweltwirkung</SectionTitle>
|
||||
<View style={styles.dataPanel}>
|
||||
{footprint?.status === 'product-specific' || footprint?.status === 'estimated' ? (
|
||||
<>
|
||||
<Text style={styles.dataText}>
|
||||
CO₂-Fussabdruck: {formatImpact(footprint.valueKgCo2ePerKg)} kg CO₂e/kg
|
||||
</Text>
|
||||
<Text style={styles.dataText}>
|
||||
{footprint.status === 'product-specific' ? 'Produktspezifische Angabe aus Open Food Facts.'
|
||||
: `Schätzung anhand vergleichbarer Lebensmittel: ${footprint.referenceCategory}. AGRIBALYSE-Durchschnitt, keine Messung dieses Markenprodukts.`}
|
||||
</Text>
|
||||
{typeof footprint.packageKgCo2e === 'number' ? (
|
||||
<Text style={styles.dataText}>
|
||||
Für {formatImpact(footprint.packageQuantityGrams, 0)} g Packungsinhalt: ca. {formatImpact(footprint.packageKgCo2e)} kg CO₂e
|
||||
</Text>
|
||||
) : null}
|
||||
<Text style={styles.dataText}>
|
||||
Quelle: {footprint.source === 'AGRIBALYSE' ? 'ADEME / ' : ''}{footprint.source}{footprint.datasetVersion ? ` ${footprint.datasetVersion}` : ''}
|
||||
{footprint.datasetUpdatedAt ? ` · Datenstand ${footprint.datasetUpdatedAt.slice(0, 10)}` : ''}
|
||||
{footprint.sourceUpdatedAt ? ` · OFF-Stand ${footprint.sourceUpdatedAt.slice(0, 10)}` : ''}
|
||||
{footprint.sourceId ? ` · Kennung ${footprint.sourceId}` : ''}
|
||||
{footprint.matchMethod ? ` · Zuordnung: ${matchLabel(footprint.matchMethod)}` : ''}
|
||||
</Text>
|
||||
{footprint.status === 'estimated' ? (
|
||||
<>
|
||||
<Text style={styles.dataText}>Landnutzung: {formatIndicator(footprint.indicators?.landUse)}</Text>
|
||||
<Text style={styles.dataText}>Wasserknappheit: {formatIndicator(footprint.indicators?.waterScarcity)}</Text>
|
||||
<Text style={styles.dataText}>Gesamtwirkung (EF): {formatIndicator(footprint.indicators?.singleScore)}</Text>
|
||||
<Text style={styles.dataText}>Lebenszyklus bis zum verzehrbaren Lebensmittel; Transport und Verpackung sind im Datensatz enthalten. Diese Indikatoren sind keine CO₂-Werte.</Text>
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
) : <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>
|
||||
</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}>Eco-Score: {product.sustainability?.ecoScore || 'Keine Angabe'}</Text>
|
||||
</View>
|
||||
|
||||
</ScreenContainer>
|
||||
@@ -161,6 +203,24 @@ function sourceLabel(source) {
|
||||
return labels[source] || 'Quelle: unbekannt';
|
||||
}
|
||||
|
||||
function formatImpact(value, maximumFractionDigits = 2) {
|
||||
return new Intl.NumberFormat('de-CH', { maximumFractionDigits, minimumFractionDigits: value < 0.01 ? 3 : 0 }).format(value);
|
||||
}
|
||||
|
||||
function formatIndicator(indicator) {
|
||||
if (typeof indicator?.value !== 'number') return 'Nicht verfügbar';
|
||||
return `${new Intl.NumberFormat('de-CH', { maximumSignificantDigits: 3 }).format(indicator.value)} ${indicator.unit}`;
|
||||
}
|
||||
|
||||
function matchLabel(method) {
|
||||
return {
|
||||
'off-category-code': 'OFF-Kategoriecode',
|
||||
'off-category-proxy': 'OFF-Kategorieproxy',
|
||||
'reviewed-category-map': 'geprüfte Kategoriezuordnung',
|
||||
'normalized-name-in-category': 'normalisierter Name innerhalb der Kategorie'
|
||||
}[method] || method;
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
productPanel: {
|
||||
backgroundColor: colors.surface,
|
||||
@@ -215,6 +275,7 @@ const styles = StyleSheet.create({
|
||||
goodRecommendation: { backgroundColor: '#e4f4e9' },
|
||||
mediumRecommendation: { backgroundColor: '#fff3d7' },
|
||||
criticalRecommendation: { backgroundColor: '#fee9e7' },
|
||||
unknownRecommendation: { backgroundColor: '#edf1ee' },
|
||||
recommendationTitle: {
|
||||
fontSize: 17,
|
||||
fontWeight: '800'
|
||||
@@ -222,6 +283,7 @@ const styles = StyleSheet.create({
|
||||
goodText: { color: colors.success },
|
||||
mediumText: { color: '#8a5914' },
|
||||
criticalText: { color: colors.danger },
|
||||
unknownText: { color: colors.muted },
|
||||
recommendationCopy: {
|
||||
color: colors.text,
|
||||
fontSize: 13,
|
||||
|
||||
Reference in New Issue
Block a user