mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 09:55:20 -05:00
aa480a2663
[web] migrate from window attributes to getMeta GitOrigin-RevId: 3dcf1ab6b01155e5e4abeb3e78d0fa9053e055bc
29 lines
757 B
TypeScript
29 lines
757 B
TypeScript
import { forwardRef } from 'react'
|
|
import ReCAPTCHA from 'react-google-recaptcha'
|
|
import getMeta from '@/utils/meta'
|
|
import { ExposedSettings } from '../../../../types/exposed-settings'
|
|
|
|
type Page = keyof ExposedSettings['recaptchaDisabled']
|
|
|
|
export const ReCaptcha2 = forwardRef<
|
|
ReCAPTCHA,
|
|
{ page: Page; onChange?: (token: string | null) => void }
|
|
>(function ReCaptcha2({ page: site, onChange }, ref) {
|
|
const { recaptchaSiteKey, recaptchaDisabled } = getMeta('ol-ExposedSettings')
|
|
|
|
if (!recaptchaSiteKey) {
|
|
return null
|
|
}
|
|
if (site && recaptchaDisabled[site]) {
|
|
return null
|
|
}
|
|
return (
|
|
<ReCAPTCHA
|
|
ref={ref}
|
|
size="invisible"
|
|
sitekey={recaptchaSiteKey}
|
|
onChange={onChange}
|
|
badge="inline"
|
|
/>
|
|
)
|
|
})
|