import { useAuth } from '../../stores/useAuth'; import { Trophy, Star, TrendingUp } from 'lucide-react'; export function GamificationWidget() { const { activeLearner } = useAuth(); if (!activeLearner) return null; const level = activeLearner.level || 1; const currentXP = activeLearner.xp || 0; // Formula inverse: XP = 50 * (Level-1)^2 // But easier: Calculate bounds for current level to show progress bar // Level N starts at: 50 * (N-1)^2 // Level N+1 starts at: 50 * N^2 const currentLevelStartXP = 50 * Math.pow(level - 1, 2); const nextLevelStartXP = 50 * Math.pow(level, 2); const xpNeededForLevel = nextLevelStartXP - currentLevelStartXP; const xpProgressInLevel = currentXP - currentLevelStartXP; // Calculate percentage const progressPercent = Math.min(100, Math.max(0, (xpProgressInLevel / xpNeededForLevel) * 100)); // Level Titles (Flavor text) const getLevelTitle = (lvl: number) => { if (lvl >= 50) return "Légende Vivante"; if (lvl >= 30) return "Grand Maître"; if (lvl >= 20) return "Érudit"; if (lvl >= 10) return "Explorateur"; if (lvl >= 5) return "Apprenti"; return "Novice"; }; return (