feat: add admin content module pages

This commit is contained in:
Simo committed 2026-07-12 15:27:07 +02:00
1 parent f422bb4a0b
commit 2606092337
24 files changed
+2892

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
import Link from 'next/link'
import { Button } from '@/components/ui/button'
import { fetchAdminList } from '@/lib/admin-list'
import { PERMS } from '@/lib/permissions'
import { EventsTable } from './events-table'
export default async function EventsPage({
params: paramsPromise,
searchParams,
}: {
params: Promise<{ locale: string }>
searchParams: Promise<Record<string, string>>
}) {
const result = await fetchAdminList(
{
permission: PERMS.EVENTS_VIEW,
model: 'websiteEvent',
searchFields: ['title'],
defaultSort: { startsAt: 'desc' },
include: { type: { select: { name: true, color: true } } },
mapRow: (e: {
id: number
title: string
type: { name: string; color: string }
startsAt: Date
endsAt: Date | null
status: string
hostUserId: number
_count?: { registrations: number }
}) => ({
id: e.id,
title: e.title,
typeName: e.type.name,
typeColor: e.type.color,
startsAt: e.startsAt,
endsAt: e.endsAt,
status: e.status,
hostUserId: e.hostUserId,
}),
},
paramsPromise,
searchParams,
)
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div>
<h1 className="text-3xl font-bold tracking-tight">Events</h1>
<p className="text-muted-foreground">Manage hotel events, calendar and prizes</p>
</div>
<Button asChild>
<Link href="/admin/events/create">New Event</Link>
</Button>
</div>
<EventsTable
data={{
rows: result.rows,
total: result.total,
page: result.page,
perPage: result.perPage,
lastPage: result.lastPage,
}}
/>
</div>
)
}