mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 20:51:13 -05:00
Fix moderation status update
This commit is contained in:
@@ -209,25 +209,37 @@ export function ModerationQueue() {
|
|||||||
updateData.reviewer_notes = moderatorNotes;
|
updateData.reviewer_notes = moderatorNotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { error } = await supabase
|
console.log('Updating item:', item.id, 'with data:', updateData);
|
||||||
|
|
||||||
|
const { error, data } = await supabase
|
||||||
.from(table)
|
.from(table)
|
||||||
.update(updateData)
|
.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({
|
toast({
|
||||||
title: `Content ${action}`,
|
title: `Content ${action}`,
|
||||||
description: `The ${item.type} has been ${action}`,
|
description: `The ${item.type} has been ${action}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove item from queue if it's no longer in the active filter
|
// Update the local state immediately
|
||||||
if (activeStatusFilter === 'pending' || activeStatusFilter === 'flagged') {
|
setItems(prev => prev.map(i =>
|
||||||
setItems(prev => prev.filter(i => i.id !== item.id));
|
i.id === item.id
|
||||||
} else {
|
? { ...i, status: action }
|
||||||
// Refresh the queue to show updated status
|
: i
|
||||||
|
));
|
||||||
|
|
||||||
|
// Also refresh the queue after a short delay to ensure consistency
|
||||||
|
setTimeout(() => {
|
||||||
fetchItems(activeEntityFilter, activeStatusFilter);
|
fetchItems(activeEntityFilter, activeStatusFilter);
|
||||||
}
|
}, 500);
|
||||||
|
|
||||||
// Clear notes
|
// Clear notes
|
||||||
setNotes(prev => {
|
setNotes(prev => {
|
||||||
@@ -239,7 +251,7 @@ export function ModerationQueue() {
|
|||||||
console.error('Error moderating content:', error);
|
console.error('Error moderating content:', error);
|
||||||
toast({
|
toast({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: `Failed to ${action} content`,
|
description: `Failed to ${action} content: ${error.message}`,
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user