import { useQuery } from "@tanstack/react-query"; import { Spin, Typography } from "antd"; import { getAPIURL } from "../utils/url"; const { Text } = Typography; interface IInfo { version: string; debug_mode: boolean; automatic_backups: boolean; data_dir: string; backups_dir: string; db_type: string; git_commit?: string; build_date?: string; } export const Version: React.FC = () => { const infoResult = useQuery({ queryKey: ["info"], queryFn: async () => { const response = await fetch(getAPIURL() + "/info"); if (!response.ok) { throw new Error("Network response was not ok"); } return response.json(); }, }); if (infoResult.isLoading) { return ; } if (infoResult.isError) { return Unknown; } const info = infoResult.data; const commit_suffix = info.git_commit ? {` (${info.git_commit})`} : <>; return ( {info.version} {commit_suffix} ); };