import React, { Component } from 'react';
import { initCaptcha } from '@/utils';

const CAPTCHAID = '6b0f5f6c8f334f3693ee754ba5692e36'


class Captcha extends Component {
    componentDidMount() {
        const {getInstance, handleError, onVerify} = this.props
        const el = document.getElementById('captcha');
        el && initCaptcha(function () {
            initNECaptcha({
                    element: el,
                    captchaId: CAPTCHAID,
                    mode: 'float',
                    width: 'auto',
                    onVerify: function (err, data) {
                        onVerify(err,data)
                    }
                },
                instance => {
                    getInstance && getInstance(instance)
                },
                err => {
                    handleError && handleError(err)
                }
            )
        })
    }

    render() {
        return (
            <div id={'captcha'} style={{'marginBottom':  this.props.mrBtm}}></div>
        );
    }
}

export default Captcha;