import * as React from 'react' ; import { MessageDialogProviderContext } from './MessageDialogProvider' ; interface UseMessageDialogProvider { showMessageDialog : ( message : string , body : React . ReactNode , options ? : { backButton : boolean ; } ) => void ; closeMessageDialog : ( ) => void ; } const useMessageDialog = ( ) : UseMessageDialogProvider => { const { dispatch } = React . useContext ( MessageDialogProviderContext ) ; const showMessageDialog = ( title , body , options ? ) => { dispatch ( { open : true , title , body , backBtn : options ?. backButton ?? false } ) ; } ; const closeMessageDialog = ( ) => { dispatch ( { open : false , title : '' , body : < React . Fragment />, backBtn: false }); } ; return { showMessageDialog , closeMessageDialog } ; } ; export default useMessageDialog ;