Implemented guild page
This commit is contained in:
@@ -5,5 +5,5 @@ import { usePathname } from "next/navigation"
|
|||||||
export function GuildPageLoadText() {
|
export function GuildPageLoadText() {
|
||||||
const path = usePathname()
|
const path = usePathname()
|
||||||
|
|
||||||
return <p>{`Loading guild stats for ${path.split("/").at(-1)}`}</p>
|
return <p>{`Loading ${path.split("/").at(-1)}'s guild...`}</p>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
|
import { getColor } from "@/lib/colors"
|
||||||
import { env } from "@/lib/env/server"
|
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 { Loader2Icon, ShieldAlert } from "lucide-react"
|
||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
import { GuildPageLoadText } from "./_client"
|
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">) {
|
async function SuspendedPage({ params }: Pick<PageProps<"/guild/[value]">, "params">) {
|
||||||
const { value } = await 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'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 (
|
return (
|
||||||
<div className="flex flex-col items-center pb-5 pt-35">
|
<div className="flex flex-col items-center pb-5 pt-30">
|
||||||
{value}
|
<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>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import Sidebar from "./_components/Sidebar"
|
|||||||
export async function generateMetadata({ params }: { params: Promise<{ ign: string }> }): Promise<Metadata> {
|
export async function generateMetadata({ params }: { params: Promise<{ ign: string }> }): Promise<Metadata> {
|
||||||
const { ign } = await params
|
const { ign } = await params
|
||||||
const user = await getUuid(ign)
|
const user = await getUuid(ign)
|
||||||
return { title: user !== null ? user.name : "Player not found" }
|
return { title: user !== null ? `${user.name}'s Stats` : "Player not found" }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PlayerPage({ params }: PageProps<"/player/[ign]">) {
|
export default function PlayerPage({ params }: PageProps<"/player/[ign]">) {
|
||||||
|
|||||||
Reference in New Issue
Block a user