| 1 |
import React from "react"; |
| 2 |
import ReactDOM from "react-dom/client"; |
| 3 |
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; |
| 4 |
import App from "./App"; |
| 5 |
import { ToastProvider } from "./components/ui/toast"; |
| 6 |
import "./css/index.css"; |
| 7 |
|
| 8 |
// Create React Query client with proper configuration |
| 9 |
let queryClient: QueryClient; |
| 10 |
|
| 11 |
try { |
| 12 |
queryClient = new QueryClient({ |
| 13 |
defaultOptions: { |
| 14 |
queries: { |
| 15 |
refetchOnWindowFocus: false, |
| 16 |
retry: 1, |
| 17 |
staleTime: 5 * 60 * 1000, // 5 minutes |
| 18 |
}, |
| 19 |
}, |
| 20 |
}); |
| 21 |
} catch (error) { |
| 22 |
console.error("Error initializing QueryClient:", error); |
| 23 |
// Fallback: create with minimal config |
| 24 |
queryClient = new QueryClient(); |
| 25 |
} |
| 26 |
|
| 27 |
// Get mount point |
| 28 |
const rootElement = document.getElementById("yatra-app-root"); |
| 29 |
|
| 30 |
if (rootElement) { |
| 31 |
try { |
| 32 |
const root = ReactDOM.createRoot(rootElement); |
| 33 |
|
| 34 |
root.render( |
| 35 |
<React.StrictMode> |
| 36 |
<QueryClientProvider client={queryClient}> |
| 37 |
<ToastProvider> |
| 38 |
<App /> |
| 39 |
</ToastProvider> |
| 40 |
</QueryClientProvider> |
| 41 |
</React.StrictMode>, |
| 42 |
); |
| 43 |
} catch (error) { |
| 44 |
console.error("Error rendering React app:", error); |
| 45 |
rootElement.innerHTML = |
| 46 |
'<div style="padding: 40px; text-align: center;"><h2>Error loading Yatra Admin</h2><p>Please refresh the page or contact support.</p></div>'; |
| 47 |
} |
| 48 |
} |
| 49 |
|