"use client"; import { Flame, Heart, SmilePlus } from "lucide-react"; import { EmptyState, LoadingSkeleton } from "@/components/shared"; import { Badge } from "@/components/ui/badge"; import { Card } from "@/components/ui/card"; import { useTopReactions, useTopReactors } from "@/hooks"; import { renderMessageContent } from "@/lib/format"; import { cn } from "@/lib/utils"; function formatReactionTime(ts: number | null): string { if (!ts) return ""; const diff = Date.now() - ts; const hours = Math.floor(diff / 3600000); if (hours < 1) return "baru saja"; if (hours < 24) return `${hours} jam lalu`; const days = Math.floor(hours / 24); return `${days} hari lalu`; } export function ReactionsSection() { const { data: reactions, isLoading: reactionsLoading } = useTopReactions(); const { data: reactors, isLoading: reactorsLoading } = useTopReactors(); return (

Top pesan paling di-reaksi

{reactionsLoading ? ( ) : !reactions || reactions.length === 0 ? ( ) : (
{reactions.map((r, i) => ( {i + 1}
{r.top_emojis.map((e) => ( {e.emoji} ))} {r.top_emojis.length === 0 && ( )}

{renderMessageContent(r.content, undefined) || "(tanpa teks)"}

{r.username ?? "unknown"} · # {r.channel_name ?? r.channel_id?.slice(0, 8)} ·{" "} {formatReactionTime(r.created_at)}

{r.reaction_count}
))}
)}

Top reaktor — paling sering ngasih reaksi

{reactorsLoading ? ( ) : !reactors || reactors.length === 0 ? ( ) : (
{reactors.map((r, i) => ( {i + 1}

{r.username}

{r.messages_reacted} pesan di-reaksi · {r.emojis_used} emoji unik · {r.adds_count} total reaksi

{r.net_count}
))}
)}
); } export default ReactionsSection;