import { useState, useEffect } from "react"; import Layout from "@/components/Layout"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { useNavigate } from "react-router-dom"; import { Badge } from "@/components/ui/badge"; import { ArrowLeft, Award, Loader2, Trophy } from "lucide-react"; import { useAuth } from "@/contexts/AuthContext"; interface Achievement { id: string; name: string; description: string; icon: string; points: number; difficulty: "bronze" | "silver" | "gold" | "platinum"; category: string; earned_count: number; } const difficultyColors: Record< "bronze" | "silver" | "gold" | "platinum", string > = { bronze: "bg-amber-700/20 text-amber-600", silver: "bg-slate-400/20 text-slate-300", gold: "bg-yellow-500/20 text-yellow-400", platinum: "bg-purple-500/20 text-purple-400", }; const mockAchievements: Achievement[] = [ { id: "1", name: "First Course Completed", description: "Complete your first Foundation course", icon: "🎓", points: 50, difficulty: "bronze", category: "Learning", earned_count: 1240, }, { id: "2", name: "Master Mathematician", description: "Complete all mathematics courses", icon: "🧮", points: 200, difficulty: "silver", category: "Specialty", earned_count: 342, }, { id: "3", name: "Game Developer Pro", description: "Complete all game development courses", icon: "🎮", points: 300, difficulty: "gold", category: "Specialty", earned_count: 234, }, { id: "4", name: "Knowledge Keeper", description: "Contribute 50 hours of learning content", icon: "📚", points: 150, difficulty: "silver", category: "Community", earned_count: 156, }, { id: "5", name: "Legendary Mentor", description: "Mentor 10 students to course completion", icon: "👨‍🏫", points: 400, difficulty: "platinum", category: "Mentorship", earned_count: 45, }, { id: "6", name: "Code Reviewer", description: "Review 100 pieces of student code", icon: "👀", points: 200, difficulty: "gold", category: "Community", earned_count: 89, }, { id: "7", name: "Weekend Warrior", description: "Complete a course in 7 days or less", icon: "⚡", points: 100, difficulty: "bronze", category: "Speed", earned_count: 567, }, { id: "8", name: "Perfect Score", description: "Achieve 100% on all course assessments", icon: "💯", points: 250, difficulty: "gold", category: "Excellence", earned_count: 123, }, ]; const CATEGORIES = [ "All", "Learning", "Specialty", "Community", "Mentorship", "Speed", "Excellence", ]; export default function FoundationAchievements() { const navigate = useNavigate(); const { user } = useAuth(); const [isLoading, setIsLoading] = useState(false); const [selectedCategory, setSelectedCategory] = useState("All"); const [userAchievements, setUserAchievements] = useState([ "1", "3", "7", ]); // Mock data const filteredAchievements = selectedCategory === "All" ? mockAchievements : mockAchievements.filter((a) => a.category === selectedCategory); const totalPoints = mockAchievements .filter((a) => userAchievements.includes(a.id)) .reduce((sum, a) => sum + a.points, 0); return (
{/* Background */}
{/* Header */}

Achievements

Earn badges and unlock rewards

{user && (

Total Points

{totalPoints}

)}
{/* Stats Section */} {user && (

Achieved

{userAchievements.length}/{mockAchievements.length}

Total Points

{totalPoints}

Rarest Badge

Platinum

)} {/* Category Filter */}
{CATEGORIES.map((category) => ( ))}
{/* Achievements Grid */}
{isLoading ? (
) : (
{filteredAchievements.map((achievement) => { const isEarned = userAchievements.includes(achievement.id); return (
{achievement.icon}

{achievement.name}

{achievement.description}

{achievement.difficulty.toUpperCase()} +{achievement.points} pts
{achievement.earned_count} earned
{isEarned && (
Unlocked
)}
); })}
)}
{/* CTA Section */} {!user && (

Start Earning Badges

Sign in to track your achievements, earn points, and unlock exclusive rewards as you progress through Foundation courses.

)}
); }