[5a9c93b] | 1 | import * as React from "react";
|
---|
| 2 | import bootstrap from 'bootstrap/dist/css/bootstrap.min.css'
|
---|
| 3 | import classNames from 'classnames';
|
---|
| 4 |
|
---|
| 5 | export default class LoginForm extends React.Component {
|
---|
| 6 | constructor(props) {
|
---|
| 7 | super(props);
|
---|
| 8 | this.state = {
|
---|
| 9 | active: "login",
|
---|
| 10 | firstName: "",
|
---|
| 11 | lastName: "",
|
---|
| 12 | email: "",
|
---|
| 13 | password: "",
|
---|
| 14 | onLogin: props.onLogin,
|
---|
| 15 | onRegister: props.onRegister
|
---|
| 16 | }
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | onChangeHandler = (e) => {
|
---|
| 20 | let name = e.target.name;
|
---|
| 21 | let value = e.target.value;
|
---|
| 22 | this.setState({[name]: value})
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | onSubmitLogin = (e) => {
|
---|
| 26 | this.state.onLogin(e, this.state.email, this.state.password);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | onSubmitRegister = (e) => {
|
---|
| 30 | this.state.onRegister(
|
---|
| 31 | e,
|
---|
| 32 | this.state.firstName,
|
---|
| 33 | this.state.lastName,
|
---|
| 34 | this.state.email,
|
---|
| 35 | this.state.password)
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | render() {
|
---|
| 39 | return (
|
---|
| 40 | <div className="row justify-content-center">
|
---|
| 41 | <div className="col-4">
|
---|
| 42 | <ul className="nav nav-pills nav-justified mb-3" id="ex1" role="tablist">
|
---|
| 43 | <li className="nav-item" role="presentation">
|
---|
| 44 | <button className={classNames("nav-link", this.state.active === "login" ? "active" : "")}
|
---|
| 45 | id="tab-login" onClick={() => this.setState({active: "login"})}>Login
|
---|
| 46 | </button>
|
---|
| 47 | </li>
|
---|
| 48 | <li className="nav-item" role="presentation">
|
---|
| 49 | <button className={classNames("nav-link", this.state.active === "register" ? "active" : "")}
|
---|
| 50 | id="tab-register" onClick={() => this.setState({active: "register"})}>Register
|
---|
| 51 | </button>
|
---|
| 52 | </li>
|
---|
| 53 | </ul>
|
---|
| 54 |
|
---|
| 55 | <div className="tab-content">
|
---|
| 56 | <div
|
---|
| 57 | className={classNames("tab-pane", "fade", this.state.active === "login" ? "show active" : "")} id="pills-login">
|
---|
| 58 | <form onSubmit={this.onSubmitLogin}>
|
---|
| 59 | <div className="form-outline mb-4">
|
---|
[db39d9e] | 60 | <input type="email" id="email" name="email" className="form-control" onChange={this.onChangeHandler}/>
|
---|
| 61 | <label className="form-label" htmlFor="email">Email</label>
|
---|
[5a9c93b] | 62 | </div>
|
---|
| 63 | <div className="form-outline mb-4">
|
---|
| 64 | <input type="password" id="loginPassword" name="password" className="form-control" onChange={this.onChangeHandler}/>
|
---|
| 65 | <label className="form-label" htmlFor="loginPassword">Password</label>
|
---|
| 66 | </div>
|
---|
| 67 |
|
---|
| 68 | <button type="submit" className="btn btn-primary btn-block mb-4">Sign In</button>
|
---|
| 69 | </form>
|
---|
| 70 | </div>
|
---|
| 71 |
|
---|
| 72 | <div
|
---|
| 73 | className={classNames("tab-pane", "fade", this.state.active === "register" ? "show active" : "")} id="pills-register">
|
---|
| 74 | <form onSubmit={this.onSubmitRegister}>
|
---|
| 75 | <div className="form-outline mb-4">
|
---|
| 76 | <input type="text" id="firstName" name="firstName" className="form-control" onChange={this.onChangeHandler}/>
|
---|
| 77 | <label className="form-label" htmlFor="firstName">First Name</label>
|
---|
| 78 | </div>
|
---|
| 79 | <div className="form-outline mb-4">
|
---|
| 80 | <input type="text" id="lastName" name="lastName" className="form-control" onChange={this.onChangeHandler}/>
|
---|
| 81 | <label className="form-label" htmlFor="lastName">Last Name</label>
|
---|
| 82 | </div>
|
---|
| 83 | <div className="form-outline mb-4">
|
---|
| 84 | <input type="text" id="email" name="email" className="form-control" onChange={this.onChangeHandler}/>
|
---|
| 85 | <label className="form-label" htmlFor="email">Email</label>
|
---|
| 86 | </div>
|
---|
| 87 | <div className="form-outline mb-4">
|
---|
| 88 | <input type="password" id="loginPassword" name="password" className="form-control" onChange={this.onChangeHandler}/>
|
---|
| 89 | <label className="form-label" htmlFor="loginPassword">Password</label>
|
---|
| 90 | </div>
|
---|
| 91 |
|
---|
| 92 | <button type="submit" className="btn btn-primary btn-block mb-4">Sign In</button>
|
---|
| 93 | </form>
|
---|
| 94 | </div>
|
---|
| 95 | </div>
|
---|
| 96 | </div>
|
---|
| 97 | </div>
|
---|
| 98 | )
|
---|
| 99 | }
|
---|
| 100 | } |
---|