import React from 'react'

class LoginForm extends React.Component {

    constructor () {
      super()
      this.handleSubmit = this.handleSubmit.bind(this)
    }
  
    handleSubmit (event) {
      event.preventDefault()
      console.log(this.props.usersActions)
      const { loginRequest } = this.props.usersActions
      const data = {
        username: this.username.value,
        password: this.password.value
      }
      console.log('submit login data', data)
      loginRequest(data)
      //const { fileUploadStart } = this.props.actions
      //const { files } = this.playerListFile
      // if (files.length === 0) {
      //   alertAdd({ type: 'info', text: 'Datei entfernt' })
      //   return
      // }
      // if (files.length > 1) {
      //   alertAdd({ type: 'warning', text: 'Mehrere Dateien gesendet. Nur die erste wird verarbeitet.' })
      // }
    }
  

  render () {
      return (
    <div>
        <form ref='loginForm' onSubmit={this.handleSubmit}>
        <label>Benutzername</label>
        <input type='text' id='username' ref={(input) => {this.username = input}}/>
        <label>Passwort</label>
        <input type='password' id='password' ref={(input) => {this.password = input}}/>
        <input type='submit' />
        </form>
    </div>
      )
  }
}

export default LoginForm