import React from "react";
import SystemVersionComponent from "./SystemVersionComponent";
import { endpoints } from "../../../utils/api";
import { useSWR, fetcher } from "units/swr";
import { blip } from "utils";
import { dtos } from "types";

const SystemVersionContainer: React.FC = () => {
  const { data, isLoading } = useSWR<dtos.SystemVersion, Error>(endpoints.system.version, fetcher, {
    revalidateOnFocus: false,
    onError: err => blip.error(err.message)
  });

  if (isLoading || !data) return null;
  return <SystemVersionComponent data={data} />;
};

export default SystemVersionContainer;
