import React, { ErrorInfo, ReactNode } from 'react'; import { AlertTriangle, RefreshCw, XCircle } from 'lucide-react'; interface Props { children?: ReactNode; } interface State { hasError: boolean; error: Error | null; errorInfo: ErrorInfo | null; } export class ErrorBoundary extends React.Component { // FIX: Switched to constructor-based state initialization to resolve issues // where the TypeScript toolchain might not correctly interpret public class fields, // causing `this.props` and `this.setState` to appear unavailable. This is a more // widely compatible approach. constructor(props: Props) { super(props); this.state = { hasError: false, error: null, errorInfo: null }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error, errorInfo: null }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error("Uncaught error:", error, errorInfo); this.setState({ errorInfo }); } handleReload = () => { window.location.reload(); }; render() { if (this.state.hasError) { return (

ERRO CRÍTICO NO SISTEMA

O APLICATIVO ENCONTROU UM PROBLEMA INESPERADO

O QUE ACONTECEU?

Ocorreu uma falha durante a renderização da interface. Tente recarregar a página. Se o problema persistir, envie o log abaixo para o suporte técnico.

{this.state.error && (
Stack Trace / Log Técnico
                    {this.state.error.toString()}
                    
{this.state.errorInfo?.componentStack}
)}
); } return this.props.children; } }