import { useMemo } from "react"; import { CartesianGrid, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts"; import { formatCount } from "@/client/features/ai-search/platformLabels"; import type { BrandLookupResult } from "@/types/schemas/ai-search"; type Props = { result: BrandLookupResult; }; export function BrandLookupMentionTrendCard({ result }: Props) { const chartData = useMemo( () => result.monthlyVolume.map((entry) => ({ label: `${entry.year}-${String(entry.month).padStart(2, "0")}`, volume: entry.volume ?? 0, })), [result.monthlyVolume], ); if (chartData.length === 0) { return (
Not enough historical data yet.
); } return (
} cursor={{ stroke: "currentColor", strokeOpacity: 0.2 }} />
); } function MentionTooltip({ active, payload, label, }: { active?: boolean; payload?: Array<{ value: number }>; label?: string; }) { if (!active || !payload?.length) return null; return (

{label}

{formatCount(payload[0].value)} mentions

); }