diff --git a/src/app/(stats)/guild/[value]/_client.tsx b/src/app/(stats)/guild/[value]/_client.tsx index 59a2f62..f34247e 100644 --- a/src/app/(stats)/guild/[value]/_client.tsx +++ b/src/app/(stats)/guild/[value]/_client.tsx @@ -1,9 +1,24 @@ "use client" -import { usePathname } from "next/navigation" +import { usePathname, useSearchParams } from "next/navigation" +import z from "zod" export function GuildPageLoadText() { const path = usePathname() + const params = useSearchParams() - return
{`Loading ${path.split("/").at(-1)}'s guild...`}
+ const { data: type } = z.literal("id").or(z.literal("name")).or(z.literal("player")).default("player").safeParse(params.get("type")) + + switch (type) { + case "player": + return{`Loading stats ${path.split("/").at(-1)}'s guild...`}
+ case "id": + return{`Loading stats for the guild id ${path.split("/").at(-1)}...`}
+ case "name": + return{`Loading stats for the guild name ${path.split("/").at(-1)}...`}
+ case undefined: + return{`Loading stats ${path.split("/").at(-1)}'s guild...`}
+ default: + throw new Error(`Unknown type: ${type satisfies never}`) + } } diff --git a/src/app/(stats)/guild/[value]/page.tsx b/src/app/(stats)/guild/[value]/page.tsx index 12105b3..e3abe0d 100644 --- a/src/app/(stats)/guild/[value]/page.tsx +++ b/src/app/(stats)/guild/[value]/page.tsx @@ -3,12 +3,13 @@ import { env } from "@/lib/env/server" import { getGuild } from "@/lib/hypixel/api/guild" import { getUuid } from "@/lib/hypixel/api/mojang" import { getPlayer } from "@/lib/hypixel/api/player" -import { cn } from "@/lib/utils" +import { cn, parseSearchParams } from "@/lib/utils" import { Loader2Icon, ShieldAlert } from "lucide-react" import { Suspense } from "react" +import z from "zod" import { GuildPageLoadText } from "./_client" -export default function GuildPage({ params }: PageProps<"/guild/[value]">) { +export default function GuildPage({ params, searchParams }: PageProps<"/guild/[value]">) { const maintenance = env.MAINTENANCE_MODE if (maintenance) { @@ -29,13 +30,16 @@ export default function GuildPage({ params }: PageProps<"/guild/[value]">) { } > -