Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FormUserPass extends PureComponent {
- constructor(props) {
- super(props);
- this.state = {
- username: '',
- password: '',
- passwordVerify: '',
- stage: props.currentUser.stage || 0,
- }
- }
- handleChange(name, value) {
- console.log("data: ", name, value);
- this.setState({ [name]: value }, () => {
- console.log(this.state);
- if ((this.state.password.length !== 0) && (this.state.password !== this.state.passwordVerify)) {
- console.log("password not match");
- return;
- }
- if ((this.state.stage === 0) && (this.state.password.length === 0)) {
- console.log("must change password");
- return;
- }
- console.log("ok");
- this.props.inputProperties.onChange(
- this.props.inputProperties.name,
- { username: this.state.username,
- password: this.state.password }
- );
- });
- }
- render() {
- // const { errorMessage } = this.props.context.getErrorMessage();
- return (
- <div className="row section-content form-group row form-funnel">
- <div className="col-md-6 col-sm-6">
- <label htmlFor="">Nom actuel d'utilisateur</label>
- <input type="text" className="form-control" id="" disabled placeholder={this.props.currentUser.displayName}/>
- </div>
- <div className="col-md-6 col-sm-6">
- <label htmlFor="">Nouveau nom d'utilisateur</label>
- <Input name="username" onChange={this.handleChange.bind(this)} value="" layout="elementOnly" placeholder="Changer le nom"/>
- </div>
- <div className="col-md-6 col-sm-6">
- <label htmlFor="">Nouveau mot de passe</label>
- <Input name="password" onChange={this.handleChange.bind(this)} value="" layout="elementOnly" placeholder="Changer de mot de passe"/>
- </div>
- <div className="col-md-6 col-sm-6">
- <label htmlFor="">Confirmer le mot de passe</label>
- <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"/>
- </div>
- </div>
- );
- }
- }
- FormUserPass.contextTypes = {
- updateCurrentValues: PropTypes.func,
- };
- registerComponent('FormUserPass', FormUserPass);
Add Comment
Please, Sign In to add comment