Files
Epicnabbo-Catalogus-Updated…/src/app/admin/events/page.tsx
T

69 lines
1.8 KiB
TypeScript

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>
);
}