Update
This commit is contained in:
@@ -1,30 +1,56 @@
|
|||||||
|
import '../css/app.css';
|
||||||
|
|
||||||
import { createInertiaApp } from '@inertiajs/react';
|
import { createInertiaApp } from '@inertiajs/react';
|
||||||
import createServer from '@inertiajs/react/server';
|
|
||||||
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
|
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
|
||||||
import ReactDOMServer from 'react-dom/server';
|
import { hydrateRoot } from 'react-dom/client';
|
||||||
import { type RouteName, route } from 'ziggy-js';
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
|
|
||||||
|
import { GA4Provider } from '@/plugins/GA4Context.jsx'; // Updated import
|
||||||
|
import DetailedErrorFallback from './components/custom/detailed-error-fallback'; // Import your component
|
||||||
|
import { Toaster } from './components/ui/sonner';
|
||||||
|
import { AxiosProvider } from './plugins/AxiosContext';
|
||||||
|
import { MittProvider } from './plugins/MittContext';
|
||||||
|
|
||||||
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
||||||
|
|
||||||
createServer((page) =>
|
createInertiaApp({
|
||||||
createInertiaApp({
|
title: (title) => `${title} - ${appName}`,
|
||||||
page,
|
resolve: (name) => resolvePageComponent(`./pages/${name}.tsx`, import.meta.glob('./pages/**/*.tsx')),
|
||||||
render: ReactDOMServer.renderToString,
|
setup({ el, App, props }) {
|
||||||
title: (title) => `${title} - ${appName}`,
|
const root = hydrateRoot(el);
|
||||||
resolve: (name) => resolvePageComponent(`./pages/${name}.tsx`, import.meta.glob('./pages/**/*.tsx')),
|
|
||||||
setup: ({ App, props }) => {
|
|
||||||
/* eslint-disable */
|
|
||||||
// @ts-expect-error
|
|
||||||
global.route<RouteName> = (name, params, absolute) =>
|
|
||||||
route(name, params as any, absolute, {
|
|
||||||
// @ts-expect-error
|
|
||||||
...page.props.ziggy,
|
|
||||||
// @ts-expect-error
|
|
||||||
location: new URL(page.props.ziggy.location),
|
|
||||||
});
|
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
return <App {...props} />;
|
const app = (
|
||||||
},
|
<ErrorBoundary
|
||||||
}),
|
FallbackComponent={DetailedErrorFallback}
|
||||||
);
|
onError={(error, errorInfo) => {
|
||||||
|
// Log to console for debugging
|
||||||
|
console.error('Error caught by boundary:', error, errorInfo);
|
||||||
|
|
||||||
|
// You could also send to an error reporting service here
|
||||||
|
// e.g., Sentry, LogRocket, etc.
|
||||||
|
}}
|
||||||
|
onReset={() => {
|
||||||
|
// Optional: Clear any error state in your app
|
||||||
|
console.log('Error boundary reset');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GA4Provider>
|
||||||
|
<MittProvider>
|
||||||
|
<AxiosProvider>
|
||||||
|
<Toaster position="top-right" />
|
||||||
|
{/* <AuthDialog /> */}
|
||||||
|
<App {...props} />
|
||||||
|
</AxiosProvider>
|
||||||
|
</MittProvider>
|
||||||
|
</GA4Provider>
|
||||||
|
</ErrorBoundary>
|
||||||
|
);
|
||||||
|
|
||||||
|
root.render(app);
|
||||||
|
},
|
||||||
|
progress: {
|
||||||
|
color: '#4B5563',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Theme is now handled by useTheme hook in components
|
||||||
|
|||||||
Reference in New Issue
Block a user