Commit b09304c3 authored by EKSAD's avatar EKSAD

reset update

parent cc4f8884
...@@ -63,6 +63,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -63,6 +63,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
//Auth //Auth
const login = (body) => api.post('auth/login', body) const login = (body) => api.post('auth/login', body)
const resetPassword = (body) => api.post('auth/reset_password', body)
const verification = (body) => api.post('email/reset_password', body) const verification = (body) => api.post('email/reset_password', body)
//Role //Role
...@@ -91,6 +92,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -91,6 +92,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
getRoot, getRoot,
login, login,
verification, verification,
resetPassword,
getRole, getRole,
getDetailRole, getDetailRole,
addRole, addRole,
......
...@@ -56,7 +56,7 @@ class ForgotPassword extends Component { ...@@ -56,7 +56,7 @@ class ForgotPassword extends Component {
<TextField <TextField
label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Email *</Typography>} label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Email *</Typography>}
id="email" id="email"
type={"text"} type={"email"}
name={"email"} name={"email"}
value={this.state.email} value={this.state.email}
onChange={(email) => { onChange={(email) => {
......
...@@ -3,6 +3,7 @@ import Images from '../assets/Images'; ...@@ -3,6 +3,7 @@ import Images from '../assets/Images';
import { TextField, InputAdornment, Button, Typography, IconButton } from '@material-ui/core'; import { TextField, InputAdornment, Button, Typography, IconButton } from '@material-ui/core';
import Visibility from '@material-ui/icons/Visibility'; import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff'; import VisibilityOff from '@material-ui/icons/VisibilityOff';
import api from '../api';
class ResetPassword extends Component { class ResetPassword extends Component {
...@@ -13,6 +14,10 @@ class ResetPassword extends Component { ...@@ -13,6 +14,10 @@ class ResetPassword extends Component {
confirmPassword: '', confirmPassword: '',
showPass: false, showPass: false,
showPass2: false, showPass2: false,
errorPassword: false,
errorConfirmPassword: false,
msgPassword: '',
msgConfirmPassword: '',
userId: 0 userId: 0
} }
} }
...@@ -21,6 +26,7 @@ class ResetPassword extends Component { ...@@ -21,6 +26,7 @@ class ResetPassword extends Component {
console.log(this.props.match.params.id) console.log(this.props.match.params.id)
let userId = this.props.match.params.id let userId = this.props.match.params.id
this.setState({userId}) this.setState({userId})
// console.log(this.props)
} }
confirmPassword() { confirmPassword() {
...@@ -29,13 +35,26 @@ class ResetPassword extends Component { ...@@ -29,13 +35,26 @@ class ResetPassword extends Component {
"confirmPassword": this.state.confirmPassword, "confirmPassword": this.state.confirmPassword,
"userId": this.state.userId "userId": this.state.userId
} }
api.create().confirmPassword(payload).then((response) => {
if(response.data.status === 'success') {
alert('success')
this.props.history.push('/login')
} else {
alert(response.data.message)
}
})
} }
handleChange(e) { handleChange(e) {
let data = this.state let data = this.state
this.setState({...data, [e.target.name] : e.target.value}) this.setState({...data, [e.target.name] : e.target.value})
if (e.target.name == "password") {
this.setState({ errorPassword: false, msgPassword: '' })
} else if (e.target.name) {
this.setState({ errorConfirmPassword: false, msgConfirmPassword: '' })
}
} }
render() { render() {
return ( return (
<div style={{ flex: 1, display: 'flex', backgroundColor: '#51c6ea', height: '100vh', justifyContent: 'center', alignItems: 'center' }}> <div style={{ flex: 1, display: 'flex', backgroundColor: '#51c6ea', height: '100vh', justifyContent: 'center', alignItems: 'center' }}>
...@@ -48,9 +67,11 @@ class ResetPassword extends Component { ...@@ -48,9 +67,11 @@ class ResetPassword extends Component {
type={this.state.showPass ? 'text' : 'password'} type={this.state.showPass ? 'text' : 'password'}
name={"password"} name={"password"}
value={this.state.password} value={this.state.password}
onChange={(password) => this.handleChange(password) } onChange={(password) => {
this.handleChange(password)
}}
variant="outlined" variant="outlined"
error={false} error={this.state.errorPassword}
style={{ width: 250, height: 51, marginTop: 32 }} style={{ width: 250, height: 51, marginTop: 32 }}
helperText={<Typography style={{fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif'}}>Terdiri 8 karakter dengan kombinasi angka.</Typography>} helperText={<Typography style={{fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif'}}>Terdiri 8 karakter dengan kombinasi angka.</Typography>}
InputProps={{ InputProps={{
...@@ -73,10 +94,12 @@ class ResetPassword extends Component { ...@@ -73,10 +94,12 @@ class ResetPassword extends Component {
type={this.state.showPass2 ? 'text' : 'password'} type={this.state.showPass2 ? 'text' : 'password'}
name={"confirmPassword"} name={"confirmPassword"}
value={this.state.confirmPassword} value={this.state.confirmPassword}
onChange={(confirmPassword) => this.handleChange(confirmPassword) } onChange={(confirmPassword) => {
this.handleChange(confirmPassword)
}}
variant="outlined" variant="outlined"
error={false} error={this.state.errorConfirmPassword}
style={{ width: 250, height: 51, marginTop: 38 }} style={{ width: 250, height: 51, marginTop: 30 }}
helperText={<Typography style={{fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif'}}>Terdiri 8 karakter dengan kombinasi angka.</Typography>} helperText={<Typography style={{fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif'}}>Terdiri 8 karakter dengan kombinasi angka.</Typography>}
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end"> endAdornment: <InputAdornment position="end">
...@@ -92,7 +115,7 @@ class ResetPassword extends Component { ...@@ -92,7 +115,7 @@ class ResetPassword extends Component {
}} }}
/> />
<Button variant="contained" style={{ marginTop: 50, width: 250, height: 30, borderRadius: 4, backgroundColor: '#51c6ea' }}> <Button name="submit" variant="contained" disabled={this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? true : false} onClick={() => this.confirmPassword()} style={{ marginTop: 30, width: '100%', height: 35, borderRadius: 4, color: this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.password.trim() == '' && this.state.confirmPassword.trim() == '' ? '#d8d8d8' : '#51c6ea' }}>
<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Lanjut</Typography> <Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Lanjut</Typography>
</Button> </Button>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment