import React from 'react'; export class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false, error: null, showDetails: false }; } static getDerivedStateFromError(error) { return { hasError: true, error }; } componentDidCatch(error, errorInfo) { console.error("Uncaught Error caught by ErrorBoundary:", error, errorInfo); // If it's a chunk loading error (common after new deployments or SPA lazy route updates), auto-reload page once const isChunkError = error && ( error.name === 'ChunkLoadError' || error.message?.includes('dynamically imported module') || error.message?.includes('Importing a module script failed') || error.message?.includes('Failed to fetch dynamically imported module') || error.message?.includes('Failed to load module script') ); if (isChunkError) { const hasReloaded = sessionStorage.getItem('chunk_reload_retry'); if (!hasReloaded) { sessionStorage.setItem('chunk_reload_retry', 'true'); window.location.reload(); } } } componentDidMount() { sessionStorage.removeItem('chunk_reload_retry'); window.addEventListener('popstate', this.handlePopState); } componentWillUnmount() { window.removeEventListener('popstate', this.handlePopState); } handlePopState = () => { if (this.state.hasError) { this.setState({ hasError: false, error: null, showDetails: false }); } }; render() { if (this.state.hasError) { return (
{/* Warning Icon Badge */}
warning

Something Went Wrong

Sorry, due to a temporary technical issue or standard network update, this page could not be displayed properly. Please refresh the page or contact our support team.

{/* Optional Collapsible Technical Details */} {this.state.error?.message && (
{this.state.showDetails && (
Error: {this.state.error.toString()}
)}
)} {/* Action Buttons */}
support_agent Contact Support Team
); } return this.props.children; } }