import { type ReactNode, createContext, useContext, useState } from "react"; interface ModalContextProps { isOpen: boolean; openModal: () => void; closeModal: () => void; } const ModalContext = createContext(undefined); export const ModalProvider = ({ children }: { children: ReactNode }) => { const [isOpen, setIsOpen] = useState(false); const openModal = () => { setIsOpen(true); }; const closeModal = () => { setIsOpen(false); }; return ( {children} ); }; export const useModal = () => { const context = useContext(ModalContext); if (!context) { throw new Error("useModal must be used within a ModalProvider"); } return context; };