import React, { Component, ReactNode } from "react"; import { Box, Button, Typography, Paper, Container } from "@mui/material"; import { RefreshCw, Home, AlertTriangle } from "lucide-react"; interface Props { children: ReactNode; } interface State { hasError: boolean; error: Error | null; } export class GlobalErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false, error: null, }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error, }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { console.error("❌ GlobalErrorBoundary: Критическая ошибка приложения", { error: error.message, stack: error.stack, componentStack: errorInfo.componentStack, }); } handleReset = () => { this.setState({ hasError: false, error: null, }); window.location.reload(); }; handleGoHome = () => { this.setState({ hasError: false, error: null, }); window.location.href = "/"; }; render() { if (this.state.hasError) { return ( Упс! Что-то пошло не так Приложение столкнулось с неожиданной ошибкой. Попробуйте перезагрузить страницу или вернуться на главную. {this.state.error?.message && ( Информация об ошибке: {this.state.error.message} )} ); } return this.props.children; } }