"use client"; import { Component, type ErrorInfo, type ReactNode } from "react"; import { Button } from "@/components/ui/button"; type Props = { children: ReactNode; /** Optional label for support / logs */ area?: string; }; type State = { error: Error | null; }; /** * Catches render/runtime errors in the subtree and shows a recoverable Persian UI * instead of a blank screen. */ export class ErrorBoundary extends Component { state: State = { error: null }; static getDerivedStateFromError(error: Error): State { return { error }; } componentDidCatch(error: Error, info: ErrorInfo) { // Keep console for operators; avoid leaking stack into the UI. console.error(`[ErrorBoundary${this.props.area ? `:${this.props.area}` : ""}]`, error, info.componentStack); } private reset = () => { this.setState({ error: null }); }; render() { if (!this.state.error) { return this.props.children; } return (

مشکلی در نمایش این بخش پیش آمد

صفحه را یک‌بار تازه کنید. اگر ادامه داشت، کمی بعد دوباره تلاش کنید.

); } }