"use client"; import { useRouter } from "next/navigation"; import { WifiOff, ServerCrash, Wrench, AlertCircle, RefreshCw } from "lucide-react"; import { Button } from "@/components/ui"; import { describeError } from "@/lib/use-api"; import { ApiClientError } from "@/lib/api"; import { cn } from "@/lib/utils"; /** Polished error state for connection loss, server outage and maintenance. */ export function ApiErrorState({ error, retry, className, compact }: { error: unknown; retry?: () => void; className?: string; compact?: boolean }) { const d = describeError(error); const Icon = d.kind === "network" ? WifiOff : d.kind === "maintenance" ? Wrench : d.kind === "server" ? ServerCrash : AlertCircle; return (

{d.title}

{d.description}

{retry ? ( ) : null}
); } /** Server components can't retry in place — this reloads the route from the client. */ export function ServerUnavailable({ className, compact }: { className?: string; compact?: boolean }) { const router = useRouter(); return router.refresh()} className={className} compact={compact} />; }