Fix: Address build errors in moderation logging

This commit is contained in:
gpt-engineer-app[bot]
2025-10-27 17:17:13 +00:00
parent 2de13c12e4
commit 1ebb491ffa
4 changed files with 195 additions and 106 deletions

View File

@@ -333,8 +333,12 @@ 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);
// Fetch full report details including reporter_id for audit log
const { data: reportData } = await supabase
.from('reports')
.select('reporter_id, reported_entity_type, reported_entity_id, reason')
.eq('id', reportId)
.single();
const { error } = await supabase
.from('reports')
@@ -348,17 +352,17 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
if (error) throw error;
// Log audit trail for report resolution
if (user && report) {
if (user && reportData) {
try {
await supabase.rpc('log_admin_action', {
_admin_user_id: user.id,
_target_user_id: report.reported_by,
_target_user_id: reportData.reporter_id,
_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,
reported_entity_type: reportData.reported_entity_type,
reported_entity_id: reportData.reported_entity_id,
report_reason: reportData.reason,
action: action
}
});