import { env } from "@/lib/env/server"
import { Loader2Icon, ShieldAlert } from "lucide-react"
import { Suspense } from "react"
import { GuildPageLoadText } from "./_client"

export default function GuildPage({ params }: PageProps<"/guild/[value]">) {
    const maintenance = env.MAINTENANCE_MODE

    if (maintenance) {
        return (
            <div className="flex flex-col gap-2 justify-center items-center h-screen">
                <ShieldAlert className="size-30" />
                <h1 className="text-xl">Not available right now. This is just so I could have a front page for Hypixel Production API Key.</h1>
            </div>
        )
    }

    return (
        <Suspense
            fallback={
                <div className="flex flex-col justify-center items-center h-screen">
                    <Loader2Icon className="animate-spin size-30" />
                    <GuildPageLoadText />
                </div>
            }
        >
            <SuspendedPage params={params} />
        </Suspense>
    )
}

async function SuspendedPage({ params }: Pick<PageProps<"/guild/[value]">, "params">) {
    const { value } = await params
    return (
        <div className="flex flex-col items-center pb-5 pt-35">
            {value}
        </div>
    )
}
