Guest User

Untitled

a guest
May 27th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. class FormUserPass extends PureComponent {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. username: '',
  6. password: '',
  7. passwordVerify: '',
  8. stage: props.currentUser.stage || 0,
  9. }
  10. }
  11.  
  12. handleChange(name, value) {
  13. console.log("data: ", name, value);
  14. this.setState({ [name]: value }, () => {
  15. console.log(this.state);
  16. if ((this.state.password.length !== 0) && (this.state.password !== this.state.passwordVerify)) {
  17. console.log("password not match");
  18. return;
  19. }
  20. if ((this.state.stage === 0) && (this.state.password.length === 0)) {
  21. console.log("must change password");
  22. return;
  23. }
  24. console.log("ok");
  25. this.props.inputProperties.onChange(
  26. this.props.inputProperties.name,
  27. { username: this.state.username,
  28. password: this.state.password }
  29. );
  30. });
  31. }
  32.  
  33. render() {
  34. // const { errorMessage } = this.props.context.getErrorMessage();
  35. return (
  36. <div className="row section-content form-group row form-funnel">
  37. <div className="col-md-6 col-sm-6">
  38. <label htmlFor="">Nom actuel d'utilisateur</label>
  39. <input type="text" className="form-control" id="" disabled placeholder={this.props.currentUser.displayName}/>
  40. </div>
  41. <div className="col-md-6 col-sm-6">
  42. <label htmlFor="">Nouveau nom d'utilisateur</label>
  43. <Input name="username" onChange={this.handleChange.bind(this)} value="" layout="elementOnly" placeholder="Changer le nom"/>
  44. </div>
  45. <div className="col-md-6 col-sm-6">
  46. <label htmlFor="">Nouveau mot de passe</label>
  47. <Input name="password" onChange={this.handleChange.bind(this)} value="" layout="elementOnly" placeholder="Changer de mot de passe"/>
  48. </div>
  49. <div className="col-md-6 col-sm-6">
  50. <label htmlFor="">Confirmer le mot de passe</label>
  51. <Input name="passwordVerify" onChange={this.handleChange.bind(this)} value="" validations="equalsField:password" validationErrors={{ equalsField : "Saisissez le même mot de passe"}} layout="elementOnly" placeholder="Confirmer le nouveau mot de passe"/>
  52. </div>
  53. </div>
  54. );
  55. }
  56. }
  57. FormUserPass.contextTypes = {
  58. updateCurrentValues: PropTypes.func,
  59. };
  60. registerComponent('FormUserPass', FormUserPass);
Add Comment
Please, Sign In to add comment