Advertisement
Guest User

Untitled

a guest
Feb 21st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import _ from 'lodash';
  3. import classNames from 'classnames';
  4. import formatErrors from '../lib/format-errors';
  5. import { Link } from 'react-router';
  6. import { subscribe, getState } from '../store.js';
  7. import UserActions from '../actions/UserActions';
  8. import ErrorDisplay from './errorDisplay.jsx';
  9.  
  10. const propTypes = {
  11. Errors: React.PropTypes.array
  12. }
  13.  
  14. class Register extends Component {
  15. constructor(props) {
  16. super(props);
  17. this.submit = this.submit.bind(this);
  18. }
  19.  
  20. componentDidMount() {
  21. this.unsubscribe = subscribe(this.render);
  22. }
  23.  
  24. componentWillUnmount() {
  25. this.unsubscribe();
  26. }
  27.  
  28. submit(e) {
  29. e.preventDefault();
  30. UserActions.register({
  31. username: this.emailInput.value,
  32. password: this.passwordInput.value,
  33. passwordConfirm: this.passwordConfirmInput.value
  34. });
  35. }
  36.  
  37. render() {
  38. let formClass = classNames({
  39. 'form-group': true,
  40. 'has-error': false
  41. });
  42.  
  43. let inputClass = classNames({
  44. 'form-control': true,
  45. 'input-lg': true
  46. });
  47.  
  48. return (
  49. <form className="form-horizontal" onSubmit={this.submit}>
  50. <h2>Sign Up</h2>
  51. <hr/>
  52.  
  53. <fieldset disabled={''}>
  54. <div className={formClass}>
  55. <label className="col-sm-2 control-label">Email</label>
  56. <div className="col-sm-10">
  57. <input ref={(ref) => this.emailInput = ref}
  58. type="text"
  59. className={inputClass}
  60. placeholder="Email"
  61. onChange={this.emailChange}/>
  62. <span className="help-block" />
  63. </div>
  64. </div>
  65.  
  66. <div className={formClass}>
  67. <label className="col-sm-2 control-label">Password</label>
  68. <div className="col-sm-10">
  69. <input ref={(ref) => this.passwordInput = ref}
  70. type="password"
  71. className={inputClass}
  72. placeholder="Password"
  73. onChange={this.passwordChange}/>
  74. <span className="help-block" />
  75. </div>
  76. </div>
  77.  
  78. <div className={formClass}>
  79. <label className="col-sm-2 control-label">Confirm Password</label>
  80. <div className="col-sm-10">
  81. <input type="password"
  82. ref={(ref) => this.passwordConfirmInput = ref}
  83. className={inputClass}
  84. placeholder="Confirm Password"
  85. onChange={this.confirmPassword}/>
  86. <span className="help-block" />
  87. </div>
  88. </div>
  89.  
  90. <div className="form-group">
  91. <div className="col-sm-offset-2 col-sm-10">
  92. <input type="submit"
  93. className="btn btn-lg btn-primary"
  94. value="Sign Up For Betterways!"/>
  95. <Link to="/login"
  96. className="btn btn-lg btn-primary">
  97. Login
  98. </Link>
  99. </div>
  100. </div>
  101. </fieldset>
  102. {(function () {console.log(getState().Errors.toJS()); return getState().Errors.toJS()}())}
  103. <ErrorDisplay errorMessages={getState().Errors}/>
  104. </form>
  105. );
  106. }
  107. };
  108.  
  109. export default Register;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement