Files
AIRegulation-Demo-Test/src/contexts/AppContext.tsx

32 lines
819 B
TypeScript
Raw Normal View History

2026-05-06 17:43:39 +08:00
import { createContext, useContext, useState, type ReactNode } from 'react';
type TabId = 'docs' | 'compliance' | 'status' | 'rag';
interface AppContextValue {
activeTab: TabId;
setActiveTab: (tab: TabId) => void;
}
const AppContext = createContext<AppContextValue | undefined>(undefined);
export const useApp = (): AppContextValue => {
const context = useContext(AppContext);
if (!context) {
throw new Error('useApp must be used within an AppProvider');
}
return context;
};
interface AppProviderProps {
children: ReactNode;
}
export const AppProvider: React.FC<AppProviderProps> = ({ children }) => {
const [activeTab, setActiveTab] = useState<TabId>('compliance');
return (
<AppContext.Provider value={{ activeTab, setActiveTab }}>
{children}
</AppContext.Provider>
);
};