'use client' import { Component, type ErrorInfo, type ReactNode } from 'react' import { useTranslations } from 'next-intl' import { createClientLogger } from '@/lib/client-logger' import { Button } from '@/components/ui/button' const log = createClientLogger('ErrorBoundary') interface Props { children: ReactNode fallback?: ReactNode } interface State { hasError: boolean error: Error | null } function ErrorFallback({ error, onRetry }: { error: Error | null; onRetry: () => void }) { const t = useTranslations('errorBoundary') const tc = useTranslations('common') return (

{t('somethingWentWrong')}

{error?.message || t('unexpectedError')}

) } export class ErrorBoundary 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: ErrorInfo) { log.error('Panel error:', error, errorInfo) } render() { if (this.state.hasError) { if (this.props.fallback) return this.props.fallback return ( this.setState({ hasError: false, error: null })} /> ) } return this.props.children } }