oops - fix api
All checks were successful
Deploy / deploy (push) Successful in 2m41s

This commit is contained in:
Lee 2024-09-28 14:48:34 +01:00
parent 4acc4c4406
commit 6b02a0f139
2 changed files with 10 additions and 3 deletions

View File

@ -13,11 +13,11 @@ export async function GET(request: NextRequest) {
await connectMongo(); // Connect to Mongo
const foundPlayer: IPlayer | null = await PlayerModel.findById(id);
const response: { tracked: boolean; lastTracked?: string } = {
const response: { tracked: boolean; trackedSince?: string } = {
tracked: foundPlayer != null,
};
if (foundPlayer != null) {
response["lastTracked"] = foundPlayer.trackedSince?.toUTCString();
response["trackedSince"] = foundPlayer.trackedSince?.toUTCString();
}
return NextResponse.json(response);
}

View File

@ -6,6 +6,7 @@ import ky from "ky";
import { config } from "../../../config";
import Tooltip from "@/components/tooltip";
import { InformationCircleIcon } from "@heroicons/react/16/solid";
import { format } from "@formkit/tempo";
type Props = {
player: ScoreSaberPlayer;
@ -18,6 +19,7 @@ export default function PlayerTrackedStatus({ player }: Props) {
ky
.get<{
tracked: boolean;
trackedSince: string;
}>(`${config.siteUrl}/api/player/isbeingtracked?id=${player.id}`)
.json(),
});
@ -29,7 +31,12 @@ export default function PlayerTrackedStatus({ player }: Props) {
return (
<div className="flex gap-2">
<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"
>
<InformationCircleIcon className="w-6 h-6 text-neutral-200" />