aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/LoginButton.js
blob: c332de14bd3683aea46791fe4741aabb1cec8f2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react';
import PropTypes from 'prop-types';
import Icon from './Icon';
import Modal from './Modal';


export default class LoginButton extends React.Component {
  constructor(props) {
    super(props);
    this.state = { isOpen: false };
  }
  toggleModal(event) {
    event.preventDefault()
    this.setState({
      isOpen: !this.state.isOpen
    });
  }

  render() {
    return (
      <React.Fragment>
        <a onClick={this.toggleModal.bind(this)}><Icon name="ei-user" size="s" />{this.props.title}</a>
        <Modal show={this.state.isOpen}
          onClose={this.toggleModal.bind(this)}>
          <div className="dialoglogin">
            <p>Please, introduce yourself:</p>
            <a href="/_fblogin" id="signfb"><Icon name="ei-sc-facebook" size="s" />Login with facebook</a>
            <a href="/_vklogin" id="signvk"><Icon name="ei-sc-vk" size="s" />Login with VK</a>
            <p>Already registered?</p>
            <form action="/login" method="POST">
              <input className="signinput" type="text" name="username" placeholder="Username..." /><br />
              <input className="signinput" type="password" name="password" placeholder="Password..." /><br />
              <input className="signsubmit" type="submit" value="OK" />
            </form>
          </div>
        </Modal>
      </React.Fragment>
    );
  }
}

LoginButton.propTypes = {
  title: PropTypes.string.isRequired,
  onAuth: PropTypes.func.isRequired
};