Add missing admin action files and navigation links

- Add 11 missing server action files: badges, bulk-users, catalog, catalog-bc, catalog-items, import-badges, import-furni, multi-account-detect, permissions, rooms, soundtracks
- Add missing admin navigation links: tickets, sounds, translations, import, radio sub-pages
- Add translation keys for all new navigation items
This commit is contained in:
openhands committed 2026-07-11 12:01:05 +02:00
1 parent 7e1ae17a3b
commit 41be6835bf
347 files changed
+28378 -6091

No files matched your search

+43 -141
View File
@@ -1,152 +1,54 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { StatusCard } from "@/components/admin/dashboard";
import { prisma } from "@/lib/prisma";
import { DoorOpen } from "lucide-react";
import { fetchAdminList } from '@/lib/admin-list'
import { canAccess, PERMS } from '@/lib/permissions'
import { RoomsTable } from './rooms-table'
export const dynamic = "force-dynamic";
const PER_PAGE = 25;
type RoomRow = {
id: number;
name: string;
ownerName: string;
users: number;
usersMax: number;
state: string;
category: number;
};
export default async function AdminRooms({
export default async function RoomsPage({
params: paramsPromise,
searchParams,
}: {
searchParams: Promise<{ q?: string; page?: string }>;
params: Promise<{ locale: string }>
searchParams: Promise<Record<string, string>>
}) {
const t = await getTranslations("pages.admin.rooms");
const sp = await searchParams;
const q = (sp.q ?? "").trim();
const page = Math.max(1, Number(sp.page ?? "1") || 1);
const where = q
? { OR: [{ name: { contains: q } }, { ownerName: { contains: q } }] }
: {};
let rooms: RoomRow[] = [];
let total = 0;
try {
[rooms, total] = await Promise.all([
prisma.rooms.findMany({
where,
select: {
id: true,
name: true,
ownerName: true,
users: true,
usersMax: true,
state: true,
category: true,
},
orderBy: { id: "desc" },
skip: (page - 1) * PER_PAGE,
take: PER_PAGE,
const result = await fetchAdminList(
{
permission: PERMS.ROOMS_VIEW,
model: 'room',
searchFields: ['name', 'owner.username'],
include: { owner: { select: { username: true } } },
mapRow: (r) => ({
id: r.id,
name: r.name,
ownerName: r.owner.username,
ownerId: r.owner?.id ?? 0,
state: r.state,
users: r.users,
usersMax: r.usersMax,
description: r.description,
}),
prisma.rooms.count({ where }),
]);
} catch {
rooms = [];
total = 0;
}
},
paramsPromise,
searchParams,
)
const pages = Math.max(1, Math.ceil(total / PER_PAGE));
const qs = (p: number) =>
`/admin/rooms?q=${encodeURIComponent(q)}&page=${p}`;
const openOnPage = rooms.filter((r) => r.state === "open").length;
const usersOnPage = rooms.reduce((sum, r) => sum + r.users, 0);
const canEdit = canAccess(result.permissions, PERMS.ROOMS_VIEW, result.rank) && result.rank >= 4
return (
<main>
<div className="flex items-center gap-3 mb-6">
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--color-primary)]/20 to-[var(--color-primary)]/5 grid place-items-center">
<DoorOpen size={20} className="text-[var(--color-primary)]" />
</div>
<div>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">{t("title")}</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">{q ? t("matchingQuery", { query: q }) + " · " : ""}{t("totalRooms", { count: total })}</p>
</div>
<div className="space-y-6">
<div>
<h1 className="text-3xl font-bold tracking-tight">Rooms</h1>
<p className="text-muted-foreground">{result.total.toLocaleString()} rooms total</p>
</div>
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
<StatusCard label={q ? t("matchingRooms") : t("totalRooms", { count: total })} value={total} icon="🏠" />
<StatusCard label={t("openThisPage")} value={openOnPage} state="ok" icon="🔓" />
<StatusCard label={t("usersInRoom")} value={usersOnPage} icon="👥" />
</div>
<form className="flex gap-2 mb-4">
<input name="q" defaultValue={q} placeholder={t("searchPlaceholder")} />
<button type="submit" className="btn btn-primary">
{t("search")}
</button>
</form>
<div className="admin-card overflow-x-auto" style={{ padding: 0 }}>
<table>
<thead>
<tr>
<th>{t("colId")}</th>
<th>{t("colName")}</th>
<th>{t("colOwner")}</th>
<th>{t("colUsers")}</th>
<th>{t("colState")}</th>
<th>{t("colCategory")}</th>
</tr>
</thead>
<tbody>
{rooms.map((r) => (
<tr key={r.id}>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{r.id}</td>
<td>
<Link href={`/admin/rooms/${r.id}`}>{r.name || t("unnamed")}</Link>
</td>
<td>{r.ownerName || "—"}</td>
<td>
{r.users} / {r.usersMax}
</td>
<td>
<span className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${r.state === "open" ? "bg-green-600/20 text-[var(--color-text)]" : "bg-red-500/22 text-[var(--color-text)]"}`}>
{r.state}
</span>
</td>
<td>{r.category}</td>
</tr>
))}
</tbody>
</table>
</div>
{rooms.length === 0 ? (
<p className="text-xs text-gray-500 dark:text-gray-400" style={{ marginTop: "1rem" }}>
{t("noRooms")}
</p>
) : null}
<p className="text-xs text-gray-500 dark:text-gray-400" style={{ marginTop: "1rem" }}>
{t("pagination", { page, pages, total })}
{page > 1 ? (
<>
{" · "}
<Link href={qs(page - 1)}>← {t("prev")}</Link>
</>
) : null}
{page < pages ? (
<>
{" · "}
<Link href={qs(page + 1)}>{t("next")} →</Link>
</>
) : null}
</p>
</main>
);
<RoomsTable
data={{
rows: result.rows,
total: result.total,
page: result.page,
perPage: result.perPage,
lastPage: result.lastPage,
}}
canEdit={canEdit}
/>
</div>
)
}