mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 18:13:40 -05:00
b4ad1ed35d
Fix SP and CE builds broken by Contact Us changes GitOrigin-RevId: fb9099ed7d755b30ab8706facd6f0d95aefbad1e
33 lines
937 B
TypeScript
33 lines
937 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
|
|
autofillProjectUrl: boolean
|
|
}> = contactUsModalModules?.import.default
|
|
|
|
export const useContactUsModal = (options = { autofillProjectUrl: true }) => {
|
|
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}
|
|
autofillProjectUrl={options.autofillProjectUrl}
|
|
/>
|
|
)
|
|
|
|
return { modal, hideModal, showModal }
|
|
}
|