<commit_before>import React, { Component } from 'react';
import M from '../_common/M';
import Button from '../_common/Button';
import ErrorMsg from '../_common/ErrorMsg';
import InputGroup from '../_common/InputGroup';
import * as LiveData from '../_data/LiveData';

export default class EmailVerificationForm extends Component {

    static propTypes = {
        actions: React.PropTypes.object.isRequired,
        error: React.PropTypes.object.isRequired,
        email: React.PropTypes.string.isRequired,
        password: React.PropTypes.string.isRequired,
        residence: React.PropTypes.string.isRequired,
        verificationCode: React.PropTypes.string.isRequired,
    };

    static contextTypes = {
        router: React.PropTypes.object.isRequired,
    };

    async onVerificationCodeEntered(event) {
        const { actions } = this.props;
        try {
            await actions.createAccountFieldUpdate('verificationCode', event.target.value);
            await actions.createAccountFieldUpdate('error', null);
        } catch (err) {
            actions.createAccountFieldUpdate('error', err);
        }
    }

    async onVerify() {
        const { actions, email, password, residence, verificationCode } = this.props;
        const { router } = this.context;

        actions.createAccountFieldUpdate('progress', true);
        try {
            await LiveData.api.createVirtualAccount({
                email,
                client_password: password,
                residence,
                verification_code: verificationCode,
            });
            router.push('/signin');
        } catch (err) {
            actions.createAccountFailed(err);
        } finally {
            actions.createAccountFieldUpdate('progress', false);
        }
    }

    render() {
        const { error } = this.props;
        return (
            <div>
                <h3>
                    <M m="Please enter your email verification code" />
                </h3>
                <InputGroup
                    type="text"
                    placeholder="Verification Code"
                    onChange={::this.onVerificationCodeEntered}
                />
                <ErrorMsg
                    shown={!!error}
                    text={(error && error.message) || '-'}
                />
                <Button text="Verify" onClick={::this.onVerify} />
            </div>
        );
    }
}<commit_msg>Add go back button<commit_after>import React, { Component } from 'react';
import M from '../_common/M';
import Button from '../_common/Button';
import ErrorMsg from '../_common/ErrorMsg';
import InputGroup from '../_common/InputGroup';
import * as LiveData from '../_data/LiveData';

export default class EmailVerificationForm extends Component {

    static propTypes = {
        actions: React.PropTypes.object.isRequired,
        error: React.PropTypes.object,
        email: React.PropTypes.string.isRequired,
        password: React.PropTypes.string.isRequired,
        residence: React.PropTypes.string.isRequired,
        verificationCode: React.PropTypes.string.isRequired,
    };

    static contextTypes = {
        router: React.PropTypes.object.isRequired,
    };

    async onVerificationCodeEntered(event) {
        const { actions } = this.props;
        try {
            await actions.createAccountFieldUpdate('verificationCode', event.target.value);
            await actions.createAccountFieldUpdate('error', null);
        } catch (err) {
            actions.createAccountFieldUpdate('error', err);
        }
    }

    async onVerify() {
        const { actions, password, residence, verificationCode } = this.props;
        const { router } = this.context;

        actions.createAccountFieldUpdate('progress', true);
        try {
            await LiveData.api.createVirtualAccount({
                client_password: password,
                residence,
                verification_code: verificationCode,
            });
            router.push('/signin');
        } catch (err) {
            actions.createAccountFailed(err);
        } finally {
            actions.createAccountFieldUpdate('progress', false);
        }
    }

    goBack() {
        const { actions } = this.props;
        actions.createAccountFieldUpdate('step', 0);
    }

    render() {
        const { error } = this.props;
        return (
            <div>
                <h3>
                    <M m="Please enter your email verification code" />
                </h3>
                <InputGroup
                    type="text"
                    placeholder="Verification Code"
                    onChange={::this.onVerificationCodeEntered}
                />
                <ErrorMsg
                    shown={!!error}
                    text={(error && error.message) || '-'}
                />
                <Button text="Go back" onClick={::this.goBack} className="btn-secondary" /> 
                &nbsp;
                <Button text="Verify" onClick={::this.onVerify} />
            </div>
        );
    }
}
{'fraction_non_alphanumeric': 0.11203319502074689, 'fraction_numerical': 0.0009879470460383323, 'mean_word_length': 1.8028792912513842, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5385367', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1253, 'n_words': 261}