Commit a785d23c authored by Riri Novita's avatar Riri Novita

maintenance login

parent 661acec7
...@@ -38,7 +38,10 @@ class Login extends Component { ...@@ -38,7 +38,10 @@ class Login extends Component {
tipeAlert: '', tipeAlert: '',
messageAlert: '', messageAlert: '',
width: 0, width: 0,
height: 0 height: 0,
maintenanceHeadline: "",
maintenanceContent: "",
maintenanceStatus: null,
} }
} }
...@@ -98,11 +101,16 @@ class Login extends Component { ...@@ -98,11 +101,16 @@ class Login extends Component {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
// console.log(response.data.data) // console.log(response.data.data)
if (response.data.data.role_id === 185 && response.data.maintenance_mode === 'ACTIVE'){ let datas = response.data.data
this.props.history.push('/maintenance') if (datas.maintenance_status === 1) {
this.setState({
maintenanceHeadline: datas.maintenance_headline,
maintenanceContent: datas.maintenance_content,
maintenanceStatus: datas.maintenance_status
})
} else { } else {
localStorage.setItem(Constant.TOKEN, response.data.data.token) localStorage.setItem(Constant.TOKEN, datas.token)
localStorage.setItem(Constant.USER, response.data.data.user_id) localStorage.setItem(Constant.USER, datas.user_id)
if (this.state.rememberMe) { if (this.state.rememberMe) {
localStorage.setItem(Constant.EMAIL, this.state.email) localStorage.setItem(Constant.EMAIL, this.state.email)
localStorage.setItem(Constant.PASSWORD, this.state.password) localStorage.setItem(Constant.PASSWORD, this.state.password)
...@@ -113,6 +121,7 @@ class Login extends Component { ...@@ -113,6 +121,7 @@ class Login extends Component {
} }
this.props.history.push('/home/beranda') this.props.history.push('/home/beranda')
} }
} else { } else {
if (response.data.message == 'Password is Not Correct') { if (response.data.message == 'Password is Not Correct') {
this.setState({ errorPassword: true, msgPassword: 'Incorrect Password' }) this.setState({ errorPassword: true, msgPassword: 'Incorrect Password' })
...@@ -149,18 +158,24 @@ class Login extends Component { ...@@ -149,18 +158,24 @@ class Login extends Component {
</Alert> </Alert>
</Snackbar> </Snackbar>
<div style={{ width: '50%', display: 'grid' }}> <div style={{ width: '50%', display: 'grid' }}>
<img src={Images.meeting} style={{ objectFit: 'fill', width: '100%', height: '100%' }}/> <img src={Images.meeting} style={{ objectFit: 'fill', width: '100%', height: '100%' }} />
{/* <img src={Images.imageLogin} style={{ marginTop: 30 }} /> */} {/* <img src={Images.imageLogin} style={{ marginTop: 30 }} /> */}
</div> </div>
<div style={{ width: '50%', height: '100vh', backgroundColor: '#263b80', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}> <div style={{ width: '50%', height: '100vh', backgroundColor: '#263b80', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}>
{this.state.maintenanceStatus === 1 ?
<div>
<Typography style={{ color: '#fff', fontSize: 20, margin: '10px 40px'}}>{this.state.maintenanceHeadline}</Typography>
<Typography style={{ color: '#fff', fontSize: 20, margin: 40}}>{this.state.maintenanceContent}</Typography>
</div>
:
<form onSubmit={(e) => { <form onSubmit={(e) => {
e.preventDefault() e.preventDefault()
this.validateLogin() this.validateLogin()
}} }}
> >
<div style={{ maxWidth: 397, paddingTop: 56, padding: 65, display: 'flex', flexDirection: 'column', height: (this.state.msgEmail.length > 45 ? 485 : 441), borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff' }}> <div style={{ maxWidth: 397, paddingTop: 56, padding: 65, display: 'flex', flexDirection: 'column', height: (this.state.msgEmail.length > 45 ? 485 : 441), borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff' }}>
<img src={Images.triputraBlack} style={{ height: 59, width: 175, alignSelf: 'center'}} /> <img src={Images.triputraBlack} style={{ height: 59, width: 175, alignSelf: 'center' }} />
<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>}
...@@ -230,6 +245,7 @@ class Login extends Component { ...@@ -230,6 +245,7 @@ class Login extends Component {
</button> </button>
</div> </div>
</form> </form>
}
</div> </div>
</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