UNPKG

bigblocks

Version:

Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React

33 lines (32 loc) 1.7 kB
"use client"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { ExclamationTriangleIcon, InfoCircledIcon, } from "@radix-ui/react-icons"; import { BACKEND_ERRORS, ErrorType, } from "../../lib/types.js"; import { cn } from "../../lib/utils.js"; function isBackendSetupError(error) { if (typeof error === "object" && error.type === ErrorType.BACKEND_SETUP) { return true; } if (typeof error === "string") { // Check against known backend error messages from constants return Object.values(BACKEND_ERRORS).some((message) => message === error); } return false; } function getErrorMessage(error) { return typeof error === "object" ? error.message : error; } export function ErrorDisplay({ error, className = "", size = "default", }) { if (!error) return null; const isBackendError = isBackendSetupError(error); const errorMessage = getErrorMessage(error); const sizeClasses = { sm: "p-2 text-xs", default: "p-3 text-sm", lg: "p-4 text-base", }; return (_jsxs("div", { className: cn("flex items-start gap-2 rounded-md border", isBackendError ? "border-amber-200 bg-amber-50 text-amber-900" : "border-destructive/50 bg-destructive/10 text-destructive-foreground", sizeClasses[size], className), children: [isBackendError ? (_jsx(InfoCircledIcon, { className: "h-4 w-4 shrink-0 mt-0.5" })) : (_jsx(ExclamationTriangleIcon, { className: "h-4 w-4 shrink-0 mt-0.5" })), _jsxs("div", { className: "flex-1", children: [isBackendError && (_jsx("div", { className: "font-bold mb-1", children: "\u26A0\uFE0F Backend Setup Required" })), errorMessage] })] })); }