mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 01:11:13 -05:00
Fix: Remove invalid sort options and validate sort fields
This commit is contained in:
@@ -15,7 +15,6 @@ interface QueueSortControlsProps {
|
||||
const getSortFieldLabel = (field: SortField): string => {
|
||||
switch (field) {
|
||||
case 'created_at': return 'Date Created';
|
||||
case 'username': return 'Submitter';
|
||||
case 'submission_type': return 'Type';
|
||||
case 'status': return 'Status';
|
||||
case 'escalated': return 'Escalated';
|
||||
@@ -58,7 +57,6 @@ export const QueueSortControls = ({
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="created_at">{getSortFieldLabel('created_at')}</SelectItem>
|
||||
<SelectItem value="username">{getSortFieldLabel('username')}</SelectItem>
|
||||
<SelectItem value="submission_type">{getSortFieldLabel('submission_type')}</SelectItem>
|
||||
<SelectItem value="status">{getSortFieldLabel('status')}</SelectItem>
|
||||
<SelectItem value="escalated">{getSortFieldLabel('escalated')}</SelectItem>
|
||||
|
||||
@@ -223,14 +223,17 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
`,
|
||||
);
|
||||
|
||||
// Map sort fields to correct database columns
|
||||
const sortField =
|
||||
sort.config.field === 'username' ? 'user_id' :
|
||||
sort.config.field;
|
||||
// Validate sort field is an actual column in content_submissions
|
||||
const validSortFields = ['created_at', 'submission_type', 'status', 'escalated', 'submitted_at'];
|
||||
let sortField = sort.config.field;
|
||||
|
||||
if (!validSortFields.includes(sortField)) {
|
||||
console.warn('[Query] Invalid sort field:', sortField, '- falling back to created_at');
|
||||
sortField = 'created_at';
|
||||
}
|
||||
|
||||
console.log('[Query] Sorting by:', {
|
||||
originalField: sort.config.field,
|
||||
mappedField: sortField,
|
||||
field: sortField,
|
||||
direction: sort.config.direction,
|
||||
ascending: sort.config.direction === 'asc'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user