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