"use client"; import { CrossCircledIcon } from "@radix-ui/react-icons"; import { useEffect, useRef } from "react"; import { trackPayEvent } from "../../../../analytics/track/pay.js"; import type { ThirdwebClient } from "../../../../client/client.js"; import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js"; import { iconSize } from "../../../core/design-system/index.js"; import { useBridgeError } from "../../../core/hooks/useBridgeError.js"; import { Container } from "../components/basic.js"; import { Button } from "../components/buttons.js"; import { Text } from "../components/text.js"; interface ErrorBannerProps { /** * The error to display */ error: Error; /** * Called when user wants to retry */ onRetry: () => void; /** * Called when user wants to cancel */ onCancel?: () => void; client: ThirdwebClient; } export function ErrorBanner({ error, onRetry, onCancel, client, }: ErrorBannerProps) { const theme = useCustomTheme(); const { userMessage } = useBridgeError({ error }); const hasFiredErrorEvent = useRef(false); useEffect(() => { if (hasFiredErrorEvent.current) return; hasFiredErrorEvent.current = true; trackPayEvent({ client, error: error.message, event: "ub:ui:error", }); }, [client, error.message]); return ( {/* Error Icon and Message */} Error {userMessage} {/* Action Buttons */} {onCancel && ( )} ); }