Files
Epicnabbo-Catalogus-Updated…/src/components/navigation.tsx
T
simoleo f7b3845131 Close the web-feasible 100% gaps: REST write/token API, tickets, draw-badge, /me, sanitisation, dusk, radio SSE
Final parity push (web-tier only):
- REST API write + token auth: POST /api/tokens (issue a personal_access_token
  for the session user), Bearer auth via src/lib/api-auth.ts, POST
  /api/articles/[slug]/comment, GET/DELETE /api/me/tokens, full tickets API
  (/api/tickets +[id] +[id]/reply), radio current-dj/points/points-leaderboard/
  embed-config + POST shouts, and a real-time /api/radio/stream (SSE). 31 public
  API routes total.
- Pages: /draw-badge (buy a custom profile badge → credits + RCON), /me
  dashboard (stats + online friends + referral claim). Wired into the nav.
- HTML sanitisation (sanitize-html) — the HTMLPurifier equivalent — applied to
  writeable boxes + article bodies before dangerouslySetInnerHTML.
- "Dusk" dark theme preset + a default-dark site option honoured by the
  no-flash boot script.

Verified live (prod, amx_test): token issue → Bearer endpoint 200, no-token
401; /api/me/tokens lists it; current-dj/leaderboard JSON; /me + /draw-badge
200; reverted the test user + tokens. tsc 0, vitest 49/49, next build 0.
2026-06-29 18:15:01 +02:00

114 lines
3.9 KiB
TypeScript

import { getTranslations } from "next-intl/server";
import Link from "next/link";
import { auth } from "@/lib/auth";
import { LanguageSwitcher } from "@/components/language-switcher";
import { ThemeSwitcher } from "@/components/theme-switcher";
export async function Navigation() {
const session = await auth();
const t = await getTranslations("nav");
const isStaff = (session?.user?.rank ?? 0) >= 7;
return (
<nav className="relative shadow-sm" style={{ backgroundColor: "var(--color-navbar)" }}>
<div className="max-w-7xl min-h-[60px] px-4 flex items-center gap-x-6 md:gap-x-8 mx-auto flex-wrap">
<Link href="/" className="nav-item">
<i className="navigation-icon home mr-1 hidden lg:inline-flex" />
{t("home")}
</Link>
<details className="relative">
<summary className="nav-item list-none cursor-pointer [&::-webkit-details-marker]:hidden">
<i className="navigation-icon community mr-1 hidden lg:inline-flex" />
{t("community")}
</summary>
<div
className="absolute left-0 mt-1 min-w-[190px] rounded-md shadow-lg z-50 py-1"
style={{ backgroundColor: "var(--color-dropdown)" }}
>
<Link href="/news" className="dropdown-item">
{t("articles")}
</Link>
<Link href="/photos" className="dropdown-item">
{t("photos")}
</Link>
<Link href="/staff" className="dropdown-item">
{t("staff")}
</Link>
<Link href="/rankings" className="dropdown-item">
{t("rankings")}
</Link>
<Link href="/guilds" className="dropdown-item">
{t("guilds")}
</Link>
</div>
</details>
<Link href="/leaderboard" className="nav-item">
<i className="navigation-icon leaderboards mr-1 hidden lg:inline-flex" />
{t("leaderboards")}
</Link>
<Link href="/rares" className="nav-item">
{t("rareValues")}
</Link>
<Link href="/shop" className="nav-item">
<i className="navigation-icon shop mr-1 hidden lg:inline-flex" />
{t("shop")}
</Link>
<Link href="/marketplace" className="nav-item">
{t("market")}
</Link>
<details className="relative">
<summary className="nav-item list-none cursor-pointer [&::-webkit-details-marker]:hidden">
<i className="navigation-icon rules mr-1 hidden lg:inline-flex" />
{t("assistance")}
</summary>
<div
className="absolute left-0 mt-1 min-w-[190px] rounded-md shadow-lg z-50 py-1"
style={{ backgroundColor: "var(--color-dropdown)" }}
>
<Link href="/help" className="dropdown-item">
{t("helpCenter")}
</Link>
{session?.user ? (
<Link href="/help/tickets" className="dropdown-item">
{t("myTickets")}
</Link>
) : null}
<Link href="/badges" className="dropdown-item">
{t("badges")}
</Link>
<Link href="/draw-badge" className="dropdown-item">
{t("drawBadge")}
</Link>
</div>
</details>
<Link href="/radio" className="nav-item">
{t("radio")}
</Link>
{session?.user ? (
<Link href="/friends" className="nav-item">
{t("friends")}
</Link>
) : null}
{session?.user ? (
<Link href="/messages" className="nav-item">
{t("messages")}
</Link>
) : null}
{isStaff ? (
<Link href="/admin" className="nav-item">
{t("admin")}
</Link>
) : null}
<div className="ml-auto flex items-center gap-x-2">
<LanguageSwitcher />
<ThemeSwitcher />
</div>
</div>
</nav>
);
}