import { useMemo } from "react"; import { useWSQuery } from "../../hooks"; import dayjs from "dayjs"; import { Tooltip, TooltipContent, TooltipTrigger, } from "../../components/Tooltip"; import PastMatch from "../../components/PastMatch"; import GemsIcon from "../../components/GemIcon"; const Profile: React.FC = () => { const { data: username } = useWSQuery("user.getSelf", null); const { data: heatmap } = useWSQuery( "user.getHeatmap", { id: username! }, !!username, ); const { data: profile } = useWSQuery( "user.getProfile", { id: username! }, !!username, ); const { data: pastGames } = useWSQuery( "game.getGames", { user: username!, page: 0, }, !!username, ); const now = useMemo(() => dayjs(), []); const firstOfYear = useMemo(() => now.startOf("year"), [now]); const weeks = now.diff(firstOfYear, "weeks") + 1; const maxHeat = heatmap ? Math.max(...heatmap) : 0; return (
{username}

Total Games: {profile?.totalGames}

Highest Stage: {profile?.highestStage}

Average Stage: {Math.round(profile?.averageStage ?? 1 * 100) / 100}

Gems Spend:{" "} {(profile?.totalGems ?? 0) - (profile?.currentGems ?? 0)}{" "}

{pastGames?.data .slice(0, 4) .map((game) => )}
{heatmap && (

Activity

{Array.from({ length: weeks }).map((_, w) => (
{Array.from({ length: 7 }).map((_, d) => { const index = w * 7 + d; if (index >= heatmap.length) return; return (

{firstOfYear .clone() .add(index, "days") .format("DD/MM/YYYY")}

{heatmap[index]} Games Played

); })}
))}
)}
); }; export default Profile;