From c9e83d098099cf9abbe69cc1324579273601e581 Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 30 Aug 2025 14:38:00 +0200 Subject: [PATCH] Removed validation --- src/components/search-bar.tsx | 16 +++++++--------- src/lib/hypixel/actions.ts | 26 ++------------------------ src/lib/hypixel/server.ts | 27 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 33 deletions(-) create mode 100644 src/lib/hypixel/server.ts diff --git a/src/components/search-bar.tsx b/src/components/search-bar.tsx index 532312f..eea475f 100644 --- a/src/components/search-bar.tsx +++ b/src/components/search-bar.tsx @@ -1,12 +1,10 @@ "use client" import { Input } from "@/components/ui/input" -import { validatePlayer } from "@/lib/hypixel/actions" import { cn } from "@/lib/utils" import { Search } from "lucide-react" import { useRouter } from "next/navigation" import { useState } from "react" -import { toast } from "sonner" export function SearchBar({ navbar }: { navbar?: boolean }) { const [input, setInput] = useState("") @@ -15,13 +13,13 @@ export function SearchBar({ navbar }: { navbar?: boolean }) { async function handleSearch(e: React.FormEvent) { e.preventDefault() - const validatedPlayer = await validatePlayer(input.trim()) - - if (validatedPlayer.error === true) { - toast.error(validatedPlayer.message) - setInput("") - return - } + // const validatedPlayer = await validatePlayer(input.trim()) + // + // if (validatedPlayer.error === true) { + // toast.error(validatedPlayer.message) + // setInput("") + // return + // } if (input.trim()) { router.push(`/player/${encodeURIComponent(input.trim())}`) diff --git a/src/lib/hypixel/actions.ts b/src/lib/hypixel/actions.ts index a143b90..397d0cd 100644 --- a/src/lib/hypixel/actions.ts +++ b/src/lib/hypixel/actions.ts @@ -1,29 +1,7 @@ "use server" -import { getUuid } from "./api/mojang" -import { getPlayer } from "./api/player" +import { _validatePlayer } from "./server" export async function validatePlayer(ign: string) { - const uuid = await getUuid(ign) - - if (!uuid) { - return { - error: true, - message: "Player not found" - } - } - - const player = await getPlayer(uuid) - - if (!player) { - return { - error: true, - message: "Player never logged on to Hypixel" - } - } - - return { - error: false, - message: "Player found" - } + return await _validatePlayer(ign) } diff --git a/src/lib/hypixel/server.ts b/src/lib/hypixel/server.ts new file mode 100644 index 0000000..c5efad2 --- /dev/null +++ b/src/lib/hypixel/server.ts @@ -0,0 +1,27 @@ +import { getUuid } from "./api/mojang" +import { getPlayer } from "./api/player" + +export async function _validatePlayer(ign: string) { + const uuid = await getUuid(ign) + + if (!uuid) { + return { + error: true, + message: "Player not found" + } + } + + const player = await getPlayer(uuid) + + if (!player) { + return { + error: true, + message: "Player never logged on to Hypixel" + } + } + + return { + error: false, + message: "Player found" + } +}