import React, { useState } from 'react'; function Challenges() { const [completedChallenges, setCompletedChallenges] = useState([]); const challenges = [ { id: 1, title: "🚲 Bike Week Challenge", description: "Use bike or walk for transportation for 7 days", difficulty: "Medium", points: 150, co2Savings: 14.7 }, { id: 2, title: "🌱 Plant-Based Week", description: "Eat only plant-based meals for 7 consecutive days", difficulty: "Hard", points: 200, co2Savings: 23.1 }, { id: 3, title: "💡 Energy Saver Challenge", description: "Reduce home energy consumption by 25% for one month", difficulty: "Medium", points: 300, co2Savings: 45.2 } ]; const startChallenge = (challengeId) => { alert(`Challenge ${challengeId} started! Track your progress in the app.`); }; const getDifficultyColor = (difficulty) => { switch (difficulty) { case 'Easy': return '#4CAF50'; case 'Medium': return '#FF9800'; case 'Hard': return '#f44336'; default: return '#666'; } }; return (

🏆 Environmental Challenges

Take on challenges to reduce your environmental impact and earn points!

🏅 Points Earned

{completedChallenges.reduce((sum, c) => sum + c.points, 0)}

Total challenge points

🌍 CO₂ Saved

{completedChallenges.reduce((sum, c) => sum + c.co2Savings, 0).toFixed(1)}

kg CO₂ prevented

✅ Completed

{completedChallenges.length}

challenges finished

🚀 Available Challenges

{challenges.map(challenge => (

{challenge.title}

{challenge.difficulty}

{challenge.description}

🏅 {challenge.points} points 🌍 {challenge.co2Savings}kg CO₂
))}
); } export default Challenges;