import { Alert, AlertDescription } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Skeleton } from "@/components/ui/skeleton"; import { SectionCard } from "../components/SectionCard"; import { useWidgetData } from "../hooks/useWidgets"; import type { BackupDashboardSummary } from "../types/backups"; import type { WidgetInstance } from "../types"; interface Props { widget: WidgetInstance; refreshIntervalMs: number; description?: string; } export function BackupsWidget({ widget, refreshIntervalMs, description, }: Props) { const { data, isLoading } = useWidgetData(widget.id, refreshIntervalMs); const summary = data?.data as BackupDashboardSummary | undefined; return ( {isLoading && !data ? (
) : data?.error ? ( {data.error} ) : summary ? (
{summary.total_jobs}
Jobs
{summary.success_rate_24h}%
24h Success
{summary.active_alerts > 0 ? ( {summary.active_alerts} ) : ( 0 )}
Alerts
{summary.last_failed_at ? (
Last failed:{" "} {new Date(summary.last_failed_at * 1000).toLocaleString()}
) : null}
) : null}
); }