diff --git a/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx b/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx index 8a910a392..b9adde426 100644 --- a/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx +++ b/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx @@ -1,5 +1,5 @@ import { CreateUserMap } from "util/data"; -import { ToFixedFloor, UppercaseFirst } from "util/misc"; +import { FormatGPTProfileRating, UppercaseFirst } from "util/misc"; import { NumericSOV, StrSOV } from "util/sorts"; import ClassBadge from "components/game/ClassBadge"; import ScoreLeaderboard from "components/game/ScoreLeaderboard"; @@ -142,9 +142,7 @@ function ProfileLeaderboard({ game, playtype }: GamePT) { ).map((e) => ( {r.ratings[e] - ? gptConfig.profileRatingAlgs[e].formatter - ? gptConfig.profileRatingAlgs[e].formatter!(r.ratings[e]!) - : ToFixedFloor(r.ratings[e]!, 2) + ? FormatGPTProfileRating(game, playtype, e, r.ratings[e]!) : "No Data."} ))} diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx index fd1ad86ed..7a63b5538 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx @@ -1,5 +1,4 @@ -import { ClumpActivity } from "util/activity"; -import { ToFixedFloor, UppercaseFirst } from "util/misc"; +import { FormatGPTProfileRating, UppercaseFirst } from "util/misc"; import { FormatDate, MillisToSince } from "util/time"; import TimelineChart from "components/charts/TimelineChart"; import useSetSubheader from "components/layout/header/useSetSubheader"; @@ -17,7 +16,14 @@ import SelectButton from "components/util/SelectButton"; import { useProfileRatingAlg } from "components/util/useScoreRatingAlg"; import { DateTime } from "luxon"; import React, { useMemo, useState } from "react"; -import { FormatGame, GetGameConfig, GetGamePTConfig, UserGameStats } from "tachi-common"; +import { + FormatGame, + Game, + GetGameConfig, + GetGamePTConfig, + Playtype, + UserGameStats, +} from "tachi-common"; import { UGPTHistory } from "types/api-returns"; import { GamePT, SetState, UGPT } from "types/react"; import FormSelect from "react-bootstrap/FormSelect"; @@ -110,7 +116,13 @@ function UserHistory({ const currentPropValue = useMemo(() => { if (mode === "rating" && rating) { - return data[0].ratings[rating] ? ToFixedFloor(data[0].ratings[rating]!, 2) : "N/A"; + const ratingValue = data[0].ratings[rating]; + + if (!ratingValue) { + return "N/A"; + } + + return FormatGPTProfileRating(game, playtype, rating, ratingValue); } else if (mode === "ranking") { return ( <> @@ -228,7 +240,7 @@ function UserHistory({ )} - + )} @@ -236,9 +248,13 @@ function UserHistory({ } function RatingTimeline({ + game, + playtype, data, rating, }: { + game: Game; + playtype: Playtype; data: UGPTHistory; rating: keyof UserGameStats["ratings"]; }) { @@ -259,12 +275,19 @@ function RatingTimeline({ tickSize: 5, tickPadding: 5, tickRotation: 0, - format: (y) => (y ? ToFixedFloor(y, 2) : "N/A"), + format: (y) => (y ? FormatGPTProfileRating(game, playtype, rating, y) : "N/A"), }} tooltip={(p) => (
- {p.point.data.y ? ToFixedFloor(p.point.data.y as number, 2) : "N/A"}{" "} + {p.point.data.y + ? FormatGPTProfileRating( + game, + playtype, + rating, + p.point.data.y as number + ) + : "N/A"}{" "} {UppercaseFirst(rating)}
diff --git a/client/src/components/charts/TimelineChart.tsx b/client/src/components/charts/TimelineChart.tsx index 5b3d257c5..19b0057fa 100644 --- a/client/src/components/charts/TimelineChart.tsx +++ b/client/src/components/charts/TimelineChart.tsx @@ -40,7 +40,7 @@ export default function TimelineChart({