import React, { Component } from 'react';
import './App.css';
import Wiass from './components';
import { sendOrder, logIn } from './actions';



class App extends Component {
  constructor(props) {
    super(props);
    this.state = {roles: []};
  }

  



  render() {
    let self = this
    const authentucate = function (username, password) {
      logIn(username, password).then(response => {
        self.setState((prevState, props) => {
          return {roles: JSON.stringify(response.roles)};
        });
      });
    }

    const onLogInClicked = function (username, password) {
      return authentucate(username, password)
    }
  
    const onOrderClicked = function () {
      return sendOrder()
    }
    return (
        <div className="App">
        {this.state.roles}
          <Wiass onOrderClicked={onOrderClicked} onLogInClicked={onLogInClicked} />
        </div>
    );
  }
}

export default App;
