Files
khata-ui/react-openapi/src/context/AppContext.tsx

22 lines
620 B
TypeScript

import { createContext, useContext } from "react";
import type { ResourceConfig, SpecConfiguration, ValidationMessage } from "../types";
export interface AppContextValue {
config: SpecConfiguration;
resources: ResourceConfig[];
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;
}