recode most things - still wip
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 2m0s
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 2m0s
This commit is contained in:
46
src/app/player/[id]/page.tsx
Normal file
46
src/app/player/[id]/page.tsx
Normal file
@ -0,0 +1,46 @@
|
||||
import { NotFound } from "@/components/not-found";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { getPlayer } from "mcutils-library";
|
||||
import { Player } from "mcutils-library/dist/types/player/player";
|
||||
import { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Lookup Player",
|
||||
};
|
||||
|
||||
async function getData(id: string): Promise<Player | null> {
|
||||
try {
|
||||
const cachedPlayer = await getPlayer(id);
|
||||
return cachedPlayer.player;
|
||||
} catch (error) {
|
||||
return null; // Player not found
|
||||
}
|
||||
}
|
||||
|
||||
type Params = {
|
||||
params: {
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
|
||||
export default async function Page({ params }: Params) {
|
||||
const player = await getData(params.id);
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col items-center">
|
||||
<div className="mb-4 text-center">
|
||||
<h1 className="text-xl">Lookup a Player</h1>
|
||||
<p>You can enter a players uuid or username to get information about the player.</p>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
{player == null && <NotFound message="Player not found" />}
|
||||
{player != null && (
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<p>Username: {player.username}</p>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user