This commit is contained in:
1 parent
21a61068fb
commit
60278b9e71
38 files changed
+3452
No files matched your search
@@ -0,0 +1,48 @@
|
||||
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">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight">Audit Logs</h1>
|
||||
<p className="text-muted-foreground">Track admin actions and changes</p>
|
||||
</div>
|
||||
|
||||
<AuditTable data={{ rows, ...pagination }} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user