Added caching
This commit is contained in:
9
src/app/(stats)/player/[ign]/_client.tsx
Normal file
9
src/app/(stats)/player/[ign]/_client.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
"use client"
|
||||
|
||||
import { usePathname } from "next/navigation"
|
||||
|
||||
export function PlayerPageLoadText() {
|
||||
const path = usePathname()
|
||||
|
||||
return <p>{`Loading stats for ${path.split("/").at(-1)}`}</p>
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { getExactLevel } from "@/lib/hypixel/general/level"
|
||||
import { Loader2Icon, ShieldAlert } from "lucide-react"
|
||||
import { Metadata } from "next"
|
||||
import { Suspense } from "react"
|
||||
import { PlayerPageLoadText } from "./_client"
|
||||
import Sidebar from "./_components/Sidebar"
|
||||
import BedwarsStats from "./_stats/bedwars/bedwars"
|
||||
import BuildBattleStats from "./_stats/build-battle/build-battle"
|
||||
@@ -27,7 +28,7 @@ export async function generateMetadata({ params }: { params: Promise<{ ign: stri
|
||||
return { title: user !== null ? user.name : "Player not found" }
|
||||
}
|
||||
|
||||
export default async function PlayerPage({ params }: PageProps<"/player/[ign]">) {
|
||||
export default function PlayerPage({ params }: PageProps<"/player/[ign]">) {
|
||||
const maintenance = env.MAINTENANCE_MODE
|
||||
|
||||
if (maintenance) {
|
||||
@@ -39,23 +40,23 @@ export default async function PlayerPage({ params }: PageProps<"/player/[ign]">)
|
||||
)
|
||||
}
|
||||
|
||||
const { ign } = await params
|
||||
|
||||
return (
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="flex flex-col justify-center items-center h-screen">
|
||||
<Loader2Icon className="animate-spin size-30" />
|
||||
<p>{`Loading stats for ${ign}`}</p>
|
||||
<PlayerPageLoadText />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<SuspendedPage ign={ign} />
|
||||
<SuspendedPage params={params} />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
||||
async function SuspendedPage({ ign: pign }: { ign: string }) {
|
||||
async function SuspendedPage({ params }: Pick<PageProps<"/player/[ign]">, "params">) {
|
||||
const { ign: pign } = await params
|
||||
|
||||
const mc = await getUuid(pign)
|
||||
if (!mc) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user