"use client"; /** * `` — compact at-a-glance system snapshot for the * `/admin` overview landing page. * * The full breakdown lives in `` at * `/admin/system-status`; this component only surfaces the handful of * facts an admin wants on the overview screen: app version, database * up/down, worker running, image build SHA + timestamp, and the * server-process start time. Same `useSystemStatus()` data source so we * don't re-fetch. */ import { Clock, Cog, Database, GitCommit, Loader2, Server, Tag, } from "lucide-react"; import { useQuery } from "@tanstack/react-query"; import { formatDateTime } from "@/lib/format"; import { useTranslations } from "@/lib/i18n/context"; import { StatusItem, useSystemStatus } from "./_shared"; interface VersionResponse { version: string; buildSha: string | null; builtAt: string | null; } function useVersion() { return useQuery({ queryKey: ["public", "version"], queryFn: async () => { const res = await fetch("/api/version"); if (!res.ok) throw new Error("Failed to load version"); return (await res.json()).data as VersionResponse; }, staleTime: 5 * 60_000, }); } export function SystemStatusSummary() { const { t } = useTranslations(); const { data: status, isError } = useSystemStatus(); const { data: version } = useVersion(); return (
{status ? (
{(version?.buildSha ?? status.gitCommit) && ( )} {version?.builtAt && ( )}
) : isError ? (
{t("admin.overview.snapshotLoadError")}
) : (
)}
); }