diff --git a/src/app/(home)/players/[id]/_components/mmr-trend-chart.tsx b/src/app/(home)/players/[id]/_components/mmr-trend-chart.tsx new file mode 100644 index 0000000..4616c89 --- /dev/null +++ b/src/app/(home)/players/[id]/_components/mmr-trend-chart.tsx @@ -0,0 +1,84 @@ +'use client' +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from '@/components/ui/card' +import { + type ChartConfig, + ChartContainer, + ChartTooltip, + ChartTooltipContent, +} from '@/components/ui/chart' +import type { SelectGames } from '@/server/db/types' +import { CartesianGrid, Line, LineChart, XAxis } from 'recharts' + +const chartConfig = { + mmr: { + label: 'MMR', + color: 'var(--color-violet-500)', + }, +} satisfies ChartConfig + +export function MmrTrendChart({ games }: { games: SelectGames[] }) { + const chartData = games + .filter((game) => game.gameType === 'ranked') + .map((game) => ({ + date: game.gameTime, + mmr: game.playerMmr, + })) + .sort((a, b) => a.date.getTime() - b.date.getTime()) + return ( + + + MMR Trends + All time + + + + + + + new Date(value).toLocaleDateString('en-US', { + month: 'short', + day: 'numeric', + }) + } + /> + } + /> + + + + + + + Showing only ranked MMR + + + + ) +} diff --git a/src/app/(home)/players/[id]/user.tsx b/src/app/(home)/players/[id]/user.tsx index b7583fc..dc7a53a 100644 --- a/src/app/(home)/players/[id]/user.tsx +++ b/src/app/(home)/players/[id]/user.tsx @@ -16,6 +16,7 @@ import type React from 'react' import { useState } from 'react' import { GamesTable } from '@/app/(home)/players/[id]/_components/games-table' +import { MmrTrendChart } from '@/app/(home)/players/[id]/_components/mmr-trend-chart' import { OpponentsTable } from '@/app/(home)/players/[id]/_components/opponents-table' import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' import { Badge } from '@/components/ui/badge' @@ -358,6 +359,7 @@ export function UserInfo() { Match History Opponents + MMR Trends Statistics Achievements @@ -409,7 +411,13 @@ export function UserInfo() { - + + + + + + + {(rankedLeaderboard || lastRankedGame) && (