Redesign anti-waste section: report card with grade, comparison vs national avg, savings badges and trend chart

- Replace simple bar chart with full Anti-Waste Report Card
- Grade system (A+ to D) based on user's waste rate
- Dual comparison bars: user waste rate vs national average (IT/DE/US)
- Estimated monthly savings in money, meals saved, CO2 avoided
- 3-month trend mini chart with colour-coded bars
- Backend: getStats() now returns 3×30d buckets (used_30d, used_prev_30d, used_prev_60d, etc.)
- Real-world benchmarks: IT 22%/5.4kg/mo (REDUCE), DE 20%/6.5kg/mo (Eurostat), US 30%/9.2kg/mo (USDA)
- All labels fully i18n: 18 new antiwaste.* keys in it/en/de translation files
- Section is fully JS-rendered; HTML now just an empty container
This commit is contained in:
dadaloop82
2026-04-29 05:54:17 +00:00
parent 2c06be33d4
commit ee2c280167
7 changed files with 397 additions and 73 deletions
+20
View File
@@ -675,6 +675,26 @@
"appliance_added": "Gerät hinzugefügt",
"item_added": "{name} hinzugefügt"
},
"antiwaste": {
"title": "🌱 Anti-Waste Report",
"grade_label": "Note",
"you": "Du",
"avg_label": "Ø",
"better": "🎉 Du verschwendest {diff}% weniger als der {country}!",
"worse": "⚠️ Du verschwendest mehr als der {country}. Verbesserungspotenzial!",
"on_par": "→ Du liegst beim {country}. Du kannst noch besser werden!",
"saved_money": "~{amount}/Monat gespart",
"saved_meals": "~{n} Mahlzeiten gerettet",
"saved_co2": "{n} kg CO₂ eingespart",
"trend_title": "Trend (letzte 3 Monate)",
"months_ago_2": "-60 Tage",
"months_ago_1": "-30 Tage",
"this_month": "Jetzt",
"country_it": "ital. Durchschnitt",
"country_de": "dt. Durchschnitt",
"country_en": "US-Durchschnitt",
"source": "Quellen: REDUCE, Eurostat, USDA 2021"
},
"error": {
"generic": "Fehler",
"network": "Netzwerkfehler",
+20
View File
@@ -675,6 +675,26 @@
"appliance_added": "Appliance added",
"item_added": "{name} added"
},
"antiwaste": {
"title": "🌱 Anti-Waste Report",
"grade_label": "Grade",
"you": "You",
"avg_label": "Avg",
"better": "🎉 You waste {diff}% less than the {country}!",
"worse": "⚠️ You waste more than the {country}. Let's improve!",
"on_par": "→ You're at the {country}. You can do better!",
"saved_money": "~{amount}/month saved",
"saved_meals": "~{n} meals saved",
"saved_co2": "{n} kg CO₂ avoided",
"trend_title": "Trend (last 3 months)",
"months_ago_2": "-60 days",
"months_ago_1": "-30 days",
"this_month": "Now",
"country_it": "Italian avg",
"country_de": "German avg",
"country_en": "US average",
"source": "Sources: REDUCE, Eurostat, USDA 2021"
},
"error": {
"generic": "Error",
"network": "Network error",
+20
View File
@@ -675,6 +675,26 @@
"appliance_added": "Elettrodomestico aggiunto",
"item_added": "{name} aggiunto"
},
"antiwaste": {
"title": "🌱 Anti-Waste Report",
"grade_label": "Voto",
"you": "Tu",
"avg_label": "Media",
"better": "🎉 Sprechi il {diff}% in meno della {country}!",
"worse": "⚠️ Sprechi più della media {country}. Puoi migliorare!",
"on_par": "→ Sei nella media {country}. Prova a fare ancora meglio!",
"saved_money": "~{amount}/mese risparmiati",
"saved_meals": "~{n} pasti salvati",
"saved_co2": "{n} kg CO₂ evitata",
"trend_title": "Andamento (ultimi 3 mesi)",
"months_ago_2": "-60 gg",
"months_ago_1": "-30 gg",
"this_month": "Ora",
"country_it": "media italiana",
"country_de": "media tedesca",
"country_en": "media USA",
"source": "Fonti: REDUCE, Eurostat, USDA 2021"
},
"error": {
"generic": "Errore",
"network": "Errore di rete",