'use client';
import { jsx as _jsx } from "react/jsx-runtime";
// packages/ui/src/internal/common/GlobalErrorFallback.tsx
/**
 * @fileoverview GlobalErrorFallback component
 * @description Global error boundary fallback for application-level errors
 *
 * @version 0.0.1
 * @since 0.0.1
 * @author AMBROISE PARK Consulting
 */
import { useEffect } from 'react';
import { handleError } from '@donotdev/core';
import ErrorFallback from './ErrorFallback';
/**
 * Global error boundary fallback component
 *
 * @version 0.0.1
 * @since 0.0.1
 * @author AMBROISE PARK Consulting
 */
const GlobalErrorFallback = ({ error, resetError, componentStack, eventId, }) => {
    useEffect(() => {
        // Use your existing error handling system
        handleError(error, {
            userMessage: 'A global error occurred',
            context: { component: 'GlobalErrorFallback', componentStack, eventId },
            showNotification: false, // Don't show notification since we're already showing the fallback UI
        });
    }, [error, componentStack, eventId]);
    const handleReloadPage = () => {
        resetError();
        if (typeof window !== 'undefined') {
            window.location.reload();
        }
    };
    const handleGoHome = () => {
        resetError();
        if (typeof window !== 'undefined') {
            window.location.href = '/';
        }
    };
    return (_jsx(ErrorFallback, { error: error, resetError: resetError, componentStack: componentStack, eventId: eventId, onRetry: handleReloadPage, onGoHome: handleGoHome }));
};
export default GlobalErrorFallback;
