"use client"; import { Button } from "@kandev/ui/button"; import { Spinner } from "@kandev/ui/spinner"; import { IconCheck, IconAlertTriangle } from "@tabler/icons-react"; import type { SelfUpdatePhase } from "@/hooks/domains/system/use-self-update"; type SelfUpdateProgressProps = { phase: SelfUpdatePhase; targetVersion: string | null; errorMessage: string | null; onDismiss: () => void; }; function activeText(phase: SelfUpdatePhase, target: string | null): string { const version = target ?? "the new version"; switch (phase) { case "starting": return `Starting update to ${version}…`; case "installing": return `Downloading and installing ${version}…`; case "restarting": return "Restarting Kandev — this can take up to a minute."; default: return ""; } } function ActiveRow({ phase, targetVersion, }: { phase: SelfUpdatePhase; targetVersion: string | null; }) { return (
{activeText(phase, targetVersion)}

Keep this page open. It will refresh automatically when the update finishes.

); } function DoneRow({ targetVersion }: { targetVersion: string | null }) { return (
Updated to {targetVersion ?? "the latest version"}.
); } function ErrorRow({ message, onDismiss }: { message: string | null; onDismiss: () => void }) { return (
{message ?? "The update failed."}
); } function ProgressBody({ phase, targetVersion, errorMessage, onDismiss }: SelfUpdateProgressProps) { if (phase === "done") return ; if (phase === "error") return ; return ; } export function SelfUpdateProgress(props: SelfUpdateProgressProps) { if (props.phase === "idle") return null; return (
); }