scoresaber-reloaded-v2/src/components/player/PlayerRankingMobile.tsx

63 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-10-23 17:09:16 +00:00
"use client";
2023-10-22 05:53:53 +00:00
import { ScoresaberPlayer } from "@/schemas/scoresaber/player";
import { useSettingsStore } from "@/store/settingsStore";
import { formatNumber } from "@/utils/number";
import dynamic from "next/dynamic";
2023-10-22 05:53:53 +00:00
import { useStore } from "zustand";
import Avatar from "../Avatar";
import Label from "../Label";
type PlayerRankingProps = {
player: ScoresaberPlayer;
showCountryFlag?: boolean;
};
const ReactCountryFlag = dynamic(() => import("react-country-flag"));
2023-10-22 05:53:53 +00:00
export default function PlayerRankingMobile({
player,
showCountryFlag = true,
}: PlayerRankingProps) {
const settingsStore = useStore(useSettingsStore, (store) => store);
return (
<div>
<div className="m-3 flex flex-col gap-2">
2023-10-23 17:09:16 +00:00
<div className="flex items-center gap-2">
2023-10-22 05:53:53 +00:00
<p>#{formatNumber(player.rank)}</p>
<Avatar url={player.profilePicture} label="Avatar" size={24} />
{showCountryFlag && (
<ReactCountryFlag
countryCode={player.country}
svg
className="!h-5 !w-5"
/>
)}
<p
className={
2023-10-22 09:50:10 +00:00
player.id == settingsStore.player?.id
2023-10-22 05:53:53 +00:00
? "transform-gpu text-red-500 transition-all hover:text-blue-500"
: ""
}
>
{player.name}
</p>
2023-10-23 17:09:16 +00:00
</div>
2023-10-22 05:53:53 +00:00
<div className="flex flex-wrap justify-center gap-2">
<Label
title="PP"
hoverValue="Total amount of pp"
value={`${formatNumber(player.pp)}`}
/>
<Label
title="Total play count"
hoverValue="Total ranked song play count"
value={formatNumber(player.scoreStats.totalPlayCount)}
/>
</div>
</div>
</div>
);
}