stud-manager / contexts /SecurityContext.tsx
dvc890's picture
Create contexts/SecurityContext.tsx
833c7c4 verified
raw
history blame contribute delete
772 Bytes
import React, { createContext, useContext, useState } from 'react';
interface SecurityContextType {
isSensitiveUnlocked: boolean;
unlockSensitiveContent: () => void;
}
const SecurityContext = createContext<SecurityContextType>({
isSensitiveUnlocked: false,
unlockSensitiveContent: () => {},
});
export const SecurityProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [isSensitiveUnlocked, setIsSensitiveUnlocked] = useState(false);
const unlockSensitiveContent = () => {
setIsSensitiveUnlocked(true);
};
return (
<SecurityContext.Provider value={{ isSensitiveUnlocked, unlockSensitiveContent }}>
{children}
</SecurityContext.Provider>
);
};
export const useSecurity = () => useContext(SecurityContext);