54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { RouterProvider } from 'react-router-dom';
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import { TooltipProvider } from '@/components/ui/tooltip';
|
|
import { Toaster } from '@/components/ui/sonner';
|
|
import { useEffect } from 'react';
|
|
import { useAuthStore } from '@/stores/useAuthStore';
|
|
import { LoginPage } from '@/pages/LoginPage';
|
|
import { router } from './router';
|
|
import { Loader2 } from 'lucide-react';
|
|
|
|
const queryClient = new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
retry: 1,
|
|
refetchOnWindowFocus: false,
|
|
staleTime: 2 * 60 * 1000,
|
|
},
|
|
},
|
|
});
|
|
|
|
export function App() {
|
|
const { isAuthenticated, isChecking, checkAuth } = useAuthStore();
|
|
|
|
useEffect(() => {
|
|
checkAuth();
|
|
}, []);
|
|
|
|
if (isChecking) {
|
|
return (
|
|
<div className="flex min-h-screen items-center justify-center bg-background">
|
|
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!isAuthenticated) {
|
|
return <LoginPage />;
|
|
}
|
|
|
|
return (
|
|
<QueryClientProvider client={queryClient}>
|
|
<TooltipProvider>
|
|
<RouterProvider router={router} />
|
|
<Toaster
|
|
position="bottom-right"
|
|
richColors
|
|
closeButton
|
|
duration={3000}
|
|
/>
|
|
</TooltipProvider>
|
|
</QueryClientProvider>
|
|
);
|
|
}
|