mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 08:49:34 -05:00
34fc43d59a
React version of Contact Us modal GitOrigin-RevId: 0bef3095f36daa88afdc6172a5531ed11e892047
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import importOverleafModules from '../../../macros/import-overleaf-module.macro'
|
|
import { JSXElementConstructor, useCallback, useState } from 'react'
|
|
import { HelpSuggestionSearchProvider } from '../../../../modules/support/frontend/js/context/help-suggestion-search-context'
|
|
|
|
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 && (
|
|
<HelpSuggestionSearchProvider>
|
|
<ContactUsModal
|
|
show={show}
|
|
handleHide={hideModal}
|
|
autofillProjectUrl={options.autofillProjectUrl}
|
|
/>
|
|
</HelpSuggestionSearchProvider>
|
|
)
|
|
|
|
return { modal, hideModal, showModal }
|
|
}
|