Add dark mode, i18n, messenger/moderation/verify, admin CRUD parity

Web-tier features completing the AtomCMS→Next.js conversion (slice 2):

UI/UX:
- Dark mode: html.dark CSS-var overrides + ThemeSwitcher (localStorage,
  no-flash boot script) wired into the nav.
- i18n (next-intl, cookie-based / no URL routing): en + it catalogs,
  request.ts, provider in root layout, LanguageSwitcher; shell (nav,
  header, footer) fully translated. URLs + access-guard unchanged.
- globals.css: --muted/--border aliases used across admin pages.

User features:
- /messages: offline messages + friend-request accept (server action
  re-reads session, two directional rows, idempotent).
- Email verification: signed-token /verify route + sendVerification wired
  into register (best-effort, never blocks signup).
- Article reactions: toggle UI on news/[slug] + server action.
- Content moderation service (website_wordfilter + optional OpenAI
  moderations, fail-open) wired into article comments + guestbook.

Admin CRUD parity (Filament replacement):
- /admin/shop (+ new/[id]) packages CRUD + read-only orders.
- /admin/transactions read-only PayPal log.
- /admin/permissions, /admin/tags, /admin/ads (+ new/[id]),
  /admin/help-questions (+ new/[id]), /admin/radio/history,
  /admin/users/[id]/edit. All gated by requireStaff + logStaffActivity.

Verified: tsc 0, vitest 48/48, next build 0 (all routes incl. new
admin CRUD + /messages + /verify).
This commit is contained in:
Simo committed 2026-06-28 16:06:42 +02:00
1 parent 22d53d0e9c
commit 7daeccb832
45 files changed
+3312 -84

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
"use client";
import { useLocale } from "next-intl";
import { useRouter } from "next/navigation";
import { useTransition } from "react";
const LOCALES: { code: string; label: string }[] = [
{ code: "en", label: "EN" },
{ code: "it", label: "IT" },
];
/**
* Locale picker. Writes the chosen locale to the `NEXT_LOCALE` cookie (read by
* src/i18n/request.ts on the server) and refreshes the route so server
* components re-render with the new messages. No URL change — matches the
* cookie-based, routing-free i18n setup.
*/
export function LanguageSwitcher() {
const locale = useLocale();
const router = useRouter();
const [pending, startTransition] = useTransition();
function onChange(e: React.ChangeEvent<HTMLSelectElement>) {
const next = e.target.value;
document.cookie = `NEXT_LOCALE=${next};path=/;max-age=31536000;samesite=lax`;
startTransition(() => router.refresh());
}
return (
<select
value={locale}
onChange={onChange}
disabled={pending}
aria-label="Language"
className="nav-item cursor-pointer bg-transparent text-[13px]"
style={{ border: "none", padding: "0 0.25rem" }}
>
{LOCALES.map((l) => (
<option key={l.code} value={l.code}>
{l.label}
</option>
))}
</select>
);
}
+31 -18
View File
@@ -1,8 +1,12 @@
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 (
@@ -10,87 +14,96 @@ export async function Navigation() {
<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" />
Home
{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" />
Community
{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">
Articles
{t("articles")}
</Link>
<Link href="/photos" className="dropdown-item">
Photos
{t("photos")}
</Link>
<Link href="/staff" className="dropdown-item">
Staff
{t("staff")}
</Link>
<Link href="/rankings" className="dropdown-item">
Rankings
{t("rankings")}
</Link>
<Link href="/guilds" className="dropdown-item">
Guilds
{t("guilds")}
</Link>
</div>
</details>
<Link href="/leaderboard" className="nav-item">
<i className="navigation-icon leaderboards mr-1 hidden lg:inline-flex" />
Leaderboards
{t("leaderboards")}
</Link>
<Link href="/rares" className="nav-item">
Rare values
{t("rareValues")}
</Link>
<Link href="/shop" className="nav-item">
<i className="navigation-icon shop mr-1 hidden lg:inline-flex" />
Shop
{t("shop")}
</Link>
<Link href="/marketplace" className="nav-item">
Market
{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" />
Assistance
{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">
Help center
{t("helpCenter")}
</Link>
{session?.user ? (
<Link href="/help/tickets" className="dropdown-item">
My tickets
{t("myTickets")}
</Link>
) : null}
<Link href="/badges" className="dropdown-item">
Badges
{t("badges")}
</Link>
</div>
</details>
<Link href="/radio" className="nav-item">
Radio
{t("radio")}
</Link>
{session?.user ? (
<Link href="/friends" className="nav-item">
Friends
{t("friends")}
</Link>
) : null}
{session?.user ? (
<Link href="/messages" className="nav-item">
{t("messages")}
</Link>
) : null}
{isStaff ? (
<Link href="/admin" className="nav-item">
Admin
{t("admin")}
</Link>
) : null}
<div className="ml-auto flex items-center gap-x-2">
<LanguageSwitcher />
<ThemeSwitcher />
</div>
</div>
</nav>
);
+3 -1
View File
@@ -1,8 +1,10 @@
import { getTranslations } from "next-intl/server";
import { siteSettings } from "@/lib/services/site-settings";
export async function SiteFooter() {
const hotelName = await siteSettings.get("hotel_name", "Atom");
const year = new Date().getFullYear();
const t = await getTranslations("footer");
return (
<footer
@@ -10,7 +12,7 @@ export async function SiteFooter() {
style={{ backgroundColor: "var(--color-surface)", color: "var(--color-text-muted)" }}
>
<div className="md:font-semibold text-[12px] md:text-[14px]">
© {year} - {hotelName} is a not for profit educational project
{t("copyright", { year, hotel: hotelName ?? "Atom" })}
</div>
</footer>
);
+8 -9
View File
@@ -1,9 +1,11 @@
import { getTranslations } from "next-intl/server";
import Link from "next/link";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
export async function SiteHeader() {
const t = await getTranslations("header");
const [session, hotelName, header, logo] = await Promise.all([
auth(),
siteSettings.get("hotel_name", "Atom"),
@@ -50,7 +52,7 @@ export async function SiteHeader() {
style={{ backgroundColor: "var(--color-surface)" }}
/>
<span className="relative">
{online} {hotelName} online
{t("online", { count: online, hotel: hotelName ?? "Atom" })}
</span>
</div>
</div>
@@ -66,7 +68,7 @@ export async function SiteHeader() {
borderColor: "rgba(255,255,255,0.3)",
}}
>
Nitro client
{t("nitroClient")}
</button>
</Link>
</div>
@@ -77,10 +79,7 @@ export async function SiteHeader() {
className="font-semibold flex flex-col items-center md:w-[600px]"
style={{ color: "#ffffff", textShadow: "0 1px 4px rgba(0,0,0,0.7)" }}
>
<p className="hidden text-center text-xl md:block">
An online virtual world where you can create your own avatar, make friends, chat,
create rooms and much more!
</p>
<p className="hidden text-center text-xl md:block">{t("tagline")}</p>
<div className="flex flex-col items-center justify-center gap-x-6 gap-y-4 md:mt-6 md:flex-row md:gap-y-0">
<Link href="/login">
<button
@@ -92,17 +91,17 @@ export async function SiteHeader() {
color: "var(--button-text-color)",
}}
>
Login
{t("login")}
</button>
</Link>
<p className="text-sm uppercase">Or</p>
<p className="text-sm uppercase">{t("or")}</p>
<Link href="/register">
<button
type="button"
className="uppercase px-8 py-2.5 rounded-full transition ease-in-out duration-200"
style={{ backgroundColor: "var(--color-accent)", color: "#ffffff" }}
>
Create an account
{t("createAccount")}
</button>
</Link>
</div>
+42
View File
@@ -0,0 +1,42 @@
"use client";
import { useEffect, useState } from "react";
/**
* Light/dark toggle. The actual class lives on <html> (so `.app.dark` selectors
* and the dark CSS-var block apply); we mirror localStorage so the choice
* survives reloads. The inline boot script in the root layout applies the saved
* theme before paint to avoid a flash — this component only reflects/toggles it.
*/
export function ThemeSwitcher() {
const [dark, setDark] = useState(false);
useEffect(() => {
setDark(document.documentElement.classList.contains("dark"));
}, []);
function toggle() {
const next = !dark;
setDark(next);
document.documentElement.classList.toggle("dark", next);
try {
localStorage.setItem("theme", next ? "dark" : "light");
} catch {
/* private mode / storage disabled — runtime toggle still works */
}
}
return (
<button
type="button"
onClick={toggle}
className="nav-item cursor-pointer"
aria-label={dark ? "Switch to light mode" : "Switch to dark mode"}
title={dark ? "Light mode" : "Dark mode"}
>
<span aria-hidden className="text-lg leading-none">
{dark ? "☀" : "☾"}
</span>
</button>
);
}