diff --git a/src/app/global-error.tsx b/src/app/global-error.tsx index 9bda5fe..bb2cb54 100644 --- a/src/app/global-error.tsx +++ b/src/app/global-error.tsx @@ -4,7 +4,11 @@ import * as Sentry from "@sentry/nextjs"; import NextError from "next/error"; import { useEffect } from "react"; -export default function GlobalError({ error }: { error: Error & { digest?: string } }) { +export default function GlobalError({ + error, +}: { + error: Error & { digest?: string }; +}) { useEffect(() => { Sentry.captureException(error); }, [error]); diff --git a/src/common/song-utils.ts b/src/common/song-utils.ts index 8d98922..e8741ba 100644 --- a/src/common/song-utils.ts +++ b/src/common/song-utils.ts @@ -28,7 +28,7 @@ const scoreBadges: ScoreBadge[] = [ * @param acc - The accuracy for the score * @returns The corresponding color for the accuracy. */ -export function getScoreColorFromAccuracy(acc: number): ScoreBadge { +export function getScoreBadgeFromAccuracy(acc: number): ScoreBadge { // Check for SS+ first since it has no upper limit if (acc >= 95) { return scoreBadges[0]; // SS+ color diff --git a/src/components/player/player-header.tsx b/src/components/player/player-header.tsx index d51c623..23097b8 100644 --- a/src/components/player/player-header.tsx +++ b/src/components/player/player-header.tsx @@ -1,13 +1,13 @@ -import { formatNumberWithCommas, formatPp } from "@/common/number-utils"; -import { GlobeAmericasIcon } from "@heroicons/react/24/solid"; +import {formatNumberWithCommas, formatPp} from "@/common/number-utils"; +import {GlobeAmericasIcon} from "@heroicons/react/24/solid"; import Card from "../card"; import CountryFlag from "../country-flag"; -import { Avatar, AvatarImage } from "../ui/avatar"; +import {Avatar, AvatarImage} from "../ui/avatar"; import ClaimProfile from "./claim-profile"; import PlayerStats from "./player-stats"; import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player"; import Tooltip from "@/components/tooltip"; -import { ReactElement } from "react"; +import {ReactElement} from "react"; import PlayerTrackedStatus from "@/components/player/player-tracked-status"; /** diff --git a/src/components/score/score-stats.tsx b/src/components/score/score-stats.tsx index 570f7a7..a589d50 100644 --- a/src/components/score/score-stats.tsx +++ b/src/components/score/score-stats.tsx @@ -1,10 +1,11 @@ import ScoreSaberLeaderboardToken from "@/common/model/token/scoresaber/score-saber-leaderboard-token"; import ScoreSaberScoreToken from "@/common/model/token/scoresaber/score-saber-score-token"; import { formatNumberWithCommas, formatPp } from "@/common/number-utils"; -import { getScoreColorFromAccuracy } from "@/common/song-utils"; +import { getScoreBadgeFromAccuracy } from "@/common/song-utils"; import StatValue from "@/components/stat-value"; import { XMarkIcon } from "@heroicons/react/24/solid"; import clsx from "clsx"; +import Tooltip from "@/components/tooltip"; type Badge = { name: string; @@ -39,14 +40,36 @@ const badges: Badge[] = [ leaderboard: ScoreSaberLeaderboardToken, ) => { const acc = (score.baseScore / leaderboard.maxScore) * 100; - return getScoreColorFromAccuracy(acc).color; + return getScoreBadgeFromAccuracy(acc).color; }, create: ( score: ScoreSaberScoreToken, leaderboard: ScoreSaberLeaderboardToken, ) => { const acc = (score.baseScore / leaderboard.maxScore) * 100; - return `${acc.toFixed(2)}%`; + const scoreBadge = getScoreBadgeFromAccuracy(acc); + let accDetails = `Accuracy ${scoreBadge.name != "-" ? scoreBadge.name : ""}`; + if (scoreBadge.max == null) { + accDetails += ` (> ${scoreBadge.min}%)`; + } else if (scoreBadge.min == null) { + accDetails += ` (< ${scoreBadge.max}%)`; + } else { + accDetails += ` (${scoreBadge.min}% - ${scoreBadge.max}%)`; + } + + return ( + <> + +

{accDetails}

+ + } + > +

{acc.toFixed(2)}%

+
+ + ); }, }, { diff --git a/src/hooks/use-database.ts b/src/hooks/use-database.ts index d0784c9..16c268b 100644 --- a/src/hooks/use-database.ts +++ b/src/hooks/use-database.ts @@ -1,5 +1,5 @@ -import { useContext } from "react"; -import { DatabaseContext } from "@/components/loaders/database-loader"; +import {useContext} from "react"; +import {DatabaseContext} from "@/components/loaders/database-loader"; /** * Gets the database context. diff --git a/src/instrumentation.ts b/src/instrumentation.ts index 8aff09f..ecb6528 100644 --- a/src/instrumentation.ts +++ b/src/instrumentation.ts @@ -1,12 +1,12 @@ -import * as Sentry from '@sentry/nextjs'; +import * as Sentry from "@sentry/nextjs"; export async function register() { - if (process.env.NEXT_RUNTIME === 'nodejs') { - await import('../sentry.server.config'); + if (process.env.NEXT_RUNTIME === "nodejs") { + await import("../sentry.server.config"); } - if (process.env.NEXT_RUNTIME === 'edge') { - await import('../sentry.edge.config'); + if (process.env.NEXT_RUNTIME === "edge") { + await import("../sentry.edge.config"); } }