Files
EpicNext-Cms/src/app/admin/events/page.tsx
T
simoleo89andCursor 3cb8b92cb3 Polish admin hub pages: drop duplicate headers, align CTAs and empties.
Remove redundant titles under AdminHubChrome, style events/polls create flows with admin chrome + i18n, and standardize empty states / teams form classes.

Co-authored-by: Cursor <[email protected]>
2026-07-18 21:28:15 +02:00

66 lines
1.5 KiB
TypeScript

import Link from "next/link";
import { getTranslations } from "next-intl/server";
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 t = await getTranslations("pages.admin.events");
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 justify-end">
<Link href="/admin/events/create" className="btn btn-primary">
{t("newEvent")}
</Link>
</div>
<EventsTable
data={{
rows: result.rows,
total: result.total,
page: result.page,
perPage: result.perPage,
lastPage: result.lastPage,
}}
/>
</div>
);
}