diff --git a/components/navigation/Navigation.tsx b/components/navigation/Navigation.tsx index 4eb824a..d7fb625 100644 --- a/components/navigation/Navigation.tsx +++ b/components/navigation/Navigation.tsx @@ -16,6 +16,7 @@ interface UserData { xp: number; maxXp: number; level: number; + score: number; } interface NavigationProps { diff --git a/components/navigation/NavigationWrapper.tsx b/components/navigation/NavigationWrapper.tsx index bb14e9c..51c0f63 100644 --- a/components/navigation/NavigationWrapper.tsx +++ b/components/navigation/NavigationWrapper.tsx @@ -11,6 +11,7 @@ interface UserData { xp: number; maxXp: number; level: number; + score: number; } export default async function NavigationWrapper() { @@ -31,6 +32,7 @@ export default async function NavigationWrapper() { xp: true, maxXp: true, level: true, + score: true, }), challengeService.getActiveChallengesCount(session.user.id), ]); diff --git a/components/profile/PlayerStats.tsx b/components/profile/PlayerStats.tsx index d4b1b3c..81c95eb 100644 --- a/components/profile/PlayerStats.tsx +++ b/components/profile/PlayerStats.tsx @@ -13,6 +13,7 @@ interface UserData { xp: number; maxXp: number; level: number; + score: number; } interface PlayerStatsProps { @@ -32,6 +33,7 @@ const defaultUserData: UserData = { xp: 0, maxXp: 5000, level: 1, + score: 0, }; export default function PlayerStats({ initialUserData }: PlayerStatsProps) { @@ -62,6 +64,7 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) { xp: data.xp || 0, maxXp: data.maxXp || 5000, level: data.level || 1, + score: data.score || 0, }); }); } @@ -77,6 +80,7 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) { xp: 0, maxXp: 5000, level: 1, + score: 0, }); }); }); @@ -88,51 +92,7 @@ export default function PlayerStats({ initialUserData }: PlayerStatsProps) { } }, [session, initialUserData]); - const { username, avatar, hp, maxHp, xp, maxXp, level } = userData; - - // Calculer les pourcentages cibles - const targetHpPercentage = (hp / maxHp) * 100; - const targetXpPercentage = (xp / maxXp) * 100; - - // Initialiser les pourcentages à 0 si on a des données initiales (pour l'animation) - // Sinon utiliser directement les valeurs calculées - const [hpPercentage, setHpPercentage] = useState( - initialUserData ? 0 : targetHpPercentage - ); - const [xpPercentage, setXpPercentage] = useState( - initialUserData ? 0 : targetXpPercentage - ); - - useEffect(() => { - // Si on a des données initiales, animer depuis 0 vers la valeur cible - if (initialUserData) { - const hpTimer = setTimeout(() => { - setHpPercentage(targetHpPercentage); - }, 100); - - const xpTimer = setTimeout(() => { - setXpPercentage(targetXpPercentage); - }, 200); - - return () => { - clearTimeout(hpTimer); - clearTimeout(xpTimer); - }; - } - // Sinon, mettre à jour directement (pour les pages Client Components) - // Utiliser requestAnimationFrame pour éviter les cascades de rendu - requestAnimationFrame(() => { - setHpPercentage(targetHpPercentage); - setXpPercentage(targetXpPercentage); - }); - }, [targetHpPercentage, targetXpPercentage, initialUserData]); - - const hpColor = - hpPercentage > 60 - ? "from-green-600 to-green-700" - : hpPercentage > 30 - ? "from-yellow-600 to-orange-700" - : "from-red-700 to-red-900"; + const { username, avatar, level, score } = userData; return (