- 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
55 lines
1.4 KiB
TypeScript
55 lines
1.4 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_VIEW, result.rank) && result.rank >= 4
|
|
|
|
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>
|
|
)
|
|
}
|