<commit_before>import React from 'react'
import {invalidCredentials, login$, resetInvalidCredentials} from 'user'
import {Constraints, ErrorMessage, form, Input} from 'widget/form'
import {ForgotPasswordLink} from './forgot-password'
import {SubmitButton} from 'widget/button'
import {Msg, msg} from 'translate'
import PropTypes from 'prop-types'

const inputs = {
    username: new Constraints()
        .notBlank('landing.login.username.required'),
    password: new Constraints()
        .notBlank('landing.login.password.required')
}

const mapStateToProps = () => ({
    errors: invalidCredentials() ? {password: msg('landing.login.password.invalid')} : {}
})

class Login extends React.Component {
    login({username, password}) {
        this.props.asyncActionBuilder('LOGIN',
            login$(username, password))
            .dispatch()
    }

    componentWillUnmount() {
        resetInvalidCredentials()
    }

    render() {
        const {form, inputs: {username, password}, action} = this.props
        return (
            <form>
                <div>
                    <label><Msg id='landing.login.username.label'/></label>
                    <Input
                        input={username}
                        placeholder={msg('landing.login.username.placeholder')}
                        autoFocus='on'
                        autoComplete='off'
                        tabIndex={1}/>
                    <ErrorMessage input={username}/>
                </div>
                <div>
                    <label><Msg id='landing.login.password.label'/></label>
                    <Input
                        input={password}
                        type='password'
                        placeholder={msg('landing.login.password.placeholder')}
                        tabIndex={2}/>
                    <ErrorMessage input={password}/>
                </div>

                <SubmitButton
                    icon={action('LOGIN').dispatching ? 'spinner' : 'sign-in'}
                    onClick={() => this.login(form.values())}
                    disabled={form.hasInvalid() || action('LOGIN').dispatching}
                    tabIndex={3}>
                    <Msg id='landing.login.button'/>
                </SubmitButton>

                <ForgotPasswordLink tabIndex={4}/>
            </form>)
    }
}

Login.propTypes = {
    form: PropTypes.object,
    inputs: PropTypes.shape({
        username: PropTypes.string,
        password: PropTypes.string,
    }),<commit_msg>Corrected prop types of form input.<commit_after>import React from 'react'
import {invalidCredentials, login$, resetInvalidCredentials} from 'user'
import {Constraints, ErrorMessage, form, Input} from 'widget/form'
import {ForgotPasswordLink} from './forgot-password'
import {SubmitButton} from 'widget/button'
import {Msg, msg} from 'translate'
import PropTypes from 'prop-types'

const inputs = {
    username: new Constraints()
        .notBlank('landing.login.username.required'),
    password: new Constraints()
        .notBlank('landing.login.password.required')
}

const mapStateToProps = () => ({
    errors: invalidCredentials() ? {password: msg('landing.login.password.invalid')} : {}
})

class Login extends React.Component {
    login({username, password}) {
        this.props.asyncActionBuilder('LOGIN',
            login$(username, password))
            .dispatch()
    }

    componentWillUnmount() {
        resetInvalidCredentials()
    }

    render() {
        const {form, inputs: {username, password}, action} = this.props
        return (
            <form>
                <div>
                    <label><Msg id='landing.login.username.label'/></label>
                    <Input
                        input={username}
                        placeholder={msg('landing.login.username.placeholder')}
                        autoFocus='on'
                        autoComplete='off'
                        tabIndex={1}/>
                    <ErrorMessage input={username}/>
                </div>
                <div>
                    <label><Msg id='landing.login.password.label'/></label>
                    <Input
                        input={password}
                        type='password'
                        placeholder={msg('landing.login.password.placeholder')}
                        tabIndex={2}/>
                    <ErrorMessage input={password}/>
                </div>

                <SubmitButton
                    icon={action('LOGIN').dispatching ? 'spinner' : 'sign-in'}
                    onClick={() => this.login(form.values())}
                    disabled={form.hasInvalid() || action('LOGIN').dispatching}
                    tabIndex={3}>
                    <Msg id='landing.login.button'/>
                </SubmitButton>

                <ForgotPasswordLink tabIndex={4}/>
            </form>)
    }
}

Login.propTypes = {
    form: PropTypes.object,
    inputs: PropTypes.shape({
        username: PropTypes.object,
        password: PropTypes.object,
    }),
{'fraction_non_alphanumeric': 0.12767220902612827, 'fraction_numerical': 0.001583531274742676, 'mean_word_length': 1.7269293038316245, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 47, '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': '5930841', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1240, 'n_words': 243}