Commit 549b29fe authored by EKSAD's avatar EKSAD

Login

parent 848655b9
...@@ -5,6 +5,7 @@ import { withStyles } from '@material-ui/core/styles'; ...@@ -5,6 +5,7 @@ import { withStyles } from '@material-ui/core/styles';
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'; import api from '../api';
import { Redirect } from 'react-router-dom';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -30,20 +31,21 @@ class Login extends Component { ...@@ -30,20 +31,21 @@ class Login extends Component {
// this.coba() // this.coba()
} }
coba(e) { handleChange(e) {
this.setState({ let data = this.state
username: e this.setState({...data, [e.target.name] : e.target.value})
})
} }
login() { login() {
let payload = { let payload = {
"username": this.state.username, "username": this.state.username,
"password": "admin" "password": this.state.password
} }
api.create().login(payload).then((response) => { api.create().login(payload).then((response) => {
console.log(response.data) if (response.data.status === 'success') {
this.props.history.replace('/home')
// console.log(response.data)
}
}) })
} }
...@@ -55,7 +57,7 @@ class Login extends Component { ...@@ -55,7 +57,7 @@ class Login extends Component {
<img src={Images.imageLogin} style={{ marginTop: 30 }} /> <img src={Images.imageLogin} style={{ marginTop: 30 }} />
</div> </div>
<div style={{ width: '50%', height: '100vh', backgroundColor: '#51c6ea', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}> <div style={{ width: '50%', height: '100vh', backgroundColor: '#51c6ea', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}>
<div style={{ padding: 60, display: 'flex', flexDirection: 'column', width: 318, height: 351, borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff' }}> <div style={{ paddingTop: 56, paddingLeft: 64, paddingRight: 64, display: 'flex', flexDirection: 'column', width: 378, height: 431, borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff' }}>
<img src={Images.tia} /> <img src={Images.tia} />
<TextField <TextField
...@@ -64,10 +66,10 @@ class Login extends Component { ...@@ -64,10 +66,10 @@ class Login extends Component {
type={"text"} type={"text"}
name={"username"} name={"username"}
value={this.state.username} value={this.state.username}
onChange={(e) => this.setState({username: e.target.value})} onChange={(username) => this.handleChange(username)}
variant="outlined" variant="outlined"
error={false} error={false}
style={{ width: '100%', height: 51, marginTop: 32, fontSize: 14 }} style={{ width: 250, height: 51, marginTop: 32, fontSize: 14 }}
helperText="" helperText=""
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>, endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>,
...@@ -79,9 +81,11 @@ class Login extends Component { ...@@ -79,9 +81,11 @@ class Login extends Component {
id="password" id="password"
type={this.state.showPass ? 'text' : 'password'} type={this.state.showPass ? 'text' : 'password'}
name={"password"} name={"password"}
value={this.state.password}
onChange={(password) => this.handleChange(password) }
variant="outlined" variant="outlined"
error={false} error={false}
style={{ width: '100%', height: 51, marginTop: 20 }} style={{ width: 250, height: 51, marginTop: 20 }}
helperText="" helperText=""
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end"> endAdornment: <InputAdornment position="end">
...@@ -99,10 +103,10 @@ class Login extends Component { ...@@ -99,10 +103,10 @@ class Login extends Component {
<div style={{ flexDirection: 'row', width: '100%', marginTop: 16 }}> <div style={{ flexDirection: 'row', width: '100%', marginTop: 16 }}>
<CustomCheckbox name="checked-remember" /> <CustomCheckbox name="checked-remember" />
<span style={{ color: 'rgba(0, 0, 0, 0.5)' }}>Remember Me</span> <span style={{ color: 'rgba(0, 0, 0, 0.5)', fontSize: 12 }}>Remember Me</span>
<span style={{marginLeft: 30, color: '#51c6ea', cursor: 'pointer' }}>Lupa Kata Sandi?</span> <span style={{marginLeft: 30, color: '#51c6ea', cursor: 'pointer', fontSize: 12 }}>Lupa Kata Sandi?</span>
</div> </div>
<Button variant="contained" onClick={() => this.login()} style={{ marginTop: 23, width: '100%', height: 35, borderRadius: 4 }}> <Button name="submit" variant="contained" onClick={() => this.login()} style={{ marginTop: 23, width: '100%', height: 35, borderRadius: 4 }}>
<Typography style={{fontSize: 12}}>Login</Typography> <Typography style={{fontSize: 12}}>Login</Typography>
</Button> </Button>
</div> </div>
......
...@@ -7,22 +7,18 @@ class ResetPassword extends Component { ...@@ -7,22 +7,18 @@ class ResetPassword extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
username: '', username: ''
password: ''
} }
} }
user(username) { handleChange(e) {
this.setState({ let data = this.state
username: username this.setState({...data, [e.target.name] : e.target.value})
}) }
}
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' }}>
<div style={{padding: 60, display: 'flex', flexDirection: 'column', width: 318, height: 250, borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff', justifyContent: 'center', alignItems: 'center' }}> <div style={{padding: 60, display: 'flex', flexDirection: 'column', width: 378, height: 351, borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff', justifyContent: 'center', alignItems: 'center' }}>
<img src={Images.tia} /> <img src={Images.tia} />
<TextField <TextField
...@@ -34,14 +30,14 @@ class ResetPassword extends Component { ...@@ -34,14 +30,14 @@ class ResetPassword extends Component {
onChange={(username) => this.setState({username: username.target.value})} onChange={(username) => this.setState({username: username.target.value})}
variant="outlined" variant="outlined"
error={false} error={false}
style={{ width: '90%', height: 51, marginTop: 32, fontSize: 14 }} style={{ width: 250, height: 51, marginTop: 32, fontSize: 14 }}
helperText="" helperText=""
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>, endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>,
}} }}
/> />
<Button variant="contained" style={{ marginTop: 23, width: '90%', height: 30, borderRadius: 4 }} disabled> <Button variant="contained" style={{ marginTop: 23, width: 250, height: 30, borderRadius: 4 }} disabled>
<Typography style={{fontSize: 12}}>Lanjut</Typography> <Typography style={{fontSize: 12}}>Lanjut</Typography>
</Button> </Button>
......
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