update: update register validator
This commit is contained in:
		| @@ -42,6 +42,10 @@ class RegisterPage extends React.Component { | |||||||
|         fileList_photo: [], |         fileList_photo: [], | ||||||
|  |  | ||||||
|         query: {}, |         query: {}, | ||||||
|  |         errors: { | ||||||
|  |           email_exists: '', | ||||||
|  |           phone_exists: '', | ||||||
|  |         }, | ||||||
|  |  | ||||||
|         // form |         // form | ||||||
|         confirmPassword: "", |         confirmPassword: "", | ||||||
| @@ -140,9 +144,24 @@ class RegisterPage extends React.Component { | |||||||
|         //  return message.warning("please upload photo"); |         //  return message.warning("please upload photo"); | ||||||
|         //} |         //} | ||||||
| // | // | ||||||
|         //if (this.state.upload_ktp === '') { |  | ||||||
|         //  return message.warning("please upload ktp"); |         if (this.state.phone_number === '') { | ||||||
|         //} |           return this.setState({ | ||||||
|  |             errors: { | ||||||
|  |               ...this.state.errors, | ||||||
|  |               phone_exists: 'Harap isi nomor handphone anda' | ||||||
|  |             } | ||||||
|  |           }) | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (this.state.email === '') { | ||||||
|  |          return this.setState({ | ||||||
|  |            errors: { | ||||||
|  |              ...this.state.errors, | ||||||
|  |              email_exists: 'Harap isi email anda' | ||||||
|  |            } | ||||||
|  |          }) | ||||||
|  |         } | ||||||
|  |  | ||||||
|         this.setState({ isLoading: true }); |         this.setState({ isLoading: true }); | ||||||
|  |  | ||||||
| @@ -176,7 +195,22 @@ class RegisterPage extends React.Component { | |||||||
|             if (err.type === 'BodyValidationError') { |             if (err.type === 'BodyValidationError') { | ||||||
|               message.error(err.detail[0].message); |               message.error(err.detail[0].message); | ||||||
|             } else { |             } else { | ||||||
|               message.error(err.message); |               if (err.message.toLowerCase().includes('email')) { | ||||||
|  |                 this.setState({ | ||||||
|  |                   errors: { | ||||||
|  |                     ...this.state.errors, | ||||||
|  |                     email_exists: 'Email sudah terdaftar' | ||||||
|  |                   } | ||||||
|  |                 }) | ||||||
|  |               } else if (err.message.toLowerCase().includes('phone number')) { | ||||||
|  |                 this.setState({ | ||||||
|  |                   errors: { | ||||||
|  |                     ...this.state.errors, | ||||||
|  |                     phone_exists: 'Nomer handphone sudah terdaftar' | ||||||
|  |                   } | ||||||
|  |                 }) | ||||||
|  |               } | ||||||
|  |               // message.error(err.message); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|     }; |     }; | ||||||
| @@ -300,10 +334,10 @@ class RegisterPage extends React.Component { | |||||||
|                                 <Grid item xs={5}> |                                 <Grid item xs={5}> | ||||||
|                                     <img src={require('../../../../assets/images/register_image_2.png')} width={"80%"} /> |                                     <img src={require('../../../../assets/images/register_image_2.png')} width={"80%"} /> | ||||||
|                                     <Typography style={{ color: '#FFF' }} variant={"h6"}> |                                     <Typography style={{ color: '#FFF' }} variant={"h6"}> | ||||||
|                                         Tukarkan point! |                                         Selamat Datang di BTN Shop! | ||||||
|                                     </Typography> |                                     </Typography> | ||||||
|                                     <Typography style={{ color: '#FFF' }} variant={"subtitle2"}> |                                     <Typography style={{ color: '#FFF' }} variant={"subtitle2"}> | ||||||
|                                         Dapatkan promo dan keuntungan dengan BTN |                                         Dapatkan promo dan keuntungan lebih dari BTN! | ||||||
|                                     </Typography> |                                     </Typography> | ||||||
|                                 </Grid> |                                 </Grid> | ||||||
|                             </Hidden> |                             </Hidden> | ||||||
| @@ -335,13 +369,15 @@ class RegisterPage extends React.Component { | |||||||
|                                             <Grid item xs={12} sm={12} md={6} style={{ paddingLeft: 5, paddingRight: 5 }}> |                                             <Grid item xs={12} sm={12} md={6} style={{ paddingLeft: 5, paddingRight: 5 }}> | ||||||
|                                                 <TextField |                                                 <TextField | ||||||
|                                                     id="phone" |                                                     id="phone" | ||||||
|                                                     label="Nomer Telfon" |                                                     label="Nomor Handphone" | ||||||
|                                                     value={this.state.phone_number} |                                                     value={this.state.phone_number} | ||||||
|                                                     onChange={this.handleChange('phone_number')} |                                                     onChange={this.handleChange('phone_number')} | ||||||
|                                                     margin="normal" |                                                     margin="normal" | ||||||
|                                                     type={"number"} |                                                     type={"number"} | ||||||
|                                                     variant="outlined" |                                                     variant="outlined" | ||||||
|                                                     fullWidth |                                                     fullWidth | ||||||
|  |                                                     error={!!this.state.errors.phone_exists} | ||||||
|  |                                                     helperText={this.state.errors.phone_exists} | ||||||
|                                                 /> |                                                 /> | ||||||
|                                             </Grid> |                                             </Grid> | ||||||
|  |  | ||||||
| @@ -354,6 +390,8 @@ class RegisterPage extends React.Component { | |||||||
|                                                     margin="normal" |                                                     margin="normal" | ||||||
|                                                     variant="outlined" |                                                     variant="outlined" | ||||||
|                                                     fullWidth |                                                     fullWidth | ||||||
|  |                                                     error={!!this.state.errors.email_exists} | ||||||
|  |                                                     helperText={this.state.errors.email_exists} | ||||||
|                                                 /> |                                                 /> | ||||||
|                                             </Grid> |                                             </Grid> | ||||||
|                                             <Grid item xs={12} sm={12} md={6} style={{ paddingLeft: 5, paddingRight: 5 }}> |                                             <Grid item xs={12} sm={12} md={6} style={{ paddingLeft: 5, paddingRight: 5 }}> | ||||||
| @@ -525,7 +563,7 @@ class RegisterPage extends React.Component { | |||||||
|  |  | ||||||
|                                     <Grid item xs={12} sm={12} md={12}> |                                     <Grid item xs={12} sm={12} md={12}> | ||||||
|                                       <TextField |                                       <TextField | ||||||
|                                         label="Referal" |                                         label="Kode Referal" | ||||||
|                                         value={this.state.query.referal} |                                         value={this.state.query.referal} | ||||||
|                                         onChange={event => { |                                         onChange={event => { | ||||||
|                                           this.setState({ |                                           this.setState({ | ||||||
| @@ -536,7 +574,7 @@ class RegisterPage extends React.Component { | |||||||
|                                           }) |                                           }) | ||||||
|                                         }} |                                         }} | ||||||
|                                         margin="normal" |                                         margin="normal" | ||||||
|                                         type={"text"} |                                         type={"password"} | ||||||
|                                         fullWidth |                                         fullWidth | ||||||
|                                         variant="outlined" |                                         variant="outlined" | ||||||
|                                       /> |                                       /> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user