mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 23:31:11 -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 => {
|
const getSortFieldLabel = (field: SortField): string => {
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case 'created_at': return 'Date Created';
|
case 'created_at': return 'Date Created';
|
||||||
case 'username': return 'Submitter';
|
|
||||||
case 'submission_type': return 'Type';
|
case 'submission_type': return 'Type';
|
||||||
case 'status': return 'Status';
|
case 'status': return 'Status';
|
||||||
case 'escalated': return 'Escalated';
|
case 'escalated': return 'Escalated';
|
||||||
@@ -58,7 +57,6 @@ export const QueueSortControls = ({
|
|||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="created_at">{getSortFieldLabel('created_at')}</SelectItem>
|
<SelectItem value="created_at">{getSortFieldLabel('created_at')}</SelectItem>
|
||||||
<SelectItem value="username">{getSortFieldLabel('username')}</SelectItem>
|
|
||||||
<SelectItem value="submission_type">{getSortFieldLabel('submission_type')}</SelectItem>
|
<SelectItem value="submission_type">{getSortFieldLabel('submission_type')}</SelectItem>
|
||||||
<SelectItem value="status">{getSortFieldLabel('status')}</SelectItem>
|
<SelectItem value="status">{getSortFieldLabel('status')}</SelectItem>
|
||||||
<SelectItem value="escalated">{getSortFieldLabel('escalated')}</SelectItem>
|
<SelectItem value="escalated">{getSortFieldLabel('escalated')}</SelectItem>
|
||||||
|
|||||||
@@ -223,14 +223,17 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
|||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Map sort fields to correct database columns
|
// Validate sort field is an actual column in content_submissions
|
||||||
const sortField =
|
const validSortFields = ['created_at', 'submission_type', 'status', 'escalated', 'submitted_at'];
|
||||||
sort.config.field === 'username' ? 'user_id' :
|
let sortField = sort.config.field;
|
||||||
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:', {
|
console.log('[Query] Sorting by:', {
|
||||||
originalField: sort.config.field,
|
field: sortField,
|
||||||
mappedField: sortField,
|
|
||||||
direction: sort.config.direction,
|
direction: sort.config.direction,
|
||||||
ascending: sort.config.direction === 'asc'
|
ascending: sort.config.direction === 'asc'
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user