2023-06-26 04:32:49 -04:00
|
|
|
import { forwardRef } from 'react'
|
|
|
|
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-18 06:01:37 -04:00
|
|
|
type Page = keyof ExposedSettings['recaptchaDisabled']
|
2023-06-26 04:32:49 -04:00
|
|
|
|
|
|
|
export const ReCaptcha2 = forwardRef<
|
|
|
|
ReCAPTCHA,
|
|
|
|
{ page: Page; onChange?: (token: string | null) => void }
|
|
|
|
>(function ReCaptcha2({ page: site, onChange }, ref) {
|
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
|
|
|
|
ref={ref}
|
|
|
|
size="invisible"
|
2024-06-18 06:01:37 -04:00
|
|
|
sitekey={recaptchaSiteKey}
|
2023-06-26 04:32:49 -04:00
|
|
|
onChange={onChange}
|
|
|
|
badge="inline"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
})
|