chore: initial project import
Some checks failed
CI - Production Readiness / Verify (push) Has been cancelled
Some checks failed
CI - Production Readiness / Verify (push) Has been cancelled
This commit is contained in:
45
app/audit-log/page.tsx
Normal file
45
app/audit-log/page.tsx
Normal file
@ -0,0 +1,45 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { getSession } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { ShellPage } from "@/components/page-templates";
|
||||
import { TablePlaceholder } from "@/components/placeholders";
|
||||
|
||||
function toTime(value: Date) {
|
||||
return new Intl.DateTimeFormat("id-ID", {
|
||||
day: "2-digit",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
export default async function TenantAuditLogPage() {
|
||||
const session = await getSession();
|
||||
if (!session) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
const audits = await prisma.auditLog.findMany({
|
||||
where: { tenantId: session.tenantId },
|
||||
include: { actorUser: true },
|
||||
orderBy: { createdAt: "desc" }
|
||||
});
|
||||
|
||||
return (
|
||||
<ShellPage shell="admin" title="Audit Log" description="User activity, message action, dan campaign action logs.">
|
||||
<TablePlaceholder
|
||||
title="Audit events"
|
||||
columns={["Time", "Actor", "Module", "Action", "Entity"]}
|
||||
rows={audits.map((audit) => [
|
||||
toTime(audit.createdAt),
|
||||
audit.actorUser?.fullName ?? "System",
|
||||
audit.entityType,
|
||||
audit.action,
|
||||
audit.entityId
|
||||
])}
|
||||
/>
|
||||
</ShellPage>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user