From 960fd816d3fd0e6039629ae95fe7c470f04ae96c Mon Sep 17 00:00:00 2001 From: Arnaz Date: Fri, 15 Sep 2017 23:01:45 +0700 Subject: [PATCH] add prefill data from social media --- app/containers/RegisterEmail/index.js | 57 +++++++++++++++++++-------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/app/containers/RegisterEmail/index.js b/app/containers/RegisterEmail/index.js index 6dfa7e70..fb56d595 100644 --- a/app/containers/RegisterEmail/index.js +++ b/app/containers/RegisterEmail/index.js @@ -56,7 +56,7 @@ class RegisterEmail extends Component { } componentWillUnmount() { - this.props.resetState() + this.props.resetState(); } onAlertOk = () => { @@ -133,9 +133,15 @@ class RegisterEmail extends Component { error_phone } = errorFields || false; + + const socialId = typeof this.props.prefilledData !== 'undefined' ? this.props.prefilledData.social_id : null; + const first = typeof this.props.prefilledData !== 'undefined' || '' ? this.props.prefilledData.first_name : text => this.handleInputChange('first_name', text); + const last = typeof this.props.prefilledData !== 'undefined' || '' ? this.props.prefilledData.last_name : text => this.handleInputChange('last_name', text); + const emails = typeof this.props.prefilledData !== 'undefined' || '' ? this.props.prefilledData.email : text => this.handleInputChange('email', text); + const checkEmail = this.checkEmail(email) === false && email !== ''; - const checkUsername = username.length < 4 && username !== ''; - const checkPassword = password.length < 4 && password !== ''; + //const checkUsername = username.length < 4 && username !== ''; + //const checkPassword = password.length < 4 && password !== ''; return ( @@ -143,55 +149,74 @@ class RegisterEmail extends Component { - this.handleInputChange('first_name', text)} value={first_name} - /> - : this.handleInputChange('first_name', text)} + value={first} + />} + {socialId === null ? this.handleInputChange('last_name', text)} value={last_name} - /> + /> : this.handleInputChange('last_name', text)} + value={last} + />} { checkEmail ? invalid email address : null } - this.handleInputChange('email', text)} value={email} - /> - { checkUsername ? + /> : this.handleInputChange('email', text)} + value={emails} + />} + {/* { checkUsername !== 'undefined' ? username should be 4 at minimum : null - } + } */} this.handleInputChange('username', text)} value={username} /> - { checkPassword ? + {/* { checkPassword ? password should be 4 at minimum : null - } + } */} - {(username.length < 4 || password.length < 4 || first_name === '' || last_name === '') || (this.checkEmail(email) === false && email !== '') ? + {(password.length < 4 || first_name === '' || last_name === '') || (this.checkEmail(email) === false && email !== '') ?