Feat: Implement Audit Logging and integrate into Reservation actions

This commit is contained in:
2025-12-03 22:32:34 +03:00
parent eb4fedef2a
commit 9538107a13
4 changed files with 115 additions and 24 deletions

21
src/lib/logger.ts Normal file
View File

@@ -0,0 +1,21 @@
import { createClient } from "@/lib/supabase/server"
export async function logAction(
action: string,
entityType: string,
entityId: string,
details?: any
) {
const supabase = await createClient()
const { data: { user } } = await supabase.auth.getUser()
if (!user) return
await supabase.from('audit_logs').insert({
user_id: user.id,
action,
entity_type: entityType,
entity_id: entityId,
details,
})
}