"use client"; import { useState } from "react"; import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid, Legend, } from "recharts"; interface Series { date: string; count: number; } interface TopRow { label: string; count: number; } export default function AnalyticsCharts({ impSeries, clkSeries, impSeriesBot, clkSeriesBot, topPages, topReferrers, totals, }: { impSeries: Series[]; clkSeries: Series[]; impSeriesBot: Series[]; clkSeriesBot: Series[]; topPages: TopRow[]; topReferrers: TopRow[]; totals: { impHuman: number; impBot: number; clkHuman: number; clkBot: number }; }) { const [includeBots, setIncludeBots] = useState(false); const imp = includeBots ? impSeriesBot : impSeries; const clk = includeBots ? clkSeriesBot : clkSeries; const totImp = includeBots ? totals.impHuman + totals.impBot : totals.impHuman; const totClk = includeBots ? totals.clkHuman + totals.clkBot : totals.clkHuman; const ctr = totImp ? ((totClk / totImp) * 100).toFixed(2) + "%" : "—"; return ( <>
setIncludeBots(e.target.checked)} className="rounded" />
); } function Tile({ label, value, small }: { label: string; value: string; small?: boolean }) { return (
{label}
{value}
); } function ChartCard({ title, data, stroke }: { title: string; data: Series[]; stroke: string }) { return (

{title}

d.slice(5)} />
); } function TopListCard({ title, rows }: { title: string; rows: TopRow[] }) { return (

{title}

{rows.length === 0 ? (

No data yet.

) : ( {rows.map((r) => ( ))}
{r.label} {r.count.toLocaleString()}
)}
); }