<commit_before>// @flow
import React, {Component} from 'react'
import {Form, Message, Grid} from 'semantic-ui-react'
import {Helmet} from 'react-helmet'
import _ from 'lodash'
import {LoginButton} from './style'

type Props = {
	login: (data: Object) => void,
	errors: Object
}

type State = {
	username: string,
	password: string
}

class LoginComponent extends Component {
	props: Props
	state: State = {
		username: '',
		password: ''
	}

	handleSubmit (e: Event) {
		e.preventDefault()
		const {username, password} = this.state
		this.props.login({username, password})
	}

	handleChange (e: Event, {name, value}) {
		this.setState({
			[name]: value
		})
	}

	render () {
		const {username, password} = this.state
		// Error from server
		const {errors} = this.props
		const loginFormProps = {error: !_.isEmpty(errors)}

		return (
			<Grid
				verticalAlign="middle"
				centered
				columns={1}
				textAlign="center"
				relaxed
				stretched
			>
				<Helmet>
					<title>Noir:Login</title>
				</Helmet>
				<Grid.Row>
					<Grid.Column tablet={10} mobile={16} computer={6}>
						{/* Consider using Redux-Form */}
						<Form onSubmit={this.handleSubmit.bind(this)} {...loginFormProps}>
							{errors && (
								<Message
									error
									header={'Invalid credentials'}
									content={'Your credentials are invalid.'}
								/>
							)}
							<Form.Input
								placeholder="Username"
								name="username"
								label="Username"
								value={username}
								onChange={this.handleChange}
							/>
							<Form.Input
								autoComplete="current-password"
								placeholder="Password"
								type="password"
								name="password"
								label="Password"
								value={password}
								onChange={this.handleChange}
							/>
							<LoginButton content="Login" icon="sign in" />
						</Form>
					</Grid.Column>
				</Grid.Row>
			</Grid>
		)
	}
}

export default LoginComponent
<commit_msg>fix(containers/Login): fix input fields onChange<commit_after>// @flow
import React, {Component} from 'react'
import {Form, Message, Grid} from 'semantic-ui-react'
import {Helmet} from 'react-helmet'
import _ from 'lodash'
import {LoginButton} from './style'

type Props = {
	login: (data: Object) => void,
	errors: Object
}

type State = {
	username: string,
	password: string
}

class LoginComponent extends Component {
	props: Props
	state: State = {
		username: '',
		password: ''
	}

	handleSubmit (e: Event) {
		e.preventDefault()
		const {username, password} = this.state
		this.props.login({username, password})
	}

	handleChange (e: Event, {name, value}) {
		this.setState({
			[name]: value
		})
	}

	render () {
		const {username, password} = this.state
		// Error from server
		const {errors} = this.props
		const loginFormProps = {error: !_.isEmpty(errors)}

		return (
			<Grid
				verticalAlign="middle"
				centered
				columns={1}
				textAlign="center"
				relaxed
				stretched
			>
				<Helmet>
					<title>Noir:Login</title>
				</Helmet>
				<Grid.Row>
					<Grid.Column tablet={10} mobile={16} computer={6}>
						{/* Consider using Redux-Form */}
						<Form onSubmit={this.handleSubmit.bind(this)} {...loginFormProps}>
							{errors && (
								<Message
									error
									header={'Invalid credentials'}
									content={'Your credentials are invalid.'}
								/>
							)}
							<Form.Input
								placeholder="Username"
								name="username"
								label="Username"
								value={username}
								onChange={this.handleChange.bind(this)}
							/>
							<Form.Input
								autoComplete="current-password"
								placeholder="Password"
								type="password"
								name="password"
								label="Password"
								value={password}
								onChange={this.handleChange.bind(this)}
							/>
							<LoginButton content="Login" icon="sign in" />
						</Form>
					</Grid.Column>
				</Grid.Row>
			</Grid>
		)
	}
}

export default LoginComponent

{'fraction_non_alphanumeric': 0.141656050955414, 'fraction_numerical': 0.003057324840764331, 'mean_word_length': 2.5952380952380953, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, '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': '127967', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1209, 'n_words': 278}