proper use of react-openapi for resource api calls

This commit is contained in:
2026-04-25 12:13:28 +05:30
parent 5acbb7ccdd
commit 71afc157ff
13 changed files with 191 additions and 222 deletions

View File

@@ -12,7 +12,7 @@ import {
} from "@mui/material";
import Home from './Home';
import Dashboard from './Dashboard';
import { Admin, initializeApiClients } from '../react-openapi';
import { Admin, AppProvider } from '../react-openapi';
import { configuration, profileConfiguration } from './openapi-config';
import { Buffer } from 'buffer';
import process from 'process';
@@ -21,30 +21,14 @@ import Header from './Header';
import Footer from './Footer';
import AppTheme from './AppTheme';
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
window.Buffer = Buffer;
window.process = process;
const rootElement = document.getElementById('root');
const root = createRoot(rootElement);
const API_BASE = import.meta.env.VITE_API_BASE_URL;
const AUTH_BASE = import.meta.env.VITE_AUTH_BASE_URL;
// Initialize global API clients so all components across khata-ui have generic API access
initializeApiClients(API_BASE, AUTH_BASE);
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 5 * 60 * 1000,
retry: 1,
refetchOnWindowFocus: false,
},
},
});
const routerMapping = [
{ path: "/", component: Home, headerTitle: "Home" },
{ path: "/home", component: Home, headerTitle: "Home" },
@@ -53,7 +37,7 @@ const routerMapping = [
];
root.render(
<QueryClientProvider client={queryClient}>
<AppProvider resourceOverrides={configuration} profileConfig={profileConfiguration}>
<BrowserRouter>
<AuthProvider authBaseUrl={AUTH_BASE}>
<AppTheme>
@@ -70,7 +54,7 @@ root.render(
path={path}
element={
path.startsWith("/admin") ? (
<Component basePath="/admin" resourceOverrides={configuration} profileConfig={profileConfiguration} />
<Component basePath="/admin" />
) : (
<Component />
)
@@ -84,5 +68,5 @@ root.render(
</AppTheme>
</AuthProvider>
</BrowserRouter>
</QueryClientProvider>
</AppProvider>
);