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