Improve sorting controls for moderation queues

Update the `QueueSortControls` component to validate sort fields and improve type safety for sort direction toggling.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ef7037e7-a631-48a2-94d1-9a4b52d7c35a
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7cdf4e95-3f41-4180-b8e3-8ef56d032c0e/ef7037e7-a631-48a2-94d1-9a4b52d7c35a/kcnWjk6
This commit is contained in:
pac7
2025-10-13 14:43:51 +00:00
parent a6cc9be6ea
commit c9423d43c1
2 changed files with 17 additions and 2 deletions

View File

@@ -21,14 +21,25 @@ export const QueueSortControls = ({
onSortChange,
isMobile
}: QueueSortControlsProps) => {
const handleFieldChange = (field: SortField) => {
const handleFieldChange = (value: string) => {
const validFields: SortField[] = ['created_at', 'submission_type', 'status'];
if (!validFields.includes(value as SortField)) {
console.warn('⚠️ [SORT] Invalid sort field:', value);
return;
}
const field = value as SortField;
console.log('🔄 [SORT] Field change:', { from: sortConfig.field, to: field });
onSortChange({ ...sortConfig, field });
};
const handleDirectionToggle = () => {
const newDirection = sortConfig.direction === 'asc' ? 'desc' : 'asc';
console.log('🔄 [SORT] Direction toggle:', { from: sortConfig.direction, to: newDirection });
onSortChange({
...sortConfig,
direction: sortConfig.direction === 'asc' ? 'desc' : 'asc'
direction: newDirection
});
};