feat: translate, fix otp

This commit is contained in:
ahmadzuhdi 2019-02-01 14:14:30 +07:00
parent a4974f0bb0
commit 2cf1761b80
3 changed files with 64 additions and 52 deletions

View File

@ -95,7 +95,7 @@ class OtpPage extends React.Component{
let data = { let data = {
code : this.state.otpText, code : this.state.otpText,
login_request_id : this.state.otpData.login_request_id login_request_id : this.state.otpData.login_request_id
} };
console.log("data",data); console.log("data",data);
this.setState({isLoading:true}); this.setState({isLoading:true});
// if(this.checkIsExpired){ // if(this.checkIsExpired){
@ -105,19 +105,19 @@ class OtpPage extends React.Component{
// },2000); // },2000);
// } // }
// else{ // else{
this.authStore.validateOtp(data).then(res=>{ // this.authStore.validateOtp(data).then(res=>{
setTimeout(()=>{ // setTimeout(()=>{
this.props.history.push(LINKS.DASHBOARD); // this.props.history.push(LINKS.DASHBOARD);
this.setState({isLoading:false}); // this.setState({isLoading:false});
},1000); // },1000);
}).catch(err=>{ // }).catch(err=>{
setTimeout(()=>{ // setTimeout(()=>{
this.setState({isLoading:false,isOtpWrong:true}); // this.setState({isLoading:false,isOtpWrong:true});
},2000); // },2000);
setTimeout(()=>{ // setTimeout(()=>{
this.setState({isOtpWrong:false}); // this.setState({isOtpWrong:false});
},4000) // },4000)
}); // });
// } // }
}; };
@ -133,7 +133,7 @@ class OtpPage extends React.Component{
ContentProps={{ ContentProps={{
'aria-describedby': 'message-id', 'aria-describedby': 'message-id',
}} }}
message={<span id="message-id">Wrong OTP code</span>} message={<span id="message-id">Kode OTP Salah</span>}
/> />
<Snackbar <Snackbar
anchorOrigin={{ vertical : 'top', horizontal: 'center' }} anchorOrigin={{ vertical : 'top', horizontal: 'center' }}
@ -142,7 +142,7 @@ class OtpPage extends React.Component{
ContentProps={{ ContentProps={{
'aria-describedby': 'message-id', 'aria-describedby': 'message-id',
}} }}
message={<span id="message-id">Your OTP code has expired</span>} message={<span id="message-id">Kode OTP sudah tidak berlaku</span>}
/> />
<Snackbar <Snackbar
anchorOrigin={{ vertical : 'top', horizontal: 'center' }} anchorOrigin={{ vertical : 'top', horizontal: 'center' }}
@ -151,7 +151,7 @@ class OtpPage extends React.Component{
ContentProps={{ ContentProps={{
'aria-describedby': 'message-id', 'aria-describedby': 'message-id',
}} }}
message={<span id="message-id">OTP Code Re-sended</span>} message={<span id="message-id">Kode OTP sudah di kirim ulang</span>}
/> />
<Grid container spacing={0} className={classes.gridContainer}> <Grid container spacing={0} className={classes.gridContainer}>
<Grid item xs={12} className={classes.logoContainer}> <Grid item xs={12} className={classes.logoContainer}>
@ -162,16 +162,22 @@ class OtpPage extends React.Component{
<Grid item xs={12} sm={12} md={6} style={{paddingLeft : 50,paddingRight : 50}}> <Grid item xs={12} sm={12} md={6} style={{paddingLeft : 50,paddingRight : 50}}>
<Paper className={classes.formRegister}> <Paper className={classes.formRegister}>
<Typography variant="h6" gutterBottom> <Typography variant="h6" gutterBottom>
Input Your OTP Code Masukkan Kode OTP Anda
</Typography>
<Typography variant="subtitle2" gutterBottom>
Still not received OTP Code? <a onClick={()=>this.resendCode()}>Resend Code</a>
</Typography> </Typography>
{/*<Typography variant="subtitle2" gutterBottom>*/}
{/*Still not received OTP Code? <a onClick={()=>this.resendCode()}>Resend Code</a>*/}
{/*</Typography>*/}
<Grid container justify="center" spacing={8}> <Grid container justify="center" spacing={8}>
{[0, 1, 2, 3, 4, 5].map(x => ( {[0, 1, 2, 3, 4, 5].map(x => (
<Grid item xs={1}> <Grid item xs={1}>
<Text onChange={event => { <Text
onKeyDown={event => {
if (event.keyCode === 8 && x > 0 && event.target.value.length === 0) {
this.otp[x-1].focus();
}
}}
onChange={event => {
// console.log(event);
if (event.target.value !== '') { if (event.target.value !== '') {
this.setState({otpText:this.state.otpText+event.target.value}, () => { this.setState({otpText:this.state.otpText+event.target.value}, () => {
if (x < 5) { if (x < 5) {
@ -186,13 +192,18 @@ class OtpPage extends React.Component{
this.setState({otpText:otpText.join("")}); this.setState({otpText:otpText.join("")});
} }
}} autoFocus={x === 0} ref={(input) => { this.otp[x] = input; }} key={x} id={x} inputStyle={{textAlign:'center'}} style={{width:'100%'}} type="tel" maxLength="1"/> }}
autoFocus={x === 0}
ref={(input) => { this.otp[x] = input; }}
key={x}
id={x}
inputStyle={{textAlign:'center'}} style={{width:'100%'}} type="tel" maxLength="1"/>
</Grid> </Grid>
))} ))}
</Grid> </Grid>
<div style={{padding : 5,marginTop : 20}}> <div style={{padding : 5,marginTop : 20}}>
<Button onClick={() => this.login()} fullWidth variant="contained" style={{background:'#ffeb3b'}} disabled={this.state.otpText.length < 6}> <Button onClick={() => this.login()} fullWidth variant="contained" style={{background:'#ffeb3b'}} disabled={this.state.otpText.length < 6}>
{this.state.isLoading ? <CircularProgress className={classes.progress} /> : "Sign In"} {this.state.isLoading ? <CircularProgress className={classes.progress} /> : "Konfirmasi"}
</Button> </Button>
</div> </div>
</Paper> </Paper>

View File

@ -75,31 +75,32 @@ export default class RegisterCompletedComponent extends React.Component{
<Grid item xs={6}> <Grid item xs={6}>
<img src={require('../../../../assets/images/login/register_image_2.png')} width={"80%"}/> <img src={require('../../../../assets/images/login/register_image_2.png')} width={"80%"}/>
<Typography style={{color : '#FFF'}} variant={"h6"}> <Typography style={{color : '#FFF'}} variant={"h6"}>
Welcome to BTN Points Selamat Datang di BTN Point
</Typography> </Typography>
<Typography style={{color : '#FFF'}} variant={"subtitle2"}> <Typography style={{color : '#FFF'}} variant={"subtitle2"}>
Sign in to get various voucher and items Daftar untuk mendapatkan berbagai macam manfaat dan keuntungan
</Typography> </Typography>
</Grid> </Grid>
</Hidden> </Hidden>
<Grid item xs={12} sm={12} md={6} style={{paddingLeft : 50,paddingRight : 50}}> <Grid item xs={12} sm={12} md={6} style={{paddingLeft : 50,paddingRight : 50}}>
<Paper className={classes.formRegister}> <Paper className={classes.formRegister}>
<Typography variant="h6" gutterBottom> <Typography variant="h6" gutterBottom>
Registration Completed Pendaftaran Berhasil
</Typography> </Typography>
<Typography variant="body1" gutterBottom> <Typography variant="body1" gutterBottom>
We have sent an email with a confirmation link to your email address. Please allow 5-10 minutes for this message to arrive. Kami telah mengirim sebuah surat elektronik yang berisi tautan untuk konfirmasi pendaftaran ke email anda, harap menunggu 5 sampai 10 menit untuk surat sampai
{/*We have sent an email with a confirmation link to your email address. Please allow 5-10 minutes for this message to arrive.*/}
</Typography> </Typography>
<div style={{padding : 5,marginTop : 20}}> {/*<div style={{padding : 5,marginTop : 20}}>*/}
<Link {/*<Link*/}
to={LINKS.LOGIN}> {/*to={LINKS.LOGIN}>*/}
<Button fullWidth variant="contained" style={{background:'#ffeb3b'}}> {/*<Button fullWidth variant="contained" style={{background:'#ffeb3b'}}>*/}
Back to Login {/*Back to Login*/}
</Button> {/*</Button>*/}
</Link> {/*</Link>*/}
</div> {/*</div>*/}
</Paper> </Paper>
</Grid> </Grid>

View File

@ -300,10 +300,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"}>
Redeem point, Get Your Item! Tukarkan point!
</Typography> </Typography>
<Typography style={{ color: '#FFF' }} variant={"subtitle2"}> <Typography style={{ color: '#FFF' }} variant={"subtitle2"}>
Get promo and benefits with BTN Dapatkan promo dan keuntungan dengan BTN
</Typography> </Typography>
</Grid> </Grid>
</Hidden> </Hidden>