2026-06-29 07:55:47 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
|
|
|
import { AppRouter } from '@/routes';
|
|
|
|
|
import { setUnauthorizedHandler } from '@/api/client';
|
|
|
|
|
import { useAuthStore } from '@/store/authStore';
|
2026-07-23 08:42:26 +02:00
|
|
|
import { useThemeStore } from '@/store/themeStore';
|
2026-07-26 12:18:52 +02:00
|
|
|
import { ErrorBoundary } from '@/components/common/ErrorBoundary';
|
2026-06-29 07:55:47 +02:00
|
|
|
|
|
|
|
|
const queryClient = new QueryClient({
|
|
|
|
|
defaultOptions: {
|
|
|
|
|
queries: {
|
|
|
|
|
retry: 1,
|
|
|
|
|
staleTime: 5 * 60 * 1000,
|
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default function App() {
|
|
|
|
|
const { logout } = useAuthStore();
|
2026-07-23 08:42:26 +02:00
|
|
|
const loadThemeFromStorage = useThemeStore((s) => s.loadFromStorage);
|
2026-06-29 07:55:47 +02:00
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
setUnauthorizedHandler(() => {
|
|
|
|
|
logout();
|
|
|
|
|
window.location.href = '/login';
|
|
|
|
|
});
|
|
|
|
|
}, [logout]);
|
|
|
|
|
|
2026-07-23 08:42:26 +02:00
|
|
|
// Load theme from localStorage on app start
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
loadThemeFromStorage();
|
|
|
|
|
}, [loadThemeFromStorage]);
|
|
|
|
|
|
2026-06-29 07:55:47 +02:00
|
|
|
return (
|
|
|
|
|
<QueryClientProvider client={queryClient}>
|
2026-07-26 12:18:52 +02:00
|
|
|
<ErrorBoundary>
|
|
|
|
|
<AppRouter />
|
|
|
|
|
</ErrorBoundary>
|
2026-06-29 07:55:47 +02:00
|
|
|
</QueryClientProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|