- main.jsx: remove VITE_AUTH_BASE_URL env var; add AppContent that reads authConfig from useAppContext() and passes to AuthProvider; reorder: AppProvider -> AuthProvider -> BrowserRouter - sync react-openapi: AuthConfig type, extractAuthConfig, loading fix - sync react-auth: authConfig prop, config-driven paths, server logout
25 lines
776 B
TypeScript
25 lines
776 B
TypeScript
import { createContext, useContext } from "react";
|
|
import type { AuthConfig, ProfileComponents, ProfileOperation, ResourceConfig, SpecConfiguration, ValidationMessage } from "../types";
|
|
|
|
export interface AppContextValue {
|
|
config: SpecConfiguration;
|
|
resources: ResourceConfig[];
|
|
profileOperations: ProfileOperation[];
|
|
profileComponents: ProfileComponents;
|
|
authConfig: AuthConfig;
|
|
schemas: Record<string, any>;
|
|
loading: boolean;
|
|
errors: ValidationMessage[];
|
|
warnings: ValidationMessage[];
|
|
}
|
|
|
|
export const AppContext = createContext<AppContextValue | null>(null);
|
|
|
|
export function useAppContext(): AppContextValue {
|
|
const ctx = useContext(AppContext);
|
|
if (!ctx) {
|
|
throw new Error("useAppContext must be used within an AppProvider");
|
|
}
|
|
return ctx;
|
|
}
|