From 5c7d36403fbb00b64a0297b73f5b431c3c80079e Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Sat, 4 Apr 2026 13:00:02 +0530 Subject: [PATCH] minor fixes --- react-openapi/Admin.tsx | 25 ++++++++++--------------- react-openapi/api/client.ts | 2 +- react-openapi/utils/openapi_loader.ts | 2 +- src/main.jsx | 19 ++++++++++++------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/react-openapi/Admin.tsx b/react-openapi/Admin.tsx index 1029f2b..91ee8fe 100644 --- a/react-openapi/Admin.tsx +++ b/react-openapi/Admin.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { AuthProvider, useAuth, AuthPage } from "../react-auth/src"; +import { useAuth, AuthPage } from "../react-auth"; import { UploadProvider } from "./providers/UploadProvider"; import AdminLayout from "./components/AdminLayout"; import ResourceView from "./components/ResourceView"; @@ -10,7 +10,6 @@ import { AppConfig } from "./types/config"; import { Box, Typography, Paper, CircularProgress } from "@mui/material"; import AppTheme from "./shared-theme/AppTheme"; import { - BrowserRouter, Routes, Route, useNavigate, @@ -23,7 +22,7 @@ const queryClient = new QueryClient(); // Create a context for the app config export const ConfigContext = React.createContext(null); -function Dashboard() { +function Dashboard({ basePath }: { basePath: string }) { const config = React.useContext(ConfigContext); const navigate = useNavigate(); return ( @@ -53,7 +52,7 @@ function Dashboard() { transition: 'transform 0.2s', '&:hover': { transform: 'translateY(-4px)', boxShadow: 4 } }} - onClick={() => navigate(`/${res.name}`)} + onClick={() => navigate(`${basePath}/${res.name}`)} > {res.pluralLabel} Manage {res.pluralLabel.toLowerCase()} @@ -66,7 +65,7 @@ function Dashboard() { import ProfileView from "./components/ProfileView"; -function AdminApp() { +function AdminApp({ basePath }: { basePath: string }) { const { currentUser, login, logout, loading, error } = useAuth(); const config = React.useContext(ConfigContext); const navigate = useNavigate(); @@ -90,11 +89,11 @@ function AdminApp() { navigate(`/${name}`)} + onSelectResource={(name) => navigate(`${basePath}/${name}`)} resources={config?.resources || []} > - } /> + } /> } /> } /> } /> @@ -115,7 +114,7 @@ function ResourceRouteWrapper() { return ; } -export default function Admin() { +export default function Admin({ basePath = "/admin" }: { basePath?: string }) { const [config, setConfig] = React.useState(null); React.useEffect(() => { @@ -146,13 +145,9 @@ export default function Admin() { - - - - - - - + + + diff --git a/react-openapi/api/client.ts b/react-openapi/api/client.ts index d2905f9..a7f8aef 100644 --- a/react-openapi/api/client.ts +++ b/react-openapi/api/client.ts @@ -1,5 +1,5 @@ import axios, { AxiosInstance } from "axios"; -import { createApiClient } from "../../auth/src"; +import { createApiClient } from "../../react-auth"; /** * We expose a singleton-like getter/setter for the API clients diff --git a/react-openapi/utils/openapi_loader.ts b/react-openapi/utils/openapi_loader.ts index 5078cd0..c40571f 100644 --- a/react-openapi/utils/openapi_loader.ts +++ b/react-openapi/utils/openapi_loader.ts @@ -1,6 +1,6 @@ import SwaggerParser from "@apidevtools/swagger-parser"; import { AppConfig, ResourceConfig, ResourceField, FieldType } from "../types/config"; -import { configuration, profileConfiguration } from "../configuration"; +import { configuration, profileConfiguration } from "../../src/openapi-config"; /** * Maps OpenAPI property types to our internal FieldType diff --git a/src/main.jsx b/src/main.jsx index f4d29da..1d4846d 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -1,17 +1,22 @@ import * as React from 'react'; import { createRoot } from 'react-dom/client'; +import { BrowserRouter, Routes, Route } from "react-router-dom"; import Home from './Home'; -import { AuthProvider } from "../react-auth/src"; -import { OpenapiProvider } from "../react-openapi/src"; +import Admin from '../react-openapi/Admin'; +import { AuthProvider } from "../react-auth"; const rootElement = document.getElementById('root'); const root = createRoot(rootElement); const AUTH_BASE = import.meta.env.VITE_AUTH_BASE_URL; root.render( - - - - - + + + + } /> + } /> + } /> + + + );