This commit is contained in:
parent
4acc4c4406
commit
6b02a0f139
@ -13,11 +13,11 @@ export async function GET(request: NextRequest) {
|
|||||||
await connectMongo(); // Connect to Mongo
|
await connectMongo(); // Connect to Mongo
|
||||||
|
|
||||||
const foundPlayer: IPlayer | null = await PlayerModel.findById(id);
|
const foundPlayer: IPlayer | null = await PlayerModel.findById(id);
|
||||||
const response: { tracked: boolean; lastTracked?: string } = {
|
const response: { tracked: boolean; trackedSince?: string } = {
|
||||||
tracked: foundPlayer != null,
|
tracked: foundPlayer != null,
|
||||||
};
|
};
|
||||||
if (foundPlayer != null) {
|
if (foundPlayer != null) {
|
||||||
response["lastTracked"] = foundPlayer.trackedSince?.toUTCString();
|
response["trackedSince"] = foundPlayer.trackedSince?.toUTCString();
|
||||||
}
|
}
|
||||||
return NextResponse.json(response);
|
return NextResponse.json(response);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import ky from "ky";
|
|||||||
import { config } from "../../../config";
|
import { config } from "../../../config";
|
||||||
import Tooltip from "@/components/tooltip";
|
import Tooltip from "@/components/tooltip";
|
||||||
import { InformationCircleIcon } from "@heroicons/react/16/solid";
|
import { InformationCircleIcon } from "@heroicons/react/16/solid";
|
||||||
|
import { format } from "@formkit/tempo";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
player: ScoreSaberPlayer;
|
player: ScoreSaberPlayer;
|
||||||
@ -18,6 +19,7 @@ export default function PlayerTrackedStatus({ player }: Props) {
|
|||||||
ky
|
ky
|
||||||
.get<{
|
.get<{
|
||||||
tracked: boolean;
|
tracked: boolean;
|
||||||
|
trackedSince: string;
|
||||||
}>(`${config.siteUrl}/api/player/isbeingtracked?id=${player.id}`)
|
}>(`${config.siteUrl}/api/player/isbeingtracked?id=${player.id}`)
|
||||||
.json(),
|
.json(),
|
||||||
});
|
});
|
||||||
@ -29,7 +31,12 @@ export default function PlayerTrackedStatus({ player }: Props) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
display={<p>This player is having their statistics tracked!</p>}
|
display={
|
||||||
|
<div className="flex flex-col justify-center items-center">
|
||||||
|
<p>This player is having their statistics tracked!</p>
|
||||||
|
<p>Tracked Since: {format(data.trackedSince)}</p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
side="bottom"
|
side="bottom"
|
||||||
>
|
>
|
||||||
<InformationCircleIcon className="w-6 h-6 text-neutral-200" />
|
<InformationCircleIcon className="w-6 h-6 text-neutral-200" />
|
||||||
|
Reference in New Issue
Block a user