import Button from '@/components/ui/Button.tsx'; import IconWrapper from '@/components/ui/IconWrapper.tsx'; import { XCircle } from 'lucide-react'; import { Component, ErrorInfo, ReactNode } from 'react'; interface Props { children?: ReactNode; } interface State { hasError: boolean; error?: Error; } class ErrorBoundary extends Component { // FIX: Replaced constructor with a class property for state initialization. This is a more modern and robust approach in class components and resolves the reported errors regarding `this.state` and `this.props` not being available. state: State = { hasError: false, error: undefined, }; static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { console.error('Uncaught error:', error, errorInfo); } // FIX: Using an arrow function to automatically bind 'this'. handleRefresh = () => { window.location.reload(); }; render() { if (this.state.hasError) { return (

Something went wrong

We're sorry for the inconvenience. Please try refreshing the page.

            {this.state.error?.message || 'An unknown error occurred'}
          
); } return this.props.children; } } export default ErrorBoundary;