import { useState } from "react"; import { Button } from "~/components/ui/button"; import { describePreviewError } from "./errorCodeMessages"; interface Props { url: string; /** Chromium net error code, e.g. -105. */ code: number; /** Stringified Chromium error, e.g. "ERR_NAME_NOT_RESOLVED". */ description: string; onReload: () => void; } /** Theme-aware tailwind port of Chromium's "This site can't be reached" page. */ export function PreviewUnreachable({ url, code, description, onReload }: Props) { const [showDetails, setShowDetails] = useState(false); const host = safeHost(url) ?? url; const friendly = describePreviewError(description); const errorLabel = description.length > 0 ? description : `ERR_${Math.abs(code) || "FAILED"}`; return (
{host}: {friendly}.
{showDetails ? (Try: