'use client'; import { useQuery } from '@tanstack/react-query'; import { LayoutDashboard, RefreshCw } from 'lucide-react'; import { useTranslations } from 'next-intl'; import { EmptyStateWithBorder } from '@/components/layout/empty'; import { ErrorInline } from '@/components/layout/error'; import { LoadingStateWithBorder } from '@/components/layout/loading'; import { Button } from '@/components/ui/button'; import { DashboardService } from '@/lib/services/openflare'; import { formatDateTime } from '@/lib/utils'; import { SourceDistributionChart, StatusCodeDistributionChart, TopDomainChart, } from './components/dashboard/distribution-rank-charts'; import { NodeHealthTable } from './components/dashboard/node-health-table'; import { TrafficCapacityTrendChart } from './components/dashboard/traffic-capacity-trend-chart'; import { TrafficTrendChart } from './components/dashboard/traffic-trend-chart'; import { WorldStage } from './components/dashboard/world-stage'; import { getErrorMessage } from './nodes/components/node-utils'; const dashboardQueryKey = ['openflare', 'dashboard', 'overview']; export default function OpenFlareDashboardPage() { const t = useTranslations('dashboard'); const overviewQuery = useQuery({ queryKey: dashboardQueryKey, queryFn: () => DashboardService.getOverview(), refetchInterval: 60_000, }); const overview = overviewQuery.data; return (

{t('title')}

{overview?.generated_at ? ( {t('generatedAt', { time: formatDateTime(overview.generated_at) })} ) : null}
{overviewQuery.isLoading ? ( ) : overviewQuery.isError ? ( overviewQuery.refetch()} /> ) : !overview ? ( ) : ( <>
)}
); }