overleaf/services/web/frontend/js/shared/components/recaptcha-2.tsx
ilkin-overleaf 687b56f18e Merge pull request #19141 from overleaf/ii-add-email-account-settings
[web] Reset recaptcha every time

GitOrigin-RevId: 6db3571ad6dad3611c748a2d92dce47002a16a77
2024-07-01 08:04:07 +00:00

33 lines
793 B
TypeScript

import ReCAPTCHA from 'react-google-recaptcha'
import getMeta from '@/utils/meta'
import { ExposedSettings } from '../../../../types/exposed-settings'
interface ReCaptcha2Props
extends Pick<React.ComponentProps<typeof ReCAPTCHA>, 'onChange'> {
page: keyof ExposedSettings['recaptchaDisabled']
recaptchaRef: React.LegacyRef<ReCAPTCHA>
}
export function ReCaptcha2({
page: site,
onChange,
recaptchaRef,
}: ReCaptcha2Props) {
const { recaptchaSiteKey, recaptchaDisabled } = getMeta('ol-ExposedSettings')
if (!recaptchaSiteKey) {
return null
}
if (site && recaptchaDisabled[site]) {
return null
}
return (
<ReCAPTCHA
ref={recaptchaRef}
size="invisible"
sitekey={recaptchaSiteKey}
onChange={onChange}
badge="inline"
/>
)
}