add days ago to tracked status
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
Lee 2024-09-28 15:07:23 +01:00
parent e7b2594e2c
commit eeb4f56e79

@ -8,6 +8,7 @@ import Tooltip from "@/components/tooltip";
import { InformationCircleIcon } from "@heroicons/react/16/solid"; import { InformationCircleIcon } from "@heroicons/react/16/solid";
import { format } from "@formkit/tempo"; import { format } from "@formkit/tempo";
import { PlayerTrackedSince } from "@/common/player/player-tracked-since"; import { PlayerTrackedSince } from "@/common/player/player-tracked-since";
import { getDaysAgo } from "@/common/time-utils";
type Props = { type Props = {
player: ScoreSaberPlayer; player: ScoreSaberPlayer;
@ -28,13 +29,25 @@ export default function PlayerTrackedStatus({ player }: Props) {
return undefined; 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 ( return (
<div className="flex gap-2"> <div className="flex gap-2">
<Tooltip <Tooltip
display={ display={
<div className="flex flex-col justify-center items-center"> <div className="flex flex-col justify-center items-center">
<p>This player is having their statistics tracked!</p> <p>This player is having their statistics tracked!</p>
<p>Tracked Since: {format(new Date(data.trackedSince!))}</p> <p>
Tracked Since: {format(trackedSince)} ({daysAgoFormatted})
</p>
</div> </div>
} }
side="bottom" side="bottom"