overleaf/services/web/frontend/js/shared/hooks/use-contact-us-modal.tsx
Alf Eaton d905863002 Merge pull request #8747 from overleaf/ae-error-boundary-fallback
Create a generic ErrorBoundaryFallback component

GitOrigin-RevId: 0c9200ddef2be3b90030a32eb8c36a59047cf2b4
2022-08-10 08:03:51 +00:00

28 lines
799 B
TypeScript

import importOverleafModules from '../../../macros/import-overleaf-module.macro'
import { JSXElementConstructor, useCallback, useState } from 'react'
const [contactUsModalModules] = importOverleafModules('contactUsModal')
const ContactUsModal: JSXElementConstructor<{
show: boolean
handleHide: () => void
}> = contactUsModalModules?.import.default
export const useContactUsModal = () => {
const [show, setShow] = useState(false)
const hideModal = useCallback((event?: Event) => {
event?.preventDefault()
setShow(false)
}, [])
const showModal = useCallback((event?: Event) => {
event?.preventDefault()
setShow(true)
}, [])
const modal = ContactUsModal && (
<ContactUsModal show={show} handleHide={hideModal} />
)
return { modal, hideModal, showModal }
}