1
0

Add planet display to user profile

- Display planet value with earth icon
- Format large numbers as M (millions) or K (thousands)
- Example: 2000336.062109 displays as 2.00M
- Show only when planet value exists
This commit is contained in:
2025-07-20 13:00:35 +09:00
parent 60076d0e83
commit 054846f8e5

View File

@@ -6,6 +6,15 @@ interface UserProfileProps {
}
export default function UserProfile({ user, cards }: UserProfileProps) {
const formatPlanet = (planet: number) => {
if (planet >= 1000000) {
return `${(planet / 1000000).toFixed(2)}M`;
} else if (planet >= 1000) {
return `${(planet / 1000).toFixed(2)}K`;
}
return planet.toLocaleString();
};
return (
<div className="bg-white rounded-lg p-6 mb-8">
<h3 className="text-2xl font-bold mb-4 flex items-center gap-2">
@@ -48,7 +57,7 @@ export default function UserProfile({ user, cards }: UserProfileProps) {
{user.planet && (
<div className="flex items-center gap-1">
<i className="fa-solid fa-earth-americas"></i>
{user.planet}
{formatPlanet(user.planet)}
</div>
)}
</div>