Guest User

Untitled

a guest
Dec 12th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. {
  2. "Rohn": {
  3. "age": "30",
  4. "city": "Mexico",
  5. "occupation": "service",
  6. },
  7. "Max": {
  8. "age": "32",
  9. "city": "Colorado",
  10. "occupation": "Business",
  11. },
  12.  
  13. }
  14.  
  15. import React from "react";
  16. import Header from "./header";
  17. import PropTypes from "prop-types";
  18. import { connect } from "react-redux";
  19. import { createLogIn } from "../actions/action";
  20.  
  21. const axios = require("axios");
  22. import config from "../config/config";
  23.  
  24. class Login extends React.Component {
  25. constructor() {
  26. super();
  27. this.state = {
  28. account : { user:'', password: ''},
  29. authorizationError: false,
  30. UserData: ""
  31. };
  32.  
  33. componentDidMount () {
  34. var currentUserJwt = config[this.state.account.user];
  35. console.log(currentUserJwt);
  36. }
  37.  
  38.  
  39. handleAccountChange = ({ target: input}) => {
  40. const account = {...this.state.account}
  41. account[input.name] = input.value
  42. this.setState({ account})
  43. };
  44.  
  45.  
  46. handleLoginForm = (e) => {
  47. e.preventDefault();
  48. let postLoginData = {};
  49.  
  50. // call to action
  51. this.props.dispatch(createLogIn(postLoginData));
  52.  
  53. this.props.history.push('/intro');
  54. this.setState({ authorizationError: false });
  55.  
  56. };
  57.  
  58. render() {
  59. const {account} = this.state;
  60. return (
  61. <div className="intro">
  62. <form onSubmit={this.handleLoginForm}>
  63. <div className="content container">
  64. <div className="row">
  65. <div className="logo-wrap">
  66. <div className="logo intro-logo">
  67. </div>
  68. </div>
  69. </div>
  70. <div className="row">
  71. <div className="col-xs-12">
  72. <input
  73. type="text"
  74. autoFocus
  75. placeholder="username"
  76. name="user"
  77. value={account.user}
  78. onChange={this.handleAccountChange}
  79. />
  80. <input
  81. type="password"
  82. placeholder="password"
  83. name="password"
  84. value={account.password}
  85. onChange={this.handleAccountChange}
  86. />
  87. <button className="lg-cta">
  88. <span>Sign in</span>
  89. </button>
  90. </div>
  91. </div>
  92. </div>
  93. </form>
  94. </div>
  95. );
  96. }
  97. }
  98.  
  99. const mapStateToProps = state => ({
  100. logIn: state.logIn
  101. });
  102.  
  103. export default connect(mapStateToProps)(Login);
Add Comment
Please, Sign In to add comment