2024-09-11 22:10:16 +00:00
|
|
|
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
|
|
|
|
import { formatNumberWithCommas } from "@/common/number-utils";
|
2024-09-09 11:08:24 +00:00
|
|
|
import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
|
2024-09-11 14:38:04 +00:00
|
|
|
import Card from "../card";
|
2024-09-09 11:08:24 +00:00
|
|
|
import CountryFlag from "../country-flag";
|
|
|
|
import { Avatar, AvatarImage } from "../ui/avatar";
|
|
|
|
import ClaimProfile from "./claim-profile";
|
2024-09-12 18:09:54 +00:00
|
|
|
import PlayerStats from "./player-stats";
|
2024-09-09 11:08:24 +00:00
|
|
|
|
2024-09-12 11:27:20 +00:00
|
|
|
const playerData = [
|
2024-09-09 11:08:24 +00:00
|
|
|
{
|
2024-09-12 11:27:20 +00:00
|
|
|
showWhenInactiveOrBanned: false,
|
2024-09-09 11:08:24 +00:00
|
|
|
icon: () => {
|
|
|
|
return <GlobeAmericasIcon className="h-5 w-5" />;
|
|
|
|
},
|
|
|
|
render: (player: ScoreSaberPlayer) => {
|
|
|
|
return <p>#{formatNumberWithCommas(player.rank)}</p>;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-09-12 11:27:20 +00:00
|
|
|
showWhenInactiveOrBanned: false,
|
2024-09-09 11:08:24 +00:00
|
|
|
icon: (player: ScoreSaberPlayer) => {
|
2024-09-11 17:33:16 +00:00
|
|
|
return <CountryFlag country={player.country.toLowerCase()} size={15} />;
|
2024-09-09 11:08:24 +00:00
|
|
|
},
|
|
|
|
render: (player: ScoreSaberPlayer) => {
|
|
|
|
return <p>#{formatNumberWithCommas(player.countryRank)}</p>;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-09-12 11:27:20 +00:00
|
|
|
showWhenInactiveOrBanned: true,
|
2024-09-09 11:08:24 +00:00
|
|
|
render: (player: ScoreSaberPlayer) => {
|
2024-09-11 14:38:04 +00:00
|
|
|
return <p className="text-pp">{formatNumberWithCommas(player.pp)}pp</p>;
|
2024-09-09 11:08:24 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
player: ScoreSaberPlayer;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function PlayerHeader({ player }: Props) {
|
|
|
|
return (
|
2024-09-11 14:38:04 +00:00
|
|
|
<Card>
|
2024-09-12 18:09:54 +00:00
|
|
|
<div className="flex gap-3 flex-col items-center text-center lg:flex-row lg:items-start lg:text-start relative select-none">
|
2024-09-09 11:08:24 +00:00
|
|
|
<Avatar className="w-32 h-32 pointer-events-none">
|
|
|
|
<AvatarImage fetchPriority="high" src={player.profilePicture} />
|
|
|
|
</Avatar>
|
2024-09-12 18:09:54 +00:00
|
|
|
<div className="w-full flex gap-2 flex-col justify-center items-center lg:justify-start lg:items-start">
|
|
|
|
<div>
|
|
|
|
<p className="font-bold text-2xl">{player.name}</p>
|
|
|
|
<div className="flex flex-col">
|
|
|
|
<div>
|
|
|
|
{player.inactive && <p className="text-gray-400">Inactive Account</p>}
|
|
|
|
{player.banned && <p className="text-red-500">Banned Account</p>}
|
|
|
|
</div>
|
|
|
|
<div className="flex gap-2">
|
|
|
|
{playerData.map((subName, index) => {
|
|
|
|
// Check if the player is inactive or banned and if the data should be shown
|
|
|
|
if (!subName.showWhenInactiveOrBanned && (player.inactive || player.banned)) {
|
|
|
|
return null;
|
|
|
|
}
|
2024-09-12 11:27:20 +00:00
|
|
|
|
2024-09-12 18:09:54 +00:00
|
|
|
return (
|
|
|
|
<div key={index} className="flex gap-1 items-center">
|
|
|
|
{subName.icon && subName.icon(player)}
|
|
|
|
{subName.render && subName.render(player)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
2024-09-12 11:27:20 +00:00
|
|
|
</div>
|
2024-09-09 11:08:24 +00:00
|
|
|
</div>
|
2024-09-12 18:09:54 +00:00
|
|
|
|
|
|
|
<PlayerStats player={player} />
|
|
|
|
|
2024-09-09 11:08:24 +00:00
|
|
|
<div className="absolute top-0 right-0">
|
|
|
|
<ClaimProfile playerId={player.id} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-11 14:38:04 +00:00
|
|
|
</Card>
|
2024-09-09 11:08:24 +00:00
|
|
|
);
|
|
|
|
}
|