"use client";
import Link from "next/link";
import { RefreshCw } from "lucide-react";
import { api, type HealthSummary } from "@/lib/api";
import { useAsync, useInterval } from "@/lib/hooks";
import { fmtCompact, fmtGB, fmtInt, fmtRelative, fmtTs } from "@/lib/format";
import { Banner, Card, ErrorState, KpiTile, PageHeader, SeverityBadge, Skeleton, StatusBadge } from "@/components/ui";
import { DataTable } from "@/components/DataTable";
import { Job } from "@/lib/api";
import { useAuth } from "@/lib/auth";
import { PublicOverview } from "@/components/PublicOverview";
export default function OverviewPage() {
const { isOwner, me } = useAuth();
const signedIn = !!me && me.mfa_passed;
return (
<>
{signedIn && }
>
);
}
function OperatorOverview({ isOwner }: { isOwner: boolean }) {
const { data, error, loading, reload } = useAsync((signal) => api.get("/health/summary", undefined, signal), []);
useInterval(reload, 60_000);
const h = data?.health;
const lake = h?.components.lake;
const jobs = data?.jobs ?? {};
const anomalies = data?.anomalies_7d ?? {};
const anomaliesTotal = Object.values(anomalies).reduce((a, b) => a + b, 0);
const primaryDs = h?.datasets?.find((d) => d.dataset_id === "market_bars.stock.1m.raw") ?? h?.datasets?.[0];
const dead = jobs.dead ?? 0;
const freeTone = lake ? (lake.free_gb < lake.hard_min_free_gb ? "crit" : lake.free_gb < lake.hard_min_free_gb * 2 ? "warn" : undefined) : undefined;
return (
Health checked {fmtRelative(h.checked_at)} · auto-refresh every 60 s> : "Lakehouse status at a glance"}
actions={
<>
{h && }
>
}
/>
FirstRate Data — private use only. Raw bars and tables may not be redistributed (no public API, CSV or tables). Derived results may be published with attribution.
{error && }
{!data && !error && }
{data && (
<>
{h && h.alerts.length > 0 && (