import { useQuery } from '@tanstack/react-query' import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, } from 'recharts' import { apiFetch } from '@/lib/http' import { LoadingSkeleton } from '@/components/common/LoadingSkeleton' interface TrendPoint { date: string; count: number } interface Response { query_count: number unique_users: number avg_response_time_ms: number trend: { data: TrendPoint[] } } async function fetchTrend(): Promise { const res = await apiFetch('/api/analytics/queries?date_range=30d') return res.json() } export function QueryTrendChart() { const { data, isLoading } = useQuery({ queryKey: ['analytics-trend'], queryFn: fetchTrend, staleTime: 300_000 }) return (

Query Volume

{isLoading ? '—' : (data?.query_count ?? 0).toLocaleString()}

Last 30 days
{isLoading ? ( ) : ( d.slice(5)} /> )}
) }