| 1 |
/** |
| 2 |
* Frontend Account Page Entry Point |
| 3 |
* Loads the customer account page on the frontend |
| 4 |
*/ |
| 5 |
|
| 6 |
import React from "react"; |
| 7 |
import ReactDOM from "react-dom/client"; |
| 8 |
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; |
| 9 |
import AccountPage from "./pages/AccountPage"; |
| 10 |
import { ToastProvider } from "./components/ui/toast"; |
| 11 |
import { ErrorBoundary } from "./components/ErrorBoundary"; |
| 12 |
import { __ } from "./lib/i18n"; |
| 13 |
import "./css/index.css"; |
| 14 |
|
| 15 |
// Create React Query client |
| 16 |
const queryClient = new QueryClient({ |
| 17 |
defaultOptions: { |
| 18 |
queries: { |
| 19 |
refetchOnWindowFocus: false, |
| 20 |
retry: 1, |
| 21 |
staleTime: 5 * 60 * 1000, // 5 minutes |
| 22 |
}, |
| 23 |
}, |
| 24 |
}); |
| 25 |
|
| 26 |
// Get mount point |
| 27 |
const rootElement = document.getElementById("yatra-account-page-root"); |
| 28 |
|
| 29 |
if (rootElement) { |
| 30 |
// Opt out of browser auto-translation so it never rewrites React-managed |
| 31 |
// text nodes (which otherwise causes "removeChild" reconciliation crashes). |
| 32 |
rootElement.setAttribute("translate", "no"); |
| 33 |
rootElement.classList.add("notranslate"); |
| 34 |
|
| 35 |
try { |
| 36 |
const root = ReactDOM.createRoot(rootElement); |
| 37 |
|
| 38 |
root.render( |
| 39 |
<React.StrictMode> |
| 40 |
<QueryClientProvider client={queryClient}> |
| 41 |
<ToastProvider> |
| 42 |
<ErrorBoundary> |
| 43 |
<AccountPage /> |
| 44 |
</ErrorBoundary> |
| 45 |
</ToastProvider> |
| 46 |
</QueryClientProvider> |
| 47 |
</React.StrictMode>, |
| 48 |
); |
| 49 |
} catch (error) { |
| 50 |
console.error("Error rendering account page:", error); |
| 51 |
const wrap = document.createElement("div"); |
| 52 |
wrap.style.cssText = "padding: 40px; text-align: center;"; |
| 53 |
const h2 = document.createElement("h2"); |
| 54 |
h2.textContent = __("Error loading account page", "yatra"); |
| 55 |
const p = document.createElement("p"); |
| 56 |
p.textContent = __( |
| 57 |
"Please refresh the page or contact support if the problem continues.", |
| 58 |
"yatra", |
| 59 |
); |
| 60 |
wrap.appendChild(h2); |
| 61 |
wrap.appendChild(p); |
| 62 |
rootElement.replaceChildren(wrap); |
| 63 |
} |
| 64 |
} |
| 65 |
|