openreplay/frontend/app/components/ForgotPassword/ReCaptcha.js
Andrey Babushkin fd5c0c9747
Add lokalisation (#3092)
* applied eslint

* add locales and lint the project

* removed error boundary

* updated locales

* fix min files

* fix locales
2025-03-06 17:43:15 +01:00

53 lines
1.1 KiB
JavaScript

import React, { Component } from 'react';
class ReCaptcha extends Component {
constructor(props) {
super(props);
this.loadRecaptcha = this.loadRecaptcha.bind(this);
this.handleChange = this.handleChange.bind(this);
}
componentDidMount() {
if (document.readyState === 'complete') {
// Window was already loaded (the component is rendered later on)
// ReCaptacha can be safely loaded
this.loadRecaptcha();
} else {
// Wait that the window gets loaded to load the ReCaptcha
window.onload = this.loadRecaptcha;
}
}
getValue() {
window.grecaptcha.getResponse(this.recatchaElt);
}
loadRecaptcha() {
const { id, apiKey, theme } = this.props;
this.recatchaElt = window.grecaptcha.render(
id,
{
sitekey: apiKey,
size: 'invisible',
callback: this.handleChange,
},
true,
);
}
handleChange() {
const { onChange } = this.props;
onChange(this.getValue());
}
render() {
const { id } = this.props;
return <div id={id} />;
}
}
export default ReCaptcha;