feat: Implement comprehensive audit logging

This commit is contained in:
gpt-engineer-app[bot]
2025-10-27 17:14:24 +00:00
parent 79277c744a
commit 2de13c12e4
4 changed files with 158 additions and 0 deletions

View File

@@ -333,16 +333,40 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
const handleReportAction = async (reportId: string, action: 'reviewed' | 'dismissed') => {
setActionLoading(reportId);
try {
// Fetch report details for audit log
const report = reports.find(r => r.id === reportId);
const { error } = await supabase
.from('reports')
.update({
status: action,
reviewed_by: user?.id,
reviewed_at: new Date().toISOString(),
})
.eq('id', reportId);
if (error) throw error;
// Log audit trail for report resolution
if (user && report) {
try {
await supabase.rpc('log_admin_action', {
_admin_user_id: user.id,
_target_user_id: report.reported_by,
_action: action === 'reviewed' ? 'report_resolved' : 'report_dismissed',
_details: {
report_id: reportId,
reported_entity_type: report.reported_entity_type,
reported_entity_id: report.reported_entity_id,
report_reason: report.reason,
action: action
}
});
} catch (auditError) {
console.error('Failed to log report action audit:', auditError);
}
}
handleSuccess(`Report ${action}`, `The report has been marked as ${action}`);
// Remove report from queue