'use client'; import React, { useState, useEffect, useCallback } from 'react'; import Link from 'next/link'; import { useAuth } from '@/contexts/AuthContext'; import { useRouter } from 'next/navigation'; import Header from '@/components/Header'; // ─── Types ──────────────────────────────────────────────────────────────────── interface ForumThread { id: string; title: string; author_name: string; body: string; reply_count: number; view_count: number; upvotes: number; is_pinned: boolean; is_featured: boolean; is_locked: boolean; is_flagged: boolean; flag_reason: string | null; created_at: string; forum_categories: { name: string; slug: string } | null; } interface ForumReply { id: string; body: string; author_name: string; is_hidden: boolean; is_flagged: boolean; flag_reason: string | null; created_at: string; forum_threads: { id: string; title: string } | null; } type Tab = 'threads' | 'replies'; type ThreadFilter = 'all' | 'flagged' | 'ai_flagged' | 'pinned' | 'featured' | 'locked'; type ReplyFilter = 'all' | 'flagged' | 'ai_flagged' | 'hidden'; // ─── Helpers ────────────────────────────────────────────────────────────────── function timeAgo(dateStr: string): string { const diff = Date.now() - new Date(dateStr).getTime(); const mins = Math.floor(diff / 60000); if (mins < 1) return 'just now'; if (mins < 60) return `${mins}m ago`; const hrs = Math.floor(mins / 60); if (hrs < 24) return `${hrs}h ago`; return `${Math.floor(hrs / 24)}d ago`; } // ─── Flag Modal ─────────────────────────────────────────────────────────────── interface FlagModalProps { onConfirm: (reason: string) => void; onCancel: () => void; } function FlagModal({ onConfirm, onCancel }: FlagModalProps) { const [reason, setReason] = useState(''); return (

Flag Content

Provide a reason for flagging this content (optional).