mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 00:11:13 -05:00
Fix: Implement comprehensive sort debugging and fixes
This commit is contained in:
@@ -48,6 +48,11 @@ export const QueueSortControls = ({
|
|||||||
Sort By
|
Sort By
|
||||||
</Label>
|
</Label>
|
||||||
)}
|
)}
|
||||||
|
<div className="flex items-center gap-2 text-xs text-muted-foreground mb-1">
|
||||||
|
<span>
|
||||||
|
Sorting by {getSortFieldLabel(sortConfig.field)} ({sortConfig.direction === 'asc' ? '↑ Ascending' : '↓ Descending'})
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Select
|
<Select
|
||||||
value={sortConfig.field}
|
value={sortConfig.field}
|
||||||
|
|||||||
@@ -222,12 +222,24 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
|||||||
)
|
)
|
||||||
`,
|
`,
|
||||||
)
|
)
|
||||||
.order("escalated", { ascending: false })
|
.order("escalated", { ascending: false });
|
||||||
.order(
|
|
||||||
sort.config.field === 'username' ? 'user_id' :
|
// Map sort fields to correct database columns
|
||||||
sort.config.field,
|
const sortField =
|
||||||
{ ascending: sort.config.direction === 'asc' }
|
sort.config.field === 'username' ? 'user_id' :
|
||||||
);
|
sort.config.field === 'created_at' ? 'submitted_at' :
|
||||||
|
sort.config.field;
|
||||||
|
|
||||||
|
console.log('[Query] Sorting by:', {
|
||||||
|
originalField: sort.config.field,
|
||||||
|
mappedField: sortField,
|
||||||
|
direction: sort.config.direction,
|
||||||
|
ascending: sort.config.direction === 'asc'
|
||||||
|
});
|
||||||
|
|
||||||
|
submissionsQuery = submissionsQuery.order(sortField, {
|
||||||
|
ascending: sort.config.direction === 'asc'
|
||||||
|
});
|
||||||
|
|
||||||
// Apply tab-based status filtering
|
// Apply tab-based status filtering
|
||||||
const tab = filters.activeTab;
|
const tab = filters.activeTab;
|
||||||
@@ -794,8 +806,19 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
|||||||
|
|
||||||
// Sort changes trigger refetch
|
// Sort changes trigger refetch
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!user || isMountingRef.current) return;
|
console.log('[Sort Effect] Triggered:', {
|
||||||
|
field: sort.config.field,
|
||||||
|
direction: sort.config.direction,
|
||||||
|
user: !!user,
|
||||||
|
isMounting: isMountingRef.current
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user || isMountingRef.current) {
|
||||||
|
console.log('[Sort Effect] Skipped due to guards');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[Sort Effect] Executing refetch');
|
||||||
pagination.reset();
|
pagination.reset();
|
||||||
fetchItemsRef.current?.(true);
|
fetchItemsRef.current?.(true);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
|||||||
Reference in New Issue
Block a user