first commit
This commit is contained in:
32
src/contexts/AppContext.tsx
Normal file
32
src/contexts/AppContext.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
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>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user