From eeb4f56e79053f0ce32412c46ec295f75a46b578 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 28 Sep 2024 15:07:23 +0100 Subject: [PATCH] add days ago to tracked status --- src/components/player/player-tracked-status.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/player/player-tracked-status.tsx b/src/components/player/player-tracked-status.tsx index 85ecfb8..12fe157 100644 --- a/src/components/player/player-tracked-status.tsx +++ b/src/components/player/player-tracked-status.tsx @@ -8,6 +8,7 @@ import Tooltip from "@/components/tooltip"; import { InformationCircleIcon } from "@heroicons/react/16/solid"; import { format } from "@formkit/tempo"; import { PlayerTrackedSince } from "@/common/player/player-tracked-since"; +import { getDaysAgo } from "@/common/time-utils"; type Props = { player: ScoreSaberPlayer; @@ -28,13 +29,25 @@ export default function PlayerTrackedStatus({ player }: Props) { return undefined; } + const trackedSince = new Date(data.trackedSince!); + const daysAgo = getDaysAgo(trackedSince) + 1; + let daysAgoFormatted = `${daysAgo} day${daysAgo > 1 ? "s" : ""} ago`; + if (daysAgo === 1) { + daysAgoFormatted = "Today"; + } + if (daysAgo === 2) { + daysAgoFormatted = "Yesterday"; + } + return (

This player is having their statistics tracked!

-

Tracked Since: {format(new Date(data.trackedSince!))}

+

+ Tracked Since: {format(trackedSince)} ({daysAgoFormatted}) +

} side="bottom"