Files
EpicNext-Cms/src/app/admin/rooms/page.tsx
T
SimoandCursor 0e89d03940
Local Build and Deploy / deploy (push) Successful in 56s
Finish fine-grained ACL across remaining admin pages and actions.
Replace leftover requireStaff gates with module PERMS, drop hardcoded room rank thresholds, and expand contract tests so admin mutations cannot regress to dashboard-only checks.

Co-authored-by: Cursor <[email protected]>
2026-07-15 20:15:22 +02:00

57 lines
1.3 KiB
TypeScript

import { fetchAdminList } from "@/lib/admin-list";
import { canAccess, PERMS } from "@/lib/permissions";
import { RoomsTable } from "./rooms-table";
export default async function RoomsPage({
params: paramsPromise,
searchParams,
}: {
params: Promise<{ locale: string }>;
searchParams: Promise<Record<string, string>>;
}) {
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,
}),
},
paramsPromise,
searchParams,
);
const canEdit = canAccess(result.permissions, PERMS.ROOMS_EDIT, result.rank);
return (
<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>
<RoomsTable
data={{
rows: result.rows,
total: result.total,
page: result.page,
perPage: result.perPage,
lastPage: result.lastPage,
}}
canEdit={canEdit}
/>
</div>
);
}