From de441b698c9ff250ae0dbef9217f37dfdf0f8cbc Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 29 Oct 2024 18:52:14 +0000 Subject: [PATCH] smh my head --- projects/common/src/player/player-stat-change.ts | 4 ++-- projects/common/src/player/player.ts | 6 ++---- .../website/src/components/statistic/change-over-time.tsx | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/projects/common/src/player/player-stat-change.ts b/projects/common/src/player/player-stat-change.ts index e771d7c..7358956 100644 --- a/projects/common/src/player/player-stat-change.ts +++ b/projects/common/src/player/player-stat-change.ts @@ -1,5 +1,5 @@ import ScoreSaberPlayer from "./impl/scoresaber-player"; -import { Timeframe } from "../timeframe"; +import { StatisticRange } from "./player"; export type PlayerStatValue = { /** @@ -10,7 +10,7 @@ export type PlayerStatValue = { /** * The value of the stat. */ - value: (player: ScoreSaberPlayer, range: Timeframe) => number | undefined; + value: (player: ScoreSaberPlayer, range: StatisticRange) => number | undefined; }; export type PlayerStatChangeType = diff --git a/projects/common/src/player/player.ts b/projects/common/src/player/player.ts index b9cf3da..8c43c6a 100644 --- a/projects/common/src/player/player.ts +++ b/projects/common/src/player/player.ts @@ -1,5 +1,4 @@ import { PlayerHistory } from "./player-history"; -import { Timeframe } from "../timeframe"; export default class Player { /** @@ -56,8 +55,7 @@ export default class Player { } } +export type StatisticRange = "daily" | "weekly" | "monthly"; export type StatisticChange = { - daily: PlayerHistory; - weekly: PlayerHistory; - monthly: PlayerHistory; + [key in StatisticRange]: PlayerHistory; }; diff --git a/projects/website/src/components/statistic/change-over-time.tsx b/projects/website/src/components/statistic/change-over-time.tsx index 9981a26..6bfcb68 100644 --- a/projects/website/src/components/statistic/change-over-time.tsx +++ b/projects/website/src/components/statistic/change-over-time.tsx @@ -4,7 +4,7 @@ import { capitalizeFirstLetter } from "@/common/string-utils"; import Tooltip from "@/components/tooltip"; import { ReactElement } from "react"; import { PlayerStatValue } from "@ssr/common/player/player-stat-change"; -import { Timeframe } from "@ssr/common/timeframe"; +import { StatisticRange } from "@ssr/common/player/player"; type ChangeOverTimeProps = { /** @@ -40,7 +40,7 @@ export function ChangeOverTime({ player, type, children }: ChangeOverTimeProps) }; // Renders the change for a given time frame - const renderChange = (value: number | undefined, range: Timeframe) => ( + const renderChange = (value: number | undefined, range: StatisticRange) => (

{capitalizeFirstLetter(range)} Change:{" "} = 0 ? (value === 0 ? "" : "text-green-500") : "text-red-500"}>