diff --git a/src/context/browserActions.tsx b/src/context/browserActions.tsx index c9ac784c..ca08b816 100644 --- a/src/context/browserActions.tsx +++ b/src/context/browserActions.tsx @@ -1,43 +1,37 @@ -import React, { createContext, useState, useContext, ReactNode } from 'react'; +import React, { createContext, useContext, useState, ReactNode } from 'react'; -interface ActionContextType { +interface ActionContextProps { getText: boolean; getScreenshot: boolean; - handleGetText: () => void; - handleGetScreenshot: () => void; - resetActions: () => void; + startGetText: () => void; + stopGetText: () => void; + startGetScreenshot: () => void; + stopGetScreenshot: () => void; } -const ActionContext = createContext(undefined); +const ActionContext = createContext(undefined); -export const useActionContext = (): ActionContextType => { +export const ActionProvider = ({ children }: { children: ReactNode }) => { + const [getText, setGetText] = useState(false); + const [getScreenshot, setGetScreenshot] = useState(false); + + const startGetText = () => setGetText(true); + const stopGetText = () => setGetText(false); + + const startGetScreenshot = () => setGetScreenshot(true); + const stopGetScreenshot = () => setGetScreenshot(false); + + return ( + + {children} + + ); +}; + +export const useActionContext = () => { const context = useContext(ActionContext); if (context === undefined) { throw new Error('useActionContext must be used within an ActionProvider'); } return context; }; - -interface ActionProviderProps { - children: ReactNode; -} - -export const ActionProvider: React.FC = ({ children }) => { - const [getText, setGetText] = useState(false); - const [getScreenshot, setGetScreenshot] = useState(false); - - const handleGetText = () => setGetText(true); - const handleGetScreenshot = () => setGetScreenshot(true); - - // Reset actions (optional) - const resetActions = () => { - setGetText(false); - setGetScreenshot(false); - }; - - return ( - - {children} - - ); -}; \ No newline at end of file