import { StrictMode } from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import { RouterProvider, createRouter } from "@tanstack/react-router";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
// Import the generated route tree
import { routeTree } from "./routeTree.gen";

// Create a client
const queryClient = new QueryClient({
    defaultOptions: {
        queries: {
            staleTime: 1000 * 60 * 5,
            retry: 0,
            refetchOnWindowFocus: false,
        },
    },
});

const router = createRouter({
    routeTree,
    basepath: "/lst/app",
    defaultPendingMinMs: 500,
    context: {
        queryClient: {} as QueryClient,
        //login: () => {},
        //logout: () => {},
    },
});

// Register the router instance for type safety
declare module "@tanstack/react-router" {
    interface Register {
        router: typeof router;
    }
}

const App = () => {
    return (
        <>
            <RouterProvider router={router} context={{ queryClient }} />
        </>
    );
};

ReactDOM.createRoot(document.getElementById("root")!).render(
    <StrictMode>
        <QueryClientProvider client={queryClient}>
            <App />
        </QueryClientProvider>
    </StrictMode>
);
