<commit_before>import React, { Component } from 'react';
import Relay from 'react-relay';
import { Grid, Row, Col, Form, FormGroup, FormControl, Checkbox, Button, Panel, ControlLabel, Alert } from 'react-bootstrap';
import { Link } from 'react-router';

import LoginMutation from '../../mutations/LoginMutation';

class LoginView extends Component {
  constructor(props) {
    super(props);

    this.state = {
      fail: 'none',
      success: 'none',
      user: {
        username: null,
        password: <PASSWORD>
      }
    };

    // bind methods
    this.onSuccess = this.onSuccess.bind(this);
    this.onFailure = this.onFailure.bind(this);
    this.handleChange = this.handleChange.bind(this);
    this.handleLogin = this.handleLogin.bind(this);
  }

  onSuccess(res) {
    console.log('Response on view', res.login.userInfo);
    this.setState({success: 'block'});
  }

  onFailure() {
    this.setState({fail: 'block'});
  }

  handleChange(e) {
    this.setState({user: Object.assign({}, this.state.user, {[e.target.name]: e.target.value})});
  }

  handleLogin() {
    const onSuccess = this.onSuccess;
    const onFailure = this.onFailure;
    Relay.Store.commitUpdate(new LoginMutation({
      username: this.state.user.username,
      password: <PASSWORD>,
      viewer: this.props.viewer
    }), {onFailure, onSuccess});
  }

  render() {
    return (
      <Grid>
        <Row>
          <Panel>
            <h2>Login</h2>
          </Panel>
        </Row>
        <Row><commit_msg>Added redirect to welcome view on login<commit_after>import React, { Component } from 'react';
import Relay from 'react-relay';
import { Grid, Row, Col, Form, FormGroup, FormControl, Checkbox, Button, Panel, ControlLabel, Alert } from 'react-bootstrap';
import { Link, hashHistory } from 'react-router';

import LoginMutation from '../../mutations/LoginMutation';

class LoginView extends Component {
  constructor(props) {
    super(props);

    this.state = {
      fail: 'none',
      success: 'none',
      user: {
        username: null,
        password: <PASSWORD>
      }
    };

    // bind methods
    this.onSuccess = this.onSuccess.bind(this);
    this.onFailure = this.onFailure.bind(this);
    this.handleChange = this.handleChange.bind(this);
    this.handleLogin = this.handleLogin.bind(this);
  }

  onSuccess(res) {
    console.log('Response on view', res.login.userInfo);
    this.setState({success: 'block'});
    // implement transition
    hashHistory.push('/welcome');
  }

  onFailure() {
    this.setState({fail: 'block'});
  }

  handleChange(e) {
    this.setState({user: Object.assign({}, this.state.user, {[e.target.name]: e.target.value})});
  }

  handleLogin() {
    const onSuccess = this.onSuccess;
    const onFailure = this.onFailure;
    Relay.Store.commitUpdate(new LoginMutation({
      username: this.state.user.username,
      password: <PASSWORD>,
      viewer: this.props.viewer
    }), {onFailure, onSuccess});
  }

  render() {
    return (
      <Grid>
        <Row>
          <Panel>
            <h2>Login</h2>
          </Panel>
        </Row>
        <Row>
{'fraction_non_alphanumeric': 0.14860083628176263, 'fraction_numerical': 0.001286587327114828, 'mean_word_length': 2.78345498783455, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '92594', 'n_tokens_mistral': 984, 'n_tokens_neox': 975, 'n_words': 207}