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": "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",