import { AlertCircleIcon, CheckIcon, ClockIcon } from "lucide-react"; import { useState } from "react"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Spinner } from "@/components/ui/spinner"; import type { AutosaveState } from "@/hooks/use-autosave"; export function AutosaveStatus({ state, issues = [], onSave, conflictVersion, canOverwrite = false, onReloadLatest, onOverwrite }: { state: AutosaveState; issues?: readonly string[]; onSave?: () => void; conflictVersion?: number | null; canOverwrite?: boolean; onReloadLatest?: () => void; onOverwrite?: () => void }) { const [showIssues, setShowIssues] = useState(false); if (state === "saving") return Saving…; if (state === "unsaved") return Waiting to save…; if (state === "incomplete") return
{showIssues ? : null}
; if (state === "conflict") return ; if (state === "error") return
Autosave failed{onSave ? : null}
; return Saved; }