Implemented guild page

This commit is contained in:
2025-09-26 13:44:42 +02:00
parent 785185d26a
commit 9978faf69d
3 changed files with 43 additions and 4 deletions

View File

@@ -5,5 +5,5 @@ import { usePathname } from "next/navigation"
export function GuildPageLoadText() {
const path = usePathname()
return <p>{`Loading guild stats for ${path.split("/").at(-1)}`}</p>
return <p>{`Loading ${path.split("/").at(-1)}'s guild...`}</p>
}

View File

@@ -1,4 +1,9 @@
import { getColor } from "@/lib/colors"
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 { Loader2Icon, ShieldAlert } from "lucide-react"
import { Suspense } from "react"
import { GuildPageLoadText } from "./_client"
@@ -31,9 +36,43 @@ export default function GuildPage({ params }: PageProps<"/guild/[value]">) {
async function SuspendedPage({ params }: Pick<PageProps<"/guild/[value]">, "params">) {
const { value } = await params
const mc = await getUuid(value)
if (!mc) {
return (
<div className="flex flex-col items-center min-h-screen">
<h1 className="pt-30">Player not found</h1>
</div>
)
}
const player = await getPlayer(mc.id)
if (!player) {
return (
<div className="flex flex-col items-center min-h-screen">
<h1 className="pt-30">Player hasn&apos;t joined hypixel</h1>
</div>
)
}
const guild = await getGuild(mc.id)
if (!guild) {
return (
<div className="flex flex-col items-center min-h-screen">
<h1 className="pt-30">Player is not in a guild.</h1>
</div>
)
}
return (
<div className="flex flex-col items-center pb-5 pt-35">
{value}
<div className="flex flex-col items-center pb-5 pt-30">
<div className="flex gap-2 items-center">
<h1 className="text-4xl font-bold sm:text-5xl text-stroke text-stroke-foreground dark:text-stroke-transparent">
<span className={cn(getColor(guild.tagColor, "text", "gray"))}>{guild.name}</span>
</h1>
</div>
</div>
)
}