import React from "react";
import { ServerApi, ServerSystemInfo } from "../api/ServerApi";
import { AsyncWidget } from "../widgets/AsyncWidget";

export function SysInfoRoute(): React.ReactElement {
  const [info, setInfo] = React.useState<ServerSystemInfo>();

  const load = async () => {
    setInfo(await ServerApi.SystemInfo());
  };

  return (
    <AsyncWidget
      load={load}
      loadKey={1}
      build={() => <SysInfoRouteInner info={info!} />}
      errMsg="Failed to load system info"
    />
  );
}

export function SysInfoRouteInner(p: {
  info: ServerSystemInfo;
}): React.ReactElement {
  return <>todo</>;
}
