All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 55s
40 lines
950 B
TypeScript
40 lines
950 B
TypeScript
"use client";
|
|
|
|
import { useRouter } from "next/navigation";
|
|
import { useState } from "react";
|
|
import { Button } from "../ui/button";
|
|
import { Input } from "../ui/input";
|
|
|
|
export function LookupPlayer(): JSX.Element {
|
|
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 (
|
|
<form className="flex gap-2 justify-center mt-2">
|
|
<Input className="w-fit" placeholder="UUID / Username" value={player} onChange={setPlayerValue} maxLength={36} />
|
|
<Button type="submit" onClick={() => lookupPlayer()}>
|
|
Lookup
|
|
</Button>
|
|
</form>
|
|
);
|
|
}
|