import React, { useState, useEffect, useCallback } from 'react'; import { Button } from '@/components/ui/index'; import { RefreshCw } from 'lucide-react'; import { BackupJobList } from '@/components/Proxmox'; import { listProxmoxClusters, listProxmoxBackupJobs } from '@/lib/proxmoxClient'; import type { ClusterInfo } from '@/lib/domain'; import { toast } from 'sonner'; export function ProxmoxBackupPage() { const [clusters, setClusters] = useState([]); const [selectedClusterId, setSelectedClusterId] = useState(''); // eslint-disable-next-line @typescript-eslint/no-explicit-any const [jobs, setJobs] = useState([]); const [isLoading, setIsLoading] = useState(false); useEffect(() => { listProxmoxClusters() .then((cls) => { setClusters(cls); if (cls.length > 0) setSelectedClusterId(cls[0].id); }) .catch((err) => { console.error('Failed to load clusters:', err); toast.error('Failed to load clusters'); }); }, []); const loadJobs = useCallback(async (clusterId: string) => { if (!clusterId) return; setIsLoading(true); try { // Backup jobs are cluster-level, not node-level const data = await listProxmoxBackupJobs(clusterId, ''); setJobs(data); } catch (err) { console.error('Failed to load backup jobs:', err); toast.error('Failed to load backup jobs'); } finally { setIsLoading(false); } }, []); useEffect(() => { if (selectedClusterId) loadJobs(selectedClusterId); }, [selectedClusterId, loadJobs]); if (clusters.length === 0 && !isLoading) { return (

Backup Jobs

Manage Proxmox backup schedules

No Proxmox clusters configured.

Add a remote connection first.

); } return (

Backup Jobs

Manage Proxmox backup schedules

{clusters.length > 1 && ( )}
loadJobs(selectedClusterId)} />
); }