2022-08-09 09:48:59 -04:00
|
|
|
import importOverleafModules from '../../../macros/import-overleaf-module.macro'
|
2024-09-30 05:49:18 -04:00
|
|
|
import {
|
|
|
|
JSXElementConstructor,
|
|
|
|
useCallback,
|
|
|
|
useState,
|
|
|
|
type UIEvent,
|
|
|
|
} from 'react'
|
2022-08-09 09:48:59 -04:00
|
|
|
|
|
|
|
const [contactUsModalModules] = importOverleafModules('contactUsModal')
|
|
|
|
const ContactUsModal: JSXElementConstructor<{
|
|
|
|
show: boolean
|
|
|
|
handleHide: () => void
|
2024-08-13 07:37:15 -04:00
|
|
|
autofillProjectUrl: boolean
|
2022-08-09 09:48:59 -04:00
|
|
|
}> = contactUsModalModules?.import.default
|
|
|
|
|
2024-08-13 07:37:15 -04:00
|
|
|
export const useContactUsModal = (options = { autofillProjectUrl: true }) => {
|
2022-08-09 09:48:59 -04:00
|
|
|
const [show, setShow] = useState(false)
|
|
|
|
|
|
|
|
const hideModal = useCallback((event?: Event) => {
|
|
|
|
event?.preventDefault()
|
|
|
|
setShow(false)
|
|
|
|
}, [])
|
|
|
|
|
2024-09-30 05:49:18 -04:00
|
|
|
const showModal = useCallback((event?: Event | UIEvent) => {
|
2022-08-09 09:48:59 -04:00
|
|
|
event?.preventDefault()
|
|
|
|
setShow(true)
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
const modal = ContactUsModal && (
|
2024-08-22 04:01:44 -04:00
|
|
|
<ContactUsModal
|
|
|
|
show={show}
|
|
|
|
handleHide={hideModal}
|
|
|
|
autofillProjectUrl={options.autofillProjectUrl}
|
|
|
|
/>
|
2022-08-09 09:48:59 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
return { modal, hideModal, showModal }
|
|
|
|
}
|