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 (
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)}{" "}
{firstOfYear .clone() .add(index, "days") .format("DD/MM/YYYY")}
{heatmap[index]} Games Played