mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 08:11:12 -05:00
feat: Remove all sorting functionality
This commit is contained in:
@@ -12,8 +12,7 @@ export type { CachedProfile } from './useProfileCache';
|
||||
export { useModerationFilters } from './useModerationFilters';
|
||||
export type { ModerationFilters, ModerationFiltersConfig } from './useModerationFilters';
|
||||
|
||||
export { useModerationSort } from './useModerationSort';
|
||||
export type { ModerationSort, ModerationSortConfig } from './useModerationSort';
|
||||
// Removed - sorting functionality deleted
|
||||
|
||||
export { usePagination } from './usePagination';
|
||||
export type { PaginationState, PaginationConfig } from './usePagination';
|
||||
|
||||
@@ -6,13 +6,12 @@ import {
|
||||
useEntityCache,
|
||||
useProfileCache,
|
||||
useModerationFilters,
|
||||
useModerationSort,
|
||||
usePagination,
|
||||
useRealtimeSubscriptions,
|
||||
} from "./index";
|
||||
import { useModerationQueue } from "@/hooks/useModerationQueue";
|
||||
import { smartMergeArray } from "@/lib/smartStateUpdate";
|
||||
import type { ModerationItem, EntityFilter, StatusFilter, LoadingState, SortConfig } from "@/types/moderation";
|
||||
import type { ModerationItem, EntityFilter, StatusFilter, LoadingState } from "@/types/moderation";
|
||||
|
||||
/**
|
||||
* Configuration for useModerationQueueManager
|
||||
@@ -44,7 +43,6 @@ export interface ModerationQueueManager {
|
||||
// Sub-hooks (exposed for granular control)
|
||||
filters: ReturnType<typeof useModerationFilters>;
|
||||
pagination: ReturnType<typeof usePagination>;
|
||||
sort: ReturnType<typeof useModerationSort>;
|
||||
queue: ReturnType<typeof useModerationQueue>;
|
||||
|
||||
// Realtime
|
||||
@@ -99,11 +97,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
},
|
||||
});
|
||||
|
||||
const sort = useModerationSort({
|
||||
initialConfig: { field: "created_at", direction: "asc" },
|
||||
persist: true,
|
||||
storageKey: "moderationQueue_sortConfig",
|
||||
});
|
||||
// Removed - sorting functionality deleted
|
||||
|
||||
const queue = useModerationQueue();
|
||||
const entityCache = useEntityCache();
|
||||
@@ -221,9 +215,7 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
status
|
||||
)
|
||||
`,
|
||||
)
|
||||
.order("escalated", { ascending: false })
|
||||
.order("created_at", { ascending: true });
|
||||
);
|
||||
|
||||
// Apply tab-based status filtering
|
||||
const tab = filters.activeTab;
|
||||
@@ -929,7 +921,6 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
actionLoading,
|
||||
filters,
|
||||
pagination,
|
||||
sort,
|
||||
queue,
|
||||
newItemsCount,
|
||||
pendingNewItems,
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
/**
|
||||
* Moderation Queue Sort Hook
|
||||
*
|
||||
* Manages sort configuration for the moderation queue with persistence.
|
||||
*/
|
||||
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import type { SortConfig, SortField, SortDirection } from '@/types/moderation';
|
||||
import {
|
||||
getDefaultSortConfig,
|
||||
loadSortConfig,
|
||||
saveSortConfig,
|
||||
toggleSortDirection as toggleDirection,
|
||||
isDefaultSortConfig,
|
||||
} from '@/lib/moderation/sorting';
|
||||
|
||||
export interface ModerationSortConfig {
|
||||
/** Initial sort configuration */
|
||||
initialConfig?: SortConfig;
|
||||
|
||||
/** Whether to persist sort config */
|
||||
persist?: boolean;
|
||||
|
||||
/** localStorage key for persistence */
|
||||
storageKey?: string;
|
||||
|
||||
/** Callback when sort config changes */
|
||||
onChange?: (config: SortConfig) => void;
|
||||
}
|
||||
|
||||
export interface ModerationSort {
|
||||
/** Current sort configuration */
|
||||
config: SortConfig;
|
||||
|
||||
/** Sort field */
|
||||
field: SortField;
|
||||
|
||||
/** Sort direction */
|
||||
direction: SortDirection;
|
||||
|
||||
/** Set sort field */
|
||||
setField: (field: SortField) => void;
|
||||
|
||||
/** Set sort direction */
|
||||
setDirection: (direction: SortDirection) => void;
|
||||
|
||||
/** Toggle sort direction */
|
||||
toggleDirection: () => void;
|
||||
|
||||
/** Set both field and direction */
|
||||
setConfig: (config: SortConfig) => void;
|
||||
|
||||
/** Reset to default */
|
||||
reset: () => void;
|
||||
|
||||
/** Check if using default config */
|
||||
isDefault: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for managing moderation queue sort configuration
|
||||
*
|
||||
* @param config - Configuration options
|
||||
* @returns Sort state and actions
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* const sort = useModerationSort({
|
||||
* persist: true,
|
||||
* onChange: (config) => fetchItems(config)
|
||||
* });
|
||||
*
|
||||
* // Use in component
|
||||
* <Select value={sort.field} onValueChange={sort.setField}>
|
||||
* <SelectItem value="created_at">Date</SelectItem>
|
||||
* <SelectItem value="username">User</SelectItem>
|
||||
* </Select>
|
||||
* ```
|
||||
*/
|
||||
export function useModerationSort(config: ModerationSortConfig = {}): ModerationSort {
|
||||
const {
|
||||
initialConfig,
|
||||
persist = true,
|
||||
storageKey = 'moderationQueue_sortConfig',
|
||||
onChange,
|
||||
} = config;
|
||||
|
||||
// Load persisted or use initial/default config
|
||||
const [sortConfig, setSortConfig] = useState<SortConfig>(() => {
|
||||
if (initialConfig) return initialConfig;
|
||||
if (persist) return loadSortConfig(storageKey);
|
||||
return getDefaultSortConfig();
|
||||
});
|
||||
|
||||
// Persist changes
|
||||
useEffect(() => {
|
||||
if (persist) {
|
||||
saveSortConfig(sortConfig, storageKey);
|
||||
}
|
||||
onChange?.(sortConfig);
|
||||
}, [sortConfig, persist, storageKey, onChange]);
|
||||
|
||||
// Set sort field (keep direction)
|
||||
const setField = useCallback((field: SortField) => {
|
||||
setSortConfig((prev) => ({ ...prev, field }));
|
||||
}, []);
|
||||
|
||||
// Set sort direction (keep field)
|
||||
const setDirection = useCallback((direction: SortDirection) => {
|
||||
setSortConfig((prev) => ({ ...prev, direction }));
|
||||
}, []);
|
||||
|
||||
// Toggle sort direction
|
||||
const toggleSortDirection = useCallback(() => {
|
||||
setSortConfig((prev) => ({
|
||||
...prev,
|
||||
direction: toggleDirection(prev.direction),
|
||||
}));
|
||||
}, []);
|
||||
|
||||
// Set entire config
|
||||
const setConfig = useCallback((newConfig: SortConfig) => {
|
||||
setSortConfig(newConfig);
|
||||
}, []);
|
||||
|
||||
// Reset to default
|
||||
const reset = useCallback(() => {
|
||||
setSortConfig(getDefaultSortConfig());
|
||||
}, []);
|
||||
|
||||
// Check if using default config
|
||||
const isDefault = isDefaultSortConfig(sortConfig);
|
||||
|
||||
return {
|
||||
config: sortConfig,
|
||||
field: sortConfig.field,
|
||||
direction: sortConfig.direction,
|
||||
setField,
|
||||
setDirection,
|
||||
toggleDirection: toggleSortDirection,
|
||||
setConfig,
|
||||
reset,
|
||||
isDefault,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user