From 25c63a7b4cdcd412b94b7ce9c11bfdcb8e9f6854 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 12 Oct 2025 20:33:10 +0000 Subject: [PATCH] feat: Extract type definitions --- src/components/moderation/ModerationQueue.tsx | 67 ++------- src/types/moderation.ts | 135 ++++++++++++++++++ 2 files changed, 150 insertions(+), 52 deletions(-) create mode 100644 src/types/moderation.ts diff --git a/src/components/moderation/ModerationQueue.tsx b/src/components/moderation/ModerationQueue.tsx index 139cac54..7cf977f8 100644 --- a/src/components/moderation/ModerationQueue.tsx +++ b/src/components/moderation/ModerationQueue.tsx @@ -33,62 +33,22 @@ import { smartMergeArray } from '@/lib/smartStateUpdate'; import { useDebounce } from '@/hooks/useDebounce'; import { QueueItem } from './QueueItem'; import { QueueSkeleton } from './QueueSkeleton'; - -interface ModerationItem { - id: string; - type: 'review' | 'content_submission'; - content: any; - created_at: string; - updated_at?: string; - user_id: string; - status: string; - submission_type?: string; - user_profile?: { - username: string; - display_name?: string; - avatar_url?: string; - }; - entity_name?: string; - park_name?: string; - reviewed_at?: string; - reviewed_by?: string; - reviewer_notes?: string; - reviewer_profile?: { - username: string; - display_name?: string; - avatar_url?: string; - }; - escalated?: boolean; - assigned_to?: string; - locked_until?: string; - _removing?: boolean; - submission_items?: Array<{ - id: string; - item_type: string; - item_data: any; - status: string; - }>; -} - -type EntityFilter = 'all' | 'reviews' | 'submissions' | 'photos'; -type StatusFilter = 'all' | 'pending' | 'partially_approved' | 'flagged' | 'approved' | 'rejected'; -type QueueTab = 'mainQueue' | 'archive'; -type SortField = 'created_at' | 'username' | 'submission_type' | 'status' | 'escalated'; -type SortDirection = 'asc' | 'desc'; - -interface SortConfig { - field: SortField; - direction: SortDirection; -} - -export interface ModerationQueueRef { - refresh: () => void; -} +import type { + ModerationItem, + EntityFilter, + StatusFilter, + QueueTab, + SortField, + SortDirection, + SortConfig, + LoadingState, + ModerationQueueRef, +} from '@/types/moderation'; export const ModerationQueue = forwardRef((props, ref) => { const isMobile = useIsMobile(); const [items, setItems] = useState([]); - const [loadingState, setLoadingState] = useState<'initial' | 'loading' | 'refreshing' | 'ready'>('initial'); + const [loadingState, setLoadingState] = useState('initial'); const [actionLoading, setActionLoading] = useState(null); const [notes, setNotes] = useState>({}); const [activeTab, setActiveTab] = useState('mainQueue'); @@ -2519,3 +2479,6 @@ export const ModerationQueue = forwardRef((props, ref) => { }); ModerationQueue.displayName = 'ModerationQueue'; + +// Re-export types for backwards compatibility +export type { ModerationQueueRef } from '@/types/moderation'; diff --git a/src/types/moderation.ts b/src/types/moderation.ts new file mode 100644 index 00000000..68a059bf --- /dev/null +++ b/src/types/moderation.ts @@ -0,0 +1,135 @@ +/** + * Moderation Queue Type Definitions + * + * This file contains all TypeScript types and interfaces used by the moderation queue system. + * Extracted from ModerationQueue.tsx to improve maintainability and reusability. + */ + +/** + * Represents a single item in the moderation queue. + * Can be either a review or a content submission. + */ +export interface ModerationItem { + /** Unique identifier for the item */ + id: string; + + /** Type of moderation item */ + type: 'review' | 'content_submission'; + + /** Raw content data (structure varies by type) */ + content: any; + + /** Timestamp when the item was created */ + created_at: string; + + /** Timestamp when the item was last updated */ + updated_at?: string; + + /** ID of the user who submitted this item */ + user_id: string; + + /** Current status of the item */ + status: string; + + /** Type of submission (e.g., 'park', 'ride', 'review') */ + submission_type?: string; + + /** Profile information of the submitting user */ + user_profile?: { + username: string; + display_name?: string; + avatar_url?: string; + }; + + /** Display name of the entity being modified */ + entity_name?: string; + + /** Display name of the park (for ride submissions) */ + park_name?: string; + + /** Timestamp when the item was reviewed */ + reviewed_at?: string; + + /** ID of the moderator who reviewed this item */ + reviewed_by?: string; + + /** Notes left by the reviewing moderator */ + reviewer_notes?: string; + + /** Profile information of the reviewing moderator */ + reviewer_profile?: { + username: string; + display_name?: string; + avatar_url?: string; + }; + + /** Whether this submission has been escalated for senior review */ + escalated?: boolean; + + /** ID of the moderator this item is assigned to */ + assigned_to?: string; + + /** Timestamp until which this item is locked by a moderator */ + locked_until?: string; + + /** Internal flag indicating item is being removed (optimistic update) */ + _removing?: boolean; + + /** Sub-items for composite submissions */ + submission_items?: Array<{ + id: string; + item_type: string; + item_data: any; + status: string; + }>; +} + +/** + * Filter options for entity types in the moderation queue + */ +export type EntityFilter = 'all' | 'reviews' | 'submissions' | 'photos'; + +/** + * Filter options for submission status in the moderation queue + */ +export type StatusFilter = 'all' | 'pending' | 'partially_approved' | 'flagged' | 'approved' | 'rejected'; + +/** + * Available tabs in the moderation interface + */ +export type QueueTab = 'mainQueue' | 'archive'; + +/** + * Fields that can be used for sorting the moderation queue + */ +export type SortField = 'created_at' | 'username' | 'submission_type' | 'status' | 'escalated'; + +/** + * Direction for sorting (ascending or descending) + */ +export type SortDirection = 'asc' | 'desc'; + +/** + * Configuration for sorting the moderation queue + */ +export interface SortConfig { + /** Field to sort by */ + field: SortField; + + /** Direction to sort */ + direction: SortDirection; +} + +/** + * Loading states for the moderation queue + */ +export type LoadingState = 'initial' | 'loading' | 'refreshing' | 'ready'; + +/** + * Ref interface for the ModerationQueue component + * Allows parent components to trigger actions imperatively + */ +export interface ModerationQueueRef { + /** Manually refresh the queue data */ + refresh: () => void; +}