Add check-in audit logging + in-app history view

Every successful check-in/undo writes a row to the "2026 Ticket Audit Logs"
NocoDB table (timestamp, people, code, action, name, remaining-after).
Non-fatal: audit failures never block a gate check-in. New GET /api/audit
endpoint (global or per-code). Admin panel gains a global "Recent check-ins"
panel and per-ticket history. Audit table is optional via NOCODB_AUDIT_TABLE_ID.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Hank 2026-07-08 03:53:30 +00:00
parent 3397e3e3ec
commit b36d63a6a4
11 changed files with 342 additions and 4 deletions

View file

@ -42,6 +42,13 @@ export async function ticketRoutes(app: FastifyInstance): Promise<void> {
},
);
// Recent check-in audit log (all, or filtered to one code via ?code=).
app.get("/api/audit", { preHandler: requireStaff }, async (req) => {
const code = (req.query as any)?.code ? normalizeCode(String((req.query as any).code)) : undefined;
const limit = Number((req.query as any)?.limit) || 50;
return { enabled: app.ctx.audit.enabled, entries: await app.ctx.audit.recent({ code, limit }) };
});
// Search by name/email or exact code for the admin panel.
app.get(
"/api/tickets",