Spaces:
Running
Running
| 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); | |