import { AlertCircle, CheckCircle, Clock, Code, Download, ExternalLink, GitCommit, } from "lucide-react"; import { useCallback, useEffect, useState } from "react"; import { versionAPI } from "../../utils/api"; const VersionUpdateTab = () => { // Version checking state const [versionInfo, setVersionInfo] = useState({ currentVersion: null, latestVersion: null, isUpdateAvailable: false, checking: false, error: null, github: null, }); // Version checking functions const checkForUpdates = useCallback(async () => { setVersionInfo((prev) => ({ ...prev, checking: true, error: null })); try { const response = await versionAPI.checkUpdates(); const data = response.data; setVersionInfo({ currentVersion: data.currentVersion, latestVersion: data.latestVersion, isUpdateAvailable: data.isUpdateAvailable, last_update_check: data.last_update_check, github: data.github, checking: false, error: null, }); } catch (error) { console.error("Version check error:", error); setVersionInfo((prev) => ({ ...prev, checking: false, error: error.response?.data?.error || "Failed to check for updates", })); } }, []); // Load current version and automatically check for updates on component mount useEffect(() => { const loadAndCheckUpdates = async () => { try { // First, get current version info const response = await versionAPI.getCurrent(); const data = response.data; setVersionInfo({ currentVersion: data.version, latestVersion: data.latest_version || null, isUpdateAvailable: data.is_update_available || false, last_update_check: data.last_update_check || null, github: data.github, checking: false, error: null, }); // Then automatically trigger a fresh update check await checkForUpdates(); } catch (error) { console.error("Error loading version info:", error); setVersionInfo((prev) => ({ ...prev, error: "Failed to load version information", })); } }; loadAndCheckUpdates(); }, [checkForUpdates]); // Run when component mounts return (
Current server version and latest updates from GitHub repository. {versionInfo.checking && ( 🔄 Checking for updates... )}
GitHub Repository Information
Updates are checked automatically every 24 hours
{versionInfo.error}