add lookup player input
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 58s
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 58s
This commit is contained in:
parent
74627311ae
commit
1d40c9b5d3
@ -1,4 +1,5 @@
|
|||||||
import { generateEmbed } from "@/common/embed";
|
import { generateEmbed } from "@/common/embed";
|
||||||
|
import { LookupPlayer } from "@/components/lookup-player";
|
||||||
import { NotFound } from "@/components/not-found";
|
import { NotFound } from "@/components/not-found";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "@/components/ui/card";
|
||||||
import { getPlayer } from "mcutils-library";
|
import { getPlayer } from "mcutils-library";
|
||||||
@ -49,6 +50,8 @@ export default async function Page({ params }: Params) {
|
|||||||
<div className="mb-4 text-center">
|
<div className="mb-4 text-center">
|
||||||
<h1 className="text-xl">Lookup a Player</h1>
|
<h1 className="text-xl">Lookup a Player</h1>
|
||||||
<p>You can enter a players uuid or username to get information about the player.</p>
|
<p>You can enter a players uuid or username to get information about the player.</p>
|
||||||
|
|
||||||
|
<LookupPlayer />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
|
37
src/components/lookup-player.tsx
Normal file
37
src/components/lookup-player.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Button } from "./ui/button";
|
||||||
|
import { Input } from "./ui/input";
|
||||||
|
|
||||||
|
export function LookupPlayer() {
|
||||||
|
const router = useRouter();
|
||||||
|
const [player, setPlayer] = useState("");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the player value
|
||||||
|
*
|
||||||
|
* @param event the input event
|
||||||
|
*/
|
||||||
|
const setPlayerValue = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setPlayer(event.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup a player
|
||||||
|
*/
|
||||||
|
const lookupPlayer = () => {
|
||||||
|
if (!player || player.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
router.push(`/player/${player}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex gap-2 justify-center mt-2">
|
||||||
|
<Input className="w-fit" placeholder="Player UUID / Username" value={player} onChange={setPlayerValue} />
|
||||||
|
<Button onClick={() => lookupPlayer()}>Lookup</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user