mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 15:51:12 -05:00
Fix moderation status update
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user