update : loginPage
This commit is contained in:
parent
d7724bda5a
commit
8b2f3ac089
|
@ -36,7 +36,8 @@ class BTNLoginPage extends React.Component{
|
|||
password: "",
|
||||
showPassword : false,
|
||||
isLoading: false,
|
||||
loginFailed: false
|
||||
loginFailed: false,
|
||||
isNeedEmailVerification: false,
|
||||
};
|
||||
this.defaultState = Object.assign({}, this.state);
|
||||
this.authStore = props.appstate.auth;
|
||||
|
@ -63,10 +64,15 @@ class BTNLoginPage extends React.Component{
|
|||
password: password,
|
||||
}
|
||||
this.authStore.login(data).then(res => {
|
||||
setTimeout(()=>{
|
||||
this.props.history.push(LINKS.DASHBOARD);
|
||||
this.setState({isLoading:false});
|
||||
},1000);
|
||||
if(!res.need_email_verification){
|
||||
setTimeout(()=>{
|
||||
this.props.history.push(LINKS.DASHBOARD);
|
||||
this.setState({isLoading:false});
|
||||
},1000);
|
||||
}
|
||||
else{
|
||||
this.setState({isNeedEmailVerification:true});
|
||||
}
|
||||
}).catch(err => {
|
||||
this.setState({loginFailed:true,isLoading:false});
|
||||
setTimeout(()=>this.setState({loginFailed:false}),3000);
|
||||
|
@ -122,50 +128,72 @@ class BTNLoginPage extends React.Component{
|
|||
</Grid>
|
||||
</Hidden>
|
||||
<Grid item xs={12} sm={12} md={6} style={{paddingLeft : 50,paddingRight : 50}}>
|
||||
<Paper className={classes.formRegister}>
|
||||
<Typography variant="h6" gutterBottom>
|
||||
Login to BTN Point
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" gutterBottom>
|
||||
Doesn't have an account? <Link to={"/register"}>Register</Link>
|
||||
</Typography>
|
||||
<TextField
|
||||
id="email"
|
||||
label="Email"
|
||||
value={this.state.email}
|
||||
onChange={this.handleChange('email')}
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
/>
|
||||
{/*<div style={{display : 'flex',alignItems : 'center'}}>*/}
|
||||
<TextField
|
||||
id="password"
|
||||
label="Password"
|
||||
value={this.state.password}
|
||||
onChange={this.handleChange('password')}
|
||||
margin="normal"
|
||||
type={this.state.showPassword ? 'text' : 'password'}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
aria-label="Toggle password visibility"
|
||||
onClick={this.viewPassword}
|
||||
>
|
||||
{this.state.showPassword ? <VisibilityOff /> : <Visibility />}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<div style={{padding : 5,marginTop : 20}}>
|
||||
<Button onClick={() => this.login()} fullWidth variant="contained" style={{background:'#ffeb3b'}} disabled={this.state.email == '' || this.state.password == ''}>
|
||||
{this.state.isLoading ? <CircularProgress className={classes.progress} /> : "Sign In"}
|
||||
</Button>
|
||||
</div>
|
||||
</Paper>
|
||||
{
|
||||
this.state.isNeedEmailVerification &&
|
||||
<Paper className={classes.formRegister}>
|
||||
<Typography variant="h6" gutterBottom>
|
||||
Your account still need email verification
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" gutterBottom>
|
||||
Still not received any email? <Link to={"/register"}>Resend email</Link>
|
||||
</Typography>
|
||||
|
||||
<div style={{padding : 5,marginTop : 20}}>
|
||||
<Button onClick={() => this.setState({isNeedEmailVerification : false})} fullWidth variant="contained" style={{background:'#ffeb3b'}}>
|
||||
Back to Login
|
||||
</Button>
|
||||
</div>
|
||||
</Paper>
|
||||
}
|
||||
|
||||
{
|
||||
!this.state.isNeedEmailVerification &&
|
||||
<Paper className={classes.formRegister}>
|
||||
<Typography variant="h6" gutterBottom>
|
||||
Login to BTN Point
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" gutterBottom>
|
||||
Doesn't have an account? <Link to={"/register"}>Register</Link>
|
||||
</Typography>
|
||||
<TextField
|
||||
id="email"
|
||||
label="Email"
|
||||
value={this.state.email}
|
||||
onChange={this.handleChange('email')}
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
/>
|
||||
{/*<div style={{display : 'flex',alignItems : 'center'}}>*/}
|
||||
<TextField
|
||||
id="password"
|
||||
label="Password"
|
||||
value={this.state.password}
|
||||
onChange={this.handleChange('password')}
|
||||
margin="normal"
|
||||
type={this.state.showPassword ? 'text' : 'password'}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
<IconButton
|
||||
aria-label="Toggle password visibility"
|
||||
onClick={this.viewPassword}
|
||||
>
|
||||
{this.state.showPassword ? <VisibilityOff /> : <Visibility />}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<div style={{padding : 5,marginTop : 20}}>
|
||||
<Button onClick={() => this.login()} fullWidth variant="contained" style={{background:'#ffeb3b'}} disabled={this.state.email == '' || this.state.password == ''}>
|
||||
{this.state.isLoading ? <CircularProgress className={classes.progress} /> : "Sign In"}
|
||||
</Button>
|
||||
</div>
|
||||
</Paper>
|
||||
}
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
|
Loading…
Reference in New Issue
Block a user