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