import React, { useState, useEffect } from 'react'; import { Card } from '../ui/card'; import { Button } from '../ui/button'; import { XPBar } from './XPBar'; import { AchievementCard } from './AchievementCard'; import { TrendingUp, Target, Crown, Zap, Loader2 } from 'lucide-react'; import { Achievement } from '../../types'; import { gamificationService } from '../../services/gamificationService'; import { logger } from '@/utils/logger'; interface ProfileXPViewProps { username: string; } export const ProfileXPView: React.FC = ({ username }) => { const [xpData, setXpData] = useState(null); const [recentAchievements, setRecentAchievements] = useState( [], ); const [loading, setLoading] = useState(true); useEffect(() => { const fetchData = async () => { setLoading(true); try { const [xp, achievements] = await Promise.all([ gamificationService.getUserXP('me'), gamificationService.getAchievements('me'), ]); setXpData(xp); setRecentAchievements(achievements.slice(0, 3)); } catch (e) { logger.error('Error loading profile XP data', { error: e instanceof Error ? e.message : String(e), stack: e instanceof Error ? e.stack : undefined, username, }); } finally { setLoading(false); } }; fetchData(); }, []); if (loading) return (
); return (

LEVEL & PROGRESS

{/* Main XP Card */}
{/* Level Badge */}
{xpData.level}
Level
{/* Progress */}

{username}

Producer • Rank #{xpData.rank}

{xpData.current} XP
Next Level: {xpData.next} XP
{xpData.totalEarned.toLocaleString()} {' '} Total Lifetime XP
+12% vs Last Week
{/* Stats Grid */}
Global Rank
#{xpData.rank}
Daily Streak
12 Days
Quests Complete
8/10
{/* Recent Achievements */}

Recent Achievements

{recentAchievements.map((ach) => ( ))}
{/* XP History Graph (Mock) */}

XP History

{Array.from({ length: 14 }).map((_, i) => (
+{Math.floor(Math.random() * 500)} XP
))}
14 Days Ago Today
); };