'use client'; import React, { useState, useEffect, useRef, useCallback } from 'react'; import Link from 'next/link'; import { useParams } from 'next/navigation'; import Header from '@/components/Header'; import Footer from '@/components/Footer'; import { createClient } from '@/lib/supabase/client'; interface ForumThread { id: string; title: string; body: string; author_name: string; status: string; reply_count: number; view_count: number; upvotes: number; downvotes: number; vote_score: number; created_at: string; forum_categories: { id: string; name: string; slug: string }; } interface ForumReply { id: string; body: string; author_name: string; is_ai_response: boolean; upvotes: number; downvotes: number; vote_score: number; created_at: string; } function timeAgo(dateStr: string): string { const diff = Date.now() - new Date(dateStr).getTime(); const mins = Math.floor(diff / 60000); if (mins < 2) return 'just now'; if (mins < 60) return `${mins}m ago`; const hrs = Math.floor(mins / 60); if (hrs < 24) return `${hrs}h ago`; const days = Math.floor(hrs / 24); if (days < 30) return `${days}d ago`; return new Date(dateStr).toLocaleDateString(); } function Avatar({ name, isAI }: { name: string; isAI: boolean }) { if (isAI) { return (
{thread.body}
{reply.body}
Ask the AI assistant a question related to this thread. Responses are generated by AI and should be verified for critical decisions.
{aiError && ({aiError}
)}