Remove the per-route 'export const instant = false' opt-outs now that the root layout carries the single Cache Components opt-out. Child pages inherit the opt-out, so admin/mod/radio leaf pages that only access cached or DB data stay instant while runtime-dependent pages remain dynamic. Update the staff-smoke contract test to assert the root-layout contract.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { calcPagination, parseListParams } from "@/lib/admin-helpers";
|
|
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
|
import { getAuditLogs } from "@/lib/services/audit";
|
|
import { AuditTable } from "./audit-table";
|
|
|
|
export default async function AuditLogsPage({
|
|
params: paramsPromise,
|
|
searchParams,
|
|
}: {
|
|
params: Promise<{ locale: string }>;
|
|
searchParams: Promise<Record<string, string>>;
|
|
}) {
|
|
await paramsPromise;
|
|
const { session, permissions } = await getAdminContext();
|
|
if (!canAccess(permissions, PERMS.LOGS_VIEW, session.user.rank)) {
|
|
redirect("/admin");
|
|
}
|
|
|
|
const params = await searchParams;
|
|
const sp = new URLSearchParams(params);
|
|
const { search, perPage, page } = parseListParams(sp);
|
|
|
|
const result = await getAuditLogs({ search, page, perPage });
|
|
|
|
const pagination = calcPagination(result.total, result.page, result.perPage);
|
|
|
|
const rows = result.rows.map((r) => ({
|
|
id: r.id,
|
|
username: r.username,
|
|
action: r.action,
|
|
target: r.target,
|
|
targetId: r.targetId,
|
|
diff: r.diff,
|
|
createdAt: r.createdAt,
|
|
}));
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
<AuditTable data={{ rows, ...pagination }} />
|
|
</div>
|
|
);
|
|
}
|