"use client"; import { Flame, Heart, SmilePlus } from "lucide-react"; import { Avatar } from "@/components/primitives/avatar"; import { Badge } from "@/components/primitives/badge"; import { EmptyState, LoadingSkeleton } from "@/components/shared"; import { useTopReactions, useTopReactors } from "@/hooks"; export interface ReactionsSectionProps { initialReactions?: Awaited>["data"]; } export function ReactionsSection() { const { data: reactions, isLoading: reactionsLoading } = useTopReactions(); const { data: reactors, isLoading: reactorsLoading } = useTopReactors(); if (reactionsLoading || reactorsLoading) return ; const topReactions = (reactions ?? []).slice(0, 6); const topReactors = (reactors ?? []).slice(0, 6); return (

Top reactions

{topReactions.length === 0 ? ( ) : (
{topReactions .flatMap((m) => m.top_emojis.map((e) => ({ emoji: e.emoji, count: e.count })), ) .reduce<{ emoji: string; count: number }[]>((acc, cur) => { const found = acc.find((x) => x.emoji === cur.emoji); if (found) found.count += cur.count; else acc.push(cur); return acc; }, []) .sort((a, b) => b.count - a.count) .slice(0, 8) .map((r) => ( {r.emoji} {r.count} ))}
)}

Top reactors

{topReactors.length === 0 ? ( ) : (
{topReactors.map((r) => (
{r.username} +{r.net_count}
))}
)}
); }