Fix moderation status update

This commit is contained in:
gpt-engineer-app[bot]
2025-09-28 23:31:33 +00:00
parent a32456ba3f
commit 659d1b2c91

View File

@@ -209,25 +209,37 @@ export function ModerationQueue() {
updateData.reviewer_notes = moderatorNotes;
}
const { error } = await supabase
console.log('Updating item:', item.id, 'with data:', updateData);
const { error, data } = await supabase
.from(table)
.update(updateData)
.eq('id', item.id);
.eq('id', item.id)
.select();
if (error) throw error;
if (error) {
console.error('Database update error:', error);
throw error;
}
console.log('Update successful:', data);
toast({
title: `Content ${action}`,
description: `The ${item.type} has been ${action}`,
});
// Remove item from queue if it's no longer in the active filter
if (activeStatusFilter === 'pending' || activeStatusFilter === 'flagged') {
setItems(prev => prev.filter(i => i.id !== item.id));
} else {
// Refresh the queue to show updated status
// Update the local state immediately
setItems(prev => prev.map(i =>
i.id === item.id
? { ...i, status: action }
: i
));
// Also refresh the queue after a short delay to ensure consistency
setTimeout(() => {
fetchItems(activeEntityFilter, activeStatusFilter);
}
}, 500);
// Clear notes
setNotes(prev => {
@@ -239,7 +251,7 @@ export function ModerationQueue() {
console.error('Error moderating content:', error);
toast({
title: "Error",
description: `Failed to ${action} content`,
description: `Failed to ${action} content: ${error.message}`,
variant: "destructive",
});
} finally {