diff --git a/src/app/(stats)/player/[ign]/_client.tsx b/src/app/(stats)/player/[ign]/_client.tsx index 5d23a0e..109db45 100644 --- a/src/app/(stats)/player/[ign]/_client.tsx +++ b/src/app/(stats)/player/[ign]/_client.tsx @@ -1,6 +1,8 @@ "use client" import { Accordion } from "@/components/ui/accordion" +import { COOKIE_VALUES } from "@/data/general" +import { Player } from "@/lib/schema/player" import { closestCenter, DndContext, DragEndEvent, KeyboardSensor, PointerSensor, useSensor, useSensors } from "@dnd-kit/core" import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from "@dnd-kit/sortable" import { useSortable } from "@dnd-kit/sortable" @@ -10,7 +12,6 @@ import { GripVertical } from "lucide-react" import { usePathname } from "next/navigation" import { useEffect, useState } from "react" -import { Player } from "@/lib/schema/player" import ArcadeStats from "./_stats/arcade/arcade" import BedwarsStats from "./_stats/bedwars/bedwars" import BlitzStats from "./_stats/blitz/blitz" @@ -25,6 +26,12 @@ import TNTGamesStats from "./_stats/tnt-games/tnt-games" import UHCStats from "./_stats/uhc/uhc" import WoolGamesStats from "./_stats/woolgames/woolgames" +export function PlayerPageLoadText() { + const path = usePathname() + + return

{`Loading stats for ${path.split("/").at(-1)}`}

+} + interface SortableStatItemProps { id: string children: React.ReactNode @@ -60,12 +67,6 @@ function SortableStatItem({ id, children }: SortableStatItemProps) { ) } -export function PlayerPageLoadText() { - const path = usePathname() - - return

{`Loading stats for ${path.split("/").at(-1)}`}

-} - export default function PlayerStats( { stats, achievements, layout }: { stats: NonNullable @@ -108,7 +109,7 @@ export default function PlayerStats( ) function updateStatsOrder(arr: string[]) { - Cookies.set("player-stats-order", JSON.stringify(arr), { + Cookies.set(COOKIE_VALUES.statsOrder, JSON.stringify(arr), { secure: process.env.NODE_ENV === "production", sameSite: "lax", expires: 365 diff --git a/src/app/(stats)/player/[ign]/page.tsx b/src/app/(stats)/player/[ign]/page.tsx index 64e96a4..dbf7f72 100644 --- a/src/app/(stats)/player/[ign]/page.tsx +++ b/src/app/(stats)/player/[ign]/page.tsx @@ -1,5 +1,6 @@ import DisplayName from "@/components/player/displayname" import { Card, CardContent } from "@/components/ui/card" +import { COOKIE_VALUES } from "@/data/general" import { env } from "@/lib/env/server" import { getGuild } from "@/lib/hypixel/api/guild" import { getUuid } from "@/lib/hypixel/api/mojang" @@ -74,7 +75,7 @@ async function SuspendedPage({ params }: Pick, "param const level = getExactLevel(player.networkExp) const schema = z.array(z.string()) - const { data: layout } = schema.safeParse(JSON.parse(c.get("stats-order")?.value ?? "null")) + const { data: layout } = schema.safeParse(JSON.parse(c.get(COOKIE_VALUES.statsOrder)?.value ?? "null")) return (
diff --git a/src/data/general.ts b/src/data/general.ts new file mode 100644 index 0000000..091b8cc --- /dev/null +++ b/src/data/general.ts @@ -0,0 +1,5 @@ +const prefix = "local-hypstats" + +export const COOKIE_VALUES = { + statsOrder: `${prefix}-player-stats-order` +} as const