mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 11:39:26 +01:00
20 lines
599 B
TypeScript
20 lines
599 B
TypeScript
import { createContext, useContext, ReactNode } from 'react'
|
|
|
|
interface ModalContextProps {
|
|
openModal: (content: ReactNode, id: string, preventClose?: boolean) => void
|
|
closeModal: (id: string) => void
|
|
closeAllModals: () => void
|
|
_getCurrentModals: () => Record<string, ReactNode>
|
|
preventCloseOnOverlayClick?: boolean
|
|
}
|
|
|
|
export const ModalContext = createContext<ModalContextProps | undefined>(undefined)
|
|
|
|
export const useModals = () => {
|
|
const context = useContext(ModalContext)
|
|
if (!context) {
|
|
throw new Error('useModal must be used within a ModalProvider')
|
|
}
|
|
return context
|
|
}
|