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