import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { api, type HetznerForServer } from "../api/client"; import TimeAgo from "./TimeAgo"; import { ForecastText, StatusBadge, TrafficBar } from "../pages/Hetzner"; import { t } from "../i18n"; /** On a server's page: the Hetzner Cloud server it is (matched by address, else by name), when there is one. Nothing is shown for a server that is not at Hetzner. */ export default function HetznerServerCard({ serverId }: { serverId: number }) { const [match, setMatch] = useState(null); useEffect(() => { let live = true; api.hetzner .forServer(serverId) .then((r) => live && setMatch(r.match)) .catch(() => live && setMatch(null)); return () => { live = false; }; }, [serverId]); if (!match) return null; const s = match.server; return (

Hetzner Cloud

{match.integrationName}
{match.problems.length > 0 && (
    {match.problems.map((p) => (
  • {p.message}
  • ))}
)}
{t("Status")}
{s.rescueEnabled && rescue on}
{t("Type and place")}
{s.type ?? "—"} · {s.location ?? "?"}
{t("Backups")}
{s.backupWindow ? (match.newestBackup ? <>newest : "on, none made yet") : "off"} {match.snapshots > 0 && · {match.snapshots} snapshot{match.snapshots === 1 ? "" : "s"}}
{t("Traffic this month")}
{match.fresh ? <>read : "Hetzner could not be read lately — this is how it was"}
); }