Commit 4c88492d authored by faisalhamdi's avatar faisalhamdi

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into faisal

parents 8545d37a 0eb344cf
import React, { Component } from 'react'; import React, { Component } from 'react';
import Images from '../assets/Images'; import Images from '../assets/Images';
import { TextField, InputAdornment, Button, Typography } from '@material-ui/core'; import { TextField, InputAdornment, Button, Typography, Snackbar } from '@material-ui/core';
import api from '../api'; import api from '../api';
import Constant from '../library/Constant'; import Constant from '../library/Constant';
import MuiAlert from '@material-ui/lab/Alert';
import { withStyles } from '@material-ui/core/styles';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class ForgotPassword extends Component { class ForgotPassword extends Component {
constructor(props) { constructor(props) {
...@@ -11,7 +15,10 @@ class ForgotPassword extends Component { ...@@ -11,7 +15,10 @@ class ForgotPassword extends Component {
this.state = { this.state = {
email: '', email: '',
errorEmail: false, errorEmail: false,
msgEmail: '' msgEmail: '',
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -46,18 +53,35 @@ class ForgotPassword extends Component { ...@@ -46,18 +53,35 @@ class ForgotPassword extends Component {
"email": this.state.email "email": this.state.email
} }
api.create().verification(payload).then((response) => { api.create().verification(payload).then((response) => {
if (response.data) {
if (response.ok) {
if(response.data.status === 'success') { if(response.data.status === 'success') {
this.props.history.push('/email-verification') this.props.history.push('/email-verification')
} else { } else {
this.setState({ errorEmail: true, msgEmail: response.data.message }) this.setState({ errorEmail: true, msgEmail: response.data.message })
} }
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
return ( return (
<div style={{ flex: 1, display: 'flex', backgroundColor: '#152d40', height: '100vh', justifyContent: 'center', alignItems: 'center' }}> <div style={{ flex: 1, display: 'flex', backgroundColor: '#152d40', height: '100vh', 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' }}> <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{padding: 60, display: 'flex', flexDirection: 'column', width: (this.state.msgEmail.length > 45 ? 403 : 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
...@@ -78,7 +102,7 @@ class ForgotPassword extends Component { ...@@ -78,7 +102,7 @@ class ForgotPassword extends Component {
}} }}
/> />
<Button name="submit" variant="contained" disabled={this.state.email.trim() === '' ? true : false} onClick={() => this.validateEmail()} style={{ marginTop: this.state.errorEmail ? 35 : 23, width: '100%', height: 30, borderRadius: 4, color: this.state.email.trim() === '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.email.trim() === '' ? '#d8d8d8' : '#51c6ea' }}> <Button name="submit" variant="contained" disabled={this.state.email.trim() === '' ? true : false} onClick={() => this.validateEmail()} style={{ marginTop: this.state.errorEmail ? (this.state.msgEmail.length > 45 ? 60 : 35) : 23, width: '100%', height: 30, borderRadius: 4, color: this.state.email.trim() === '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.email.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>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import Images from '../assets/Images'; import Images from '../assets/Images';
import { Checkbox, Button, InputAdornment, TextField, InputLabel, Typography, IconButton } from '@material-ui/core'; import { Checkbox, Button, InputAdornment, TextField, Typography, IconButton, Snackbar } from '@material-ui/core';
import { withStyles } from '@material-ui/core/styles'; 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 MuiAlert from '@material-ui/lab/Alert';
import api from '../api'; import api from '../api';
import Constant from '../library/Constant'; import Constant from '../library/Constant';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
...@@ -18,6 +19,9 @@ const CustomCheckbox = withStyles({ ...@@ -18,6 +19,9 @@ const CustomCheckbox = withStyles({
checked: {}, checked: {},
})((props) => <Checkbox color="default" {...props} />); })((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class Login extends Component { class Login extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -29,7 +33,10 @@ class Login extends Component { ...@@ -29,7 +33,10 @@ class Login extends Component {
errorPassword: false, errorPassword: false,
msgEmail: '', msgEmail: '',
msgPassword: '', msgPassword: '',
rememberMe: false rememberMe: false,
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -68,6 +75,10 @@ class Login extends Component { ...@@ -68,6 +75,10 @@ class Login extends Component {
} }
} }
closeAlert() {
this.setState({ alert: false })
}
login() { login() {
console.log('login'); console.log('login');
let payload = { let payload = {
...@@ -76,6 +87,7 @@ class Login extends Component { ...@@ -76,6 +87,7 @@ class Login extends Component {
} }
api.create().login(payload).then((response) => { api.create().login(payload).then((response) => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
console.log(response.data.data) console.log(response.data.data)
localStorage.setItem(Constant.TOKEN, response.data.data.token) localStorage.setItem(Constant.TOKEN, response.data.data.token)
...@@ -97,7 +109,10 @@ class Login extends Component { ...@@ -97,7 +109,10 @@ class Login extends Component {
} }
} }
} else { } else {
alert(response.problem) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -116,6 +131,11 @@ class Login extends Component { ...@@ -116,6 +131,11 @@ class Login extends Component {
render() { render() {
return ( return (
<div style={{ flex: 1, display: 'flex' }}> <div style={{ flex: 1, display: 'flex' }}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{ width: '50%', height: '100vh', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}> <div style={{ width: '50%', height: '100vh', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}>
<img src={Images.tia} /> <img src={Images.tia} />
<img src={Images.imageLogin} style={{ marginTop: 30 }} /> <img src={Images.imageLogin} style={{ marginTop: 30 }} />
......
...@@ -19,7 +19,7 @@ export default class CreateParameter extends Component { ...@@ -19,7 +19,7 @@ export default class CreateParameter extends Component {
minValue: null, minValue: null,
maxValue: null, maxValue: null,
startDate: '', startDate: '',
endDate: '', endDate: null,
date: new Date(), date: new Date(),
approvedBy: null, approvedBy: null,
getApprovedBy: null, getApprovedBy: null,
...@@ -40,6 +40,10 @@ export default class CreateParameter extends Component { ...@@ -40,6 +40,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorValue: '', msgErrorValue: '',
...@@ -217,6 +221,10 @@ export default class CreateParameter extends Component { ...@@ -217,6 +221,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorValue: '', msgErrorValue: '',
...@@ -237,6 +245,10 @@ export default class CreateParameter extends Component { ...@@ -237,6 +245,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorValue: '', msgErrorValue: '',
...@@ -258,6 +270,10 @@ export default class CreateParameter extends Component { ...@@ -258,6 +270,10 @@ export default class CreateParameter extends Component {
errorMaxValue: false, errorMaxValue: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '', msgErrorParameter: '',
msgErrorDeskripsi: '', msgErrorDeskripsi: '',
msgErrorValue: '', msgErrorValue: '',
...@@ -270,11 +286,36 @@ export default class CreateParameter extends Component { ...@@ -270,11 +286,36 @@ export default class CreateParameter extends Component {
} }
} }
clearMessage() {
this.setState({
errorParameter: false,
errorDeskripsi: false,
errorValue: false,
errorMinValue: false,
errorOrder: false,
errorMaxValue: false,
errorStartDate: false,
errorEndDate: false,
errorGroup: false,
errorPerusahaan: false,
msgErrorPerusahaan: '',
msgErrorGroup: '',
msgErrorParameter: '',
msgErrorDeskripsi: '',
msgErrorValue: '',
msgErrorMinValue: '',
msgErrorOrder: '',
msgErrorMaxValue: '',
msgErrorStartDate: '',
msgErrorEndDate: ''
})
}
handleChangeCreate(e, type) { handleChangeCreate(e, type) {
let data = this.state let data = this.state
let isDate = type !== '' ? true : false let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') { if (isDate && type == 'start_date') {
this.setState({ startDate: format(e, 'yyyy-MM-dd') }, () => { this.setState({ startDate: format(e, 'yyyy-MM-dd'), endDate: null }, () => {
console.log(this.state.startDate) console.log(this.state.startDate)
}) })
} else if (isDate && type == 'end_date') { } else if (isDate && type == 'end_date') {
...@@ -282,22 +323,28 @@ export default class CreateParameter extends Component { ...@@ -282,22 +323,28 @@ export default class CreateParameter extends Component {
console.log(this.state.endDate) console.log(this.state.endDate)
}) })
} else { } else {
this.setState({ ...data, [e.target.name]: e.target.value }) this.setState({ ...data, [e.target.name]: e.target.value }, () => this.clearMessage())
} }
} }
validasi() { validasi() {
if (R.isEmpty(this.state.tempData.description)) { if (R.isNil(this.state.getParameter)) {
this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' }) this.setState({ errorParameter: true, msgErrorParameter: 'Parameter tidak boleh kosong' })
} else if (R.isEmpty(this.state.tempData.value)) { } else if (R.isNil(this.state.getTypes)) {
this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' }) this.setState({ errorGroup: true, msgErrorGroup: 'Group tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.min_value)) { } else if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Perusahaan tidak boleh kosong' })
// } else if (R.isEmpty(this.state.tempData.description)) {
// this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
// } else if (R.isEmpty(this.state.tempData.value)) {
// this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if (!R.isNil(this.state.tempData.max_value) && R.isNil(this.state.tempData.min_value)) {
this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' }) this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.start_date)) { } else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' }) this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.order)) { // } else if (R.isNil(this.state.tempData.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' }) // this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.max_value)) { } else if (!R.isNil(this.state.tempData.min_value) && R.isNil(this.state.tempData.max_value)) {
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' }) this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' })
} else if (R.isNil(this.state.tempData.end_date)) { } else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' }) this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' })
...@@ -307,17 +354,23 @@ export default class CreateParameter extends Component { ...@@ -307,17 +354,23 @@ export default class CreateParameter extends Component {
} }
validasiCreate() { validasiCreate() {
if (R.isEmpty(this.state.description)) { if (R.isNil(this.state.getTypes)) {
this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' }) this.setState({ errorGroup: true, msgErrorGroup: 'Group tidak boleh kosong' })
} else if (R.isEmpty(this.state.value)) { } else if (R.isNil(this.state.getParameter)) {
this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' }) this.setState({ errorParameter: true, msgErrorParameter: 'Parameter tidak boleh kosong' })
} else if (R.isNil(this.state.minValue)) { } else if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Perusahaan tidak boleh kosong' })
// } else if (R.isEmpty(this.state.description)) {
// this.setState({ errorDeskripsi: true, msgErrorDeskripsi: 'Deskripsi tidak boleh kosong' })
// } else if (R.isNil(this.state.value)) {
// this.setState({ errorValue: true, msgErrorValue: 'Value tidak boleh kosong' })
} else if (!R.isNil(this.state.maxValue) && R.isNil(this.state.minValue)) {
this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' }) this.setState({ errorMinValue: true, msgErrorMinValue: 'Min Value tidak boleh kosong' })
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' }) this.setState({ errorStartDate: true, msgErrorStartDate: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.order)) { // } else if (R.isNil(this.state.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' }) // this.setState({ errorOrder: true, msgErrorOrder: 'Order tidak boleh kosong' })
} else if (R.isNil(this.state.maxValue)) { } else if (!R.isNil(this.state.minValue) && R.isNil(this.state.maxValue)) {
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' }) this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Max Value tidak boleh kosong' })
} else if (R.isNil(this.state.endDate)) { } else if (R.isNil(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' }) this.setState({ errorEndDate: true, msgErrorEndDate: 'End Date tidak boleh kosong' })
...@@ -382,7 +435,7 @@ export default class CreateParameter extends Component { ...@@ -382,7 +435,7 @@ export default class CreateParameter extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -415,8 +468,16 @@ export default class CreateParameter extends Component { ...@@ -415,8 +468,16 @@ export default class CreateParameter extends Component {
{...this.state.parameter} {...this.state.parameter}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue })} onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, ()=> this.clearMessage())}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parameter" />} renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Parameter"
error={this.state.errorParameter}
helperText={this.state.msgErrorParameter}
/>}
value={this.state.getParameter} value={this.state.getParameter}
/> />
</div> </div>
...@@ -439,8 +500,8 @@ export default class CreateParameter extends Component { ...@@ -439,8 +500,8 @@ export default class CreateParameter extends Component {
}} }}
name="description" name="description"
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorDeskripsi} // error={this.state.errorDeskripsi}
helperText={this.state.msgErrorDeskripsi} // helperText={this.state.msgErrorDeskripsi}
> >
</TextField> </TextField>
</div> </div>
...@@ -464,8 +525,8 @@ export default class CreateParameter extends Component { ...@@ -464,8 +525,8 @@ export default class CreateParameter extends Component {
}} }}
name="value" name="value"
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorValue} // error={this.state.errorValue}
helperText={this.state.msgErrorValue} // helperText={this.state.msgErrorValue}
> >
</TextField> </TextField>
</div> </div>
...@@ -547,11 +608,11 @@ export default class CreateParameter extends Component { ...@@ -547,11 +608,11 @@ export default class CreateParameter extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography> <Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.created}</Typography> <Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.created}</Typography>
</div> </div>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography> <Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.updated == - null ? "" : this.props.data.updated}</Typography> <Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.updated === null ? "" : this.state.tempData.updated}</Typography>
</div> </div>
</div> </div>
</div> </div>
...@@ -562,7 +623,7 @@ export default class CreateParameter extends Component { ...@@ -562,7 +623,7 @@ export default class CreateParameter extends Component {
{...this.state.types} {...this.state.types}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }) : this.getParameterByGroup(newInputValue.setting_group_id))} onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }, ()=> this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id), this.clearMessage() )}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Group" />} renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Group" />}
value={this.state.getTypes} value={this.state.getTypes}
/> />
...@@ -572,7 +633,7 @@ export default class CreateParameter extends Component { ...@@ -572,7 +633,7 @@ export default class CreateParameter extends Component {
{...this.state.perusahaan} {...this.state.perusahaan}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })} onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, ()=> this.clearMessage())}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Perusahaan" />} renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Perusahaan" />}
value={this.state.getPerusahaan} value={this.state.getPerusahaan}
/> />
...@@ -597,8 +658,8 @@ export default class CreateParameter extends Component { ...@@ -597,8 +658,8 @@ export default class CreateParameter extends Component {
}} }}
name="order" name="order"
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorOrder} // error={this.state.errorOrder}
helperText={this.state.msgErrorOrder} // helperText={this.state.msgErrorOrder}
> >
</TextField> </TextField>
</div> </div>
...@@ -702,7 +763,7 @@ export default class CreateParameter extends Component { ...@@ -702,7 +763,7 @@ export default class CreateParameter extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -736,8 +797,16 @@ export default class CreateParameter extends Component { ...@@ -736,8 +797,16 @@ export default class CreateParameter extends Component {
debug debug
disabled={!this.state.enableParameter} disabled={!this.state.enableParameter}
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue })} onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, ()=> this.clearMessage())}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parameter" />} renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Parameter"
error={this.state.errorParameter}
helperText={this.state.msgErrorParameter}
/>}
value={this.state.getParameter} value={this.state.getParameter}
/> />
</div> </div>
...@@ -760,8 +829,6 @@ export default class CreateParameter extends Component { ...@@ -760,8 +829,6 @@ export default class CreateParameter extends Component {
}} }}
name="description" name="description"
onChange={(e) => this.handleChangeCreate(e, '')} onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorDeskripsi}
helperText={this.state.msgErrorDeskripsi}
> >
</TextField> </TextField>
</div> </div>
...@@ -785,8 +852,8 @@ export default class CreateParameter extends Component { ...@@ -785,8 +852,8 @@ export default class CreateParameter extends Component {
}} }}
name="value" name="value"
onChange={(e) => this.handleChangeCreate(e, '')} onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorValue} // error={this.state.errorValue}
helperText={this.state.msgErrorValue} // helperText={this.state.msgErrorValue}
> >
</TextField> </TextField>
</div> </div>
...@@ -866,8 +933,8 @@ export default class CreateParameter extends Component { ...@@ -866,8 +933,8 @@ export default class CreateParameter extends Component {
</div> </div>
<div style={{ padding: 10, borderRadius: 5 }}> <div style={{ padding: 10, borderRadius: 5 }}>
<Typography style={{ fontSize: 11 }}>Dibuat : Admin - 21 Jul 2020, 18:45</Typography> <Typography style={{ fontSize: 11 }}>Dibuat : </Typography>
<Typography style={{ fontSize: 11 }}>Diubah : Admin - 21 Jul 2020, 18:45</Typography> <Typography style={{ fontSize: 11 }}>Diubah : </Typography>
</div> </div>
</div> </div>
...@@ -877,8 +944,16 @@ export default class CreateParameter extends Component { ...@@ -877,8 +944,16 @@ export default class CreateParameter extends Component {
{...this.state.types} {...this.state.types}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }) : this.getParameterByGroup(newInputValue.setting_group_id))} onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => newInputValue === null ? this.setState({ enableParameter: false, getParameter: null }, ()=> this.clearMessage()) : this.getParameterByGroup(newInputValue.setting_group_id), this.clearMessage() )}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Group" />} renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Group"
error={this.state.errorGroup}
helperText={this.state.msgErrorGroup}
/>}
value={this.state.getTypes} value={this.state.getTypes}
/> />
</div> </div>
...@@ -887,8 +962,16 @@ export default class CreateParameter extends Component { ...@@ -887,8 +962,16 @@ export default class CreateParameter extends Component {
{...this.state.perusahaan} {...this.state.perusahaan}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })} onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, ()=> this.clearMessage())}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Perusahaan" />} renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Perusahaan"
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
/>}
value={this.state.getPerusahaan} value={this.state.getPerusahaan}
/> />
</div> </div>
...@@ -912,8 +995,8 @@ export default class CreateParameter extends Component { ...@@ -912,8 +995,8 @@ export default class CreateParameter extends Component {
}} }}
name="order" name="order"
onChange={(e) => this.handleChangeCreate(e, '')} onChange={(e) => this.handleChangeCreate(e, '')}
error={this.state.errorOrder} // error={this.state.errorOrder}
helperText={this.state.msgErrorOrder} // helperText={this.state.msgErrorOrder}
> >
</TextField> </TextField>
</div> </div>
......
...@@ -2,7 +2,8 @@ import React, { Component } from 'react'; ...@@ -2,7 +2,8 @@ import React, { Component } from 'react';
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles'; import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import { InputBase } from "@material-ui/core"; import { InputBase, Snackbar, withStyles } from "@material-ui/core";
import MuiAlert from '@material-ui/lab/Alert';
import CreateParameter from '../Parameter/CreateParameter'; import CreateParameter from '../Parameter/CreateParameter';
import api from '../../../api'; import api from '../../../api';
import PopUpFailedSave from "../../../library/PopUpFailedSave"; import PopUpFailedSave from "../../../library/PopUpFailedSave";
...@@ -15,6 +16,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable()); ...@@ -15,6 +16,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
const options2 = ct.customOptions2(); const options2 = ct.customOptions2();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class Parameter extends Component { export default class Parameter extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -24,7 +28,10 @@ export default class Parameter extends Component { ...@@ -24,7 +28,10 @@ export default class Parameter extends Component {
visibleParameter: true, visibleParameter: true,
popupError: false, popupError: false,
data: [], data: [],
dataTable: [] dataTable: [],
alert: false,
tipeAlert: '',
messageAlert: ''
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -76,10 +83,15 @@ export default class Parameter extends Component { ...@@ -76,10 +83,15 @@ export default class Parameter extends Component {
updateParameter = (payload) => { updateParameter = (payload) => {
this.setState({ visibleEdit: false }) this.setState({ visibleEdit: false })
api.create().updateParameter(payload).then(response => { api.create().updateParameter(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getAllParameter() this.getAllParameter()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -87,10 +99,15 @@ export default class Parameter extends Component { ...@@ -87,10 +99,15 @@ export default class Parameter extends Component {
createParameter = (payload) => { createParameter = (payload) => {
this.setState({ visibleCreate: false }) this.setState({ visibleCreate: false })
api.create().createParameter(payload).then(response => { api.create().createParameter(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getAllParameter() this.getAllParameter()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -499,14 +516,22 @@ export default class Parameter extends Component { ...@@ -499,14 +516,22 @@ export default class Parameter extends Component {
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response) console.log(response)
alert(response.data.message)
this.getAllParameter() this.getAllParameter()
this.setState({ visibleParameter: true }) this.setState({ visibleParameter: true })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -641,6 +666,11 @@ export default class Parameter extends Component { ...@@ -641,6 +666,11 @@ export default class Parameter extends Component {
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} /> <div className={"main-color"} style={{ height: 199, width: '100%' }} />
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.visibleParameter === true ? {this.state.visibleParameter === true ?
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
......
...@@ -7,7 +7,8 @@ import UploadFile from "../../library/Upload"; ...@@ -7,7 +7,8 @@ import UploadFile from "../../library/Upload";
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import CreateUnitBisnis from "./formUnitBisnis/CreateUnitBisnis"; import CreateUnitBisnis from "./formUnitBisnis/CreateUnitBisnis";
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import { TextField, InputBase } from "@material-ui/core"; import MuiAlert from '@material-ui/lab/Alert';
import { TextField, InputBase, Snackbar, withStyles } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import api from "../../api"; import api from "../../api";
import { isThisSecond } from "date-fns"; import { isThisSecond } from "date-fns";
...@@ -18,6 +19,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable()); ...@@ -18,6 +19,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
const options2 = ct.customOptions2(); const options2 = ct.customOptions2();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class UnitBisnis extends Component { export default class UnitBisnis extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -32,7 +36,10 @@ export default class UnitBisnis extends Component { ...@@ -32,7 +36,10 @@ export default class UnitBisnis extends Component {
cols: null, cols: null,
rows: null, rows: null,
dataLoaded: false, dataLoaded: false,
popupError: false popupError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -193,10 +200,10 @@ export default class UnitBisnis extends Component { ...@@ -193,10 +200,10 @@ export default class UnitBisnis extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
} }
} else { } else {
this.setState({ dataTable: [] }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', dataTable: [] })
} }
}) })
} }
...@@ -222,6 +229,7 @@ export default class UnitBisnis extends Component { ...@@ -222,6 +229,7 @@ export default class UnitBisnis extends Component {
} }
api.create().searchUnitBisnis(body).then(response => { api.create().searchUnitBisnis(body).then(response => {
// console.log(response.data); // console.log(response.data);
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
...@@ -229,7 +237,10 @@ export default class UnitBisnis extends Component { ...@@ -229,7 +237,10 @@ export default class UnitBisnis extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -237,22 +248,32 @@ export default class UnitBisnis extends Component { ...@@ -237,22 +248,32 @@ export default class UnitBisnis extends Component {
updateUnitBisnis = (payload) => { updateUnitBisnis = (payload) => {
this.setState({ visibleEdit: false }) this.setState({ visibleEdit: false })
api.create().updateUnitBisnis(payload).then(response => { api.create().updateUnitBisnis(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
alert(response.data.message)
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
}) })
} }
createUnitBisnis = (payload) => { createUnitBisnis = (payload) => {
this.setState({ visibleCreate: false }) this.setState({ visibleCreate: false })
api.create().createUnitBisnis(payload).then(response => { api.create().createUnitBisnis(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -290,14 +311,23 @@ export default class UnitBisnis extends Component { ...@@ -290,14 +311,23 @@ export default class UnitBisnis extends Component {
uploadUnitBisnis() { uploadUnitBisnis() {
api.create().uploadUnitBisnis(this.state.payload).then(response => { api.create().uploadUnitBisnis(this.state.payload).then(response => {
console.log(response) console.log(response)
if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
alert(response.data.message)
this.getData() this.getData()
this.setState({ visibleUnitBisnis: true }) this.setState({ visibleUnitBisnis: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -366,6 +396,11 @@ export default class UnitBisnis extends Component { ...@@ -366,6 +396,11 @@ export default class UnitBisnis extends Component {
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div style={{ height: 199, width: '100%' }} className={"main-color"} /> <div style={{ height: 199, width: '100%' }} className={"main-color"} />
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.visibleUnitBisnis === true ? {this.state.visibleUnitBisnis === true ?
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
......
...@@ -7,8 +7,10 @@ import AddUser from './User/AddUser'; ...@@ -7,8 +7,10 @@ import AddUser from './User/AddUser';
import EditUser from './User/EditUser' import EditUser from './User/EditUser'
import api from "../../api"; import api from "../../api";
import { titleCase } from "../../library/Utils"; import { titleCase } from "../../library/Utils";
import { InputAdornment, TextField, InputBase } from "@material-ui/core"; import { InputAdornment, Snackbar, InputBase } from "@material-ui/core";
import MuiAlert from '@material-ui/lab/Alert';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { withStyles } from '@material-ui/core/styles';
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import ReactTooltip from "react-tooltip"; import ReactTooltip from "react-tooltip";
import PopUpFailedSave from "../../library/PopUpFailedSave"; import PopUpFailedSave from "../../library/PopUpFailedSave";
...@@ -17,6 +19,9 @@ var ct = require("../../library/CustomTable"); ...@@ -17,6 +19,9 @@ var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class UserRole extends Component { export default class UserRole extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -27,6 +32,9 @@ export default class UserRole extends Component { ...@@ -27,6 +32,9 @@ export default class UserRole extends Component {
edit: false, edit: false,
visibleUser: true, visibleUser: true,
buttonError: false, buttonError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -44,6 +52,8 @@ export default class UserRole extends Component { ...@@ -44,6 +52,8 @@ export default class UserRole extends Component {
getUser() { getUser() {
api.create().getUser().then((response) => { api.create().getUser().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a, b) => a.user_id - b.user_id).map((item, index) => { let listData = data.sort((a, b) => a.user_id - b.user_id).map((item, index) => {
...@@ -51,7 +61,13 @@ export default class UserRole extends Component { ...@@ -51,7 +61,13 @@ export default class UserRole extends Component {
}) })
this.setState({ listUser: listData }) this.setState({ listUser: listData })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -61,6 +77,8 @@ export default class UserRole extends Component { ...@@ -61,6 +77,8 @@ export default class UserRole extends Component {
"keyword": this.state.search "keyword": this.state.search
} }
api.create().searchUser(payload).then((response) => { api.create().searchUser(payload).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a, b) => a.user_id - b.user_id).map((item, index) => { let listData = data.sort((a, b) => a.user_id - b.user_id).map((item, index) => {
...@@ -68,7 +86,13 @@ export default class UserRole extends Component { ...@@ -68,7 +86,13 @@ export default class UserRole extends Component {
}) })
this.setState({ listUser: listData }) this.setState({ listUser: listData })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -281,16 +305,28 @@ export default class UserRole extends Component { ...@@ -281,16 +305,28 @@ export default class UserRole extends Component {
uploadUser() { uploadUser() {
api.create().uploadUser(this.state.payload).then(response => { api.create().uploadUser(this.state.payload).then(response => {
if (response.data) { if (response.data) {
if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response) console.log(response)
alert(response.data.message) alert(response.data.message)
this.getUser() this.getUser()
this.setState({ visibleUser: true }) this.setState({ visibleUser: true })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -298,7 +334,7 @@ export default class UserRole extends Component { ...@@ -298,7 +334,7 @@ export default class UserRole extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[6] === "Aktif" ? {/* {tableMeta.rowData[6] === "Aktif" ? */}
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -310,9 +346,9 @@ export default class UserRole extends Component { ...@@ -310,9 +346,9 @@ export default class UserRole extends Component {
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
: {/* :
null null
} } */}
</div > </div >
); );
} }
...@@ -388,6 +424,11 @@ export default class UserRole extends Component { ...@@ -388,6 +424,11 @@ export default class UserRole extends Component {
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} /> <div className={"main-color"} style={{ height: 199, width: '100%' }} />
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.visibleUser ? <div> {this.state.visibleUser ? <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - User</label> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - User</label>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core'; import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, Snackbar } from '@material-ui/core';
import api from '../../../api'; import api from '../../../api';
import Autocomplete from '@material-ui/lab/Autocomplete'; import Autocomplete from '@material-ui/lab/Autocomplete';
import { titleCase } from '../../../library/Utils'; import { titleCase } from '../../../library/Utils';
...@@ -10,6 +10,7 @@ import AddIcon from '@material-ui/icons/Add'; ...@@ -10,6 +10,7 @@ import AddIcon from '@material-ui/icons/Add';
import { DatePicker } from '@material-ui/pickers'; import { DatePicker } from '@material-ui/pickers';
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -31,6 +32,9 @@ const CustomCheckboxDisabled = withStyles({ ...@@ -31,6 +32,9 @@ const CustomCheckboxDisabled = withStyles({
checked: {}, checked: {},
})((props) => <Checkbox color="default" {...props} />); })((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class AddUser extends Component { export default class AddUser extends Component {
constructor(props) { constructor(props) {
...@@ -60,6 +64,9 @@ export default class AddUser extends Component { ...@@ -60,6 +64,9 @@ export default class AddUser extends Component {
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -169,8 +176,22 @@ export default class AddUser extends Component { ...@@ -169,8 +176,22 @@ export default class AddUser extends Component {
api.create().createUser(payload).then((response) => { api.create().createUser(payload).then((response) => {
// console.log(response) // console.log(response)
// if (String(response.data.status).toLocaleUpperCase === 'Success' || String(response.data.status).toLocaleUpperCase === 'success') { // if (String(response.data.status).toLocaleUpperCase === 'Success' || String(response.data.status).toLocaleUpperCase === 'success') {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.onClickClose() this.props.onClickClose()
this.props.refresh() this.props.refresh()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
// } else { // } else {
// alert(response.data.message) // alert(response.data.message)
// this.props.onClickClose() // this.props.onClickClose()
...@@ -181,6 +202,8 @@ export default class AddUser extends Component { ...@@ -181,6 +202,8 @@ export default class AddUser extends Component {
getRole() { getRole() {
api.create().getRoleActive().then((response) => { api.create().getRoleActive().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let roleData = data.map((item) => { let roleData = data.map((item) => {
...@@ -195,16 +218,32 @@ export default class AddUser extends Component { ...@@ -195,16 +218,32 @@ export default class AddUser extends Component {
}; };
this.setState({ listRole: defaultProps }) this.setState({ listRole: defaultProps })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
getPerusahaan() { getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => { api.create().getPerusahaanHierarki().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data }) this.setState({ listCompany: response.data.data })
console.log(response.data.data) console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -327,9 +366,18 @@ export default class AddUser extends Component { ...@@ -327,9 +366,18 @@ export default class AddUser extends Component {
return false; return false;
}; };
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core'; import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, Snackbar } from '@material-ui/core';
import api from '../../../api'; import api from '../../../api';
import { titleCase } from '../../../library/Utils'; import { titleCase } from '../../../library/Utils';
import Autocomplete from '@material-ui/lab/Autocomplete'; import Autocomplete from '@material-ui/lab/Autocomplete';
...@@ -9,6 +9,7 @@ import RemoveIcon from '@material-ui/icons/Remove'; ...@@ -9,6 +9,7 @@ import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -30,6 +31,9 @@ const CustomCheckboxDisabled = withStyles({ ...@@ -30,6 +31,9 @@ const CustomCheckboxDisabled = withStyles({
checked: {}, checked: {},
})((props) => <Checkbox color="default" {...props} />); })((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class EditUser extends Component { export default class EditUser extends Component {
constructor(props) { constructor(props) {
...@@ -54,6 +58,9 @@ export default class EditUser extends Component { ...@@ -54,6 +58,9 @@ export default class EditUser extends Component {
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -117,11 +124,19 @@ export default class EditUser extends Component { ...@@ -117,11 +124,19 @@ export default class EditUser extends Component {
getDetailUser() { getDetailUser() {
api.create().getDetailUser(this.state.paramsId).then((response) => { api.create().getDetailUser(this.state.paramsId).then((response) => {
this.getRole() this.getRole()
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ tempData: response.data.data, company: response.data.data.company }) this.setState({ tempData: response.data.data, company: response.data.data.company })
console.log(response.data.data) console.log(response.data.data)
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -168,17 +183,28 @@ export default class EditUser extends Component { ...@@ -168,17 +183,28 @@ export default class EditUser extends Component {
} }
api.create().updateUser(payload).then((response) => { api.create().updateUser(payload).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.onClickClose() this.props.onClickClose()
this.props.refresh() this.props.refresh()
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
getRole() { getRole() {
api.create().getRoleActive().then((response) => { api.create().getRoleActive().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let roleData = data.map((item) => { let roleData = data.map((item) => {
...@@ -195,15 +221,31 @@ export default class EditUser extends Component { ...@@ -195,15 +221,31 @@ export default class EditUser extends Component {
let index = roleData.findIndex((val) => val.role_id === this.state.tempData.role_id) let index = roleData.findIndex((val) => val.role_id === this.state.tempData.role_id)
this.setState({ listRole: defaultProps, role: index === -1 ? roleData[0] : roleData[index] }) this.setState({ listRole: defaultProps, role: index === -1 ? roleData[0] : roleData[index] })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
getPerusahaan() { getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => { api.create().getPerusahaanHierarki().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ listCompany: response.data.data }) this.setState({ listCompany: response.data.data })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -326,9 +368,18 @@ export default class EditUser extends Component { ...@@ -326,9 +368,18 @@ export default class EditUser extends Component {
return false; return false;
}; };
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......
...@@ -9,12 +9,18 @@ import api from "../../api"; ...@@ -9,12 +9,18 @@ import api from "../../api";
import { titleCase } from "../../library/Utils"; import { titleCase } from "../../library/Utils";
import InputAdornment from '@material-ui/core/InputAdornment'; import InputAdornment from '@material-ui/core/InputAdornment';
import TextField from '@material-ui/core/TextField'; import TextField from '@material-ui/core/TextField';
import { InputBase } from "@material-ui/core"; import { InputBase, Snackbar } from "@material-ui/core";
import ReactTooltip from "react-tooltip"; import ReactTooltip from "react-tooltip";
import MuiAlert from '@material-ui/lab/Alert';
import { withStyles } from '@material-ui/core/styles';
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class UserRole extends Component { class UserRole extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -23,7 +29,10 @@ class UserRole extends Component { ...@@ -23,7 +29,10 @@ class UserRole extends Component {
indexData: {}, indexData: {},
add: false, add: false,
edit: false, edit: false,
search: '' search: '',
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -41,7 +50,8 @@ class UserRole extends Component { ...@@ -41,7 +50,8 @@ class UserRole extends Component {
getRole() { getRole() {
api.create().getRole().then((response) => { api.create().getRole().then((response) => {
// console.log(response) if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a, b) => a.role_id - b.role_id).map((item, index) => { let listData = data.sort((a, b) => a.role_id - b.role_id).map((item, index) => {
...@@ -54,9 +64,14 @@ class UserRole extends Component { ...@@ -54,9 +64,14 @@ class UserRole extends Component {
// }) // })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
// console.log(response.data.data)
}) })
} }
...@@ -65,6 +80,8 @@ class UserRole extends Component { ...@@ -65,6 +80,8 @@ class UserRole extends Component {
"keyword": this.state.search "keyword": this.state.search
} }
api.create().searchRole(payload).then((response) => { api.create().searchRole(payload).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a, b) => a.role_id - b.role_id).map((item, index) => { let listData = data.sort((a, b) => a.role_id - b.role_id).map((item, index) => {
...@@ -72,7 +89,13 @@ class UserRole extends Component { ...@@ -72,7 +89,13 @@ class UserRole extends Component {
}) })
this.setState({ listRole: listData }) this.setState({ listRole: listData })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -95,6 +118,10 @@ class UserRole extends Component { ...@@ -95,6 +118,10 @@ class UserRole extends Component {
})) }))
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -113,7 +140,7 @@ class UserRole extends Component { ...@@ -113,7 +140,7 @@ class UserRole extends Component {
onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })} onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })}
> >
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[2] !== "superadmin" && tableMeta.rowData[4] === "Aktif" ? {tableMeta.rowData[2] !== "superadmin" ?
<img src={Images.editCopy} /> : <img src={Images.editCopy} /> :
null null
} }
...@@ -173,6 +200,11 @@ class UserRole extends Component { ...@@ -173,6 +200,11 @@ class UserRole extends Component {
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div className={"main-color"} style={{ height: 199, width: '100%' }} /> <div className={"main-color"} style={{ height: 199, width: '100%' }} />
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Role & Otorisasi</label> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Role & Otorisasi</label>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core'; import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, Snackbar } from '@material-ui/core';
import api from '../../../api'; import api from '../../../api';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove'; import RemoveIcon from '@material-ui/icons/Remove';
...@@ -8,6 +8,7 @@ import format from "date-fns/format"; ...@@ -8,6 +8,7 @@ import format from "date-fns/format";
import localeID from "date-fns/locale/id" import localeID from "date-fns/locale/id"
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -20,6 +21,9 @@ const CustomCheckbox = withStyles({ ...@@ -20,6 +21,9 @@ const CustomCheckbox = withStyles({
checked: {}, checked: {},
})((props) => <Checkbox color="default" {...props} />); })((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class AddRole extends Component { export default class AddRole extends Component {
constructor(props) { constructor(props) {
...@@ -43,6 +47,9 @@ export default class AddRole extends Component { ...@@ -43,6 +47,9 @@ export default class AddRole extends Component {
msgErrorED: '', msgErrorED: '',
application: [], application: [],
setting: [], setting: [],
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -127,11 +134,20 @@ export default class AddRole extends Component { ...@@ -127,11 +134,20 @@ export default class AddRole extends Component {
// console.log(payload) // console.log(payload)
api.create().addRole(payload).then((response) => { api.create().addRole(payload).then((response) => {
console.log(response) console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.refresh() this.props.refresh()
this.props.onClickClose() this.props.onClickClose()
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -151,6 +167,8 @@ export default class AddRole extends Component { ...@@ -151,6 +167,8 @@ export default class AddRole extends Component {
getMenu() { getMenu() {
api.create().getMenu().then((response) => { api.create().getMenu().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let app = null let app = null
let set = null let set = null
...@@ -167,7 +185,13 @@ export default class AddRole extends Component { ...@@ -167,7 +185,13 @@ export default class AddRole extends Component {
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application)) this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data }) // this.setState({ menuData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -243,9 +267,18 @@ export default class AddRole extends Component { ...@@ -243,9 +267,18 @@ export default class AddRole extends Component {
this.setState({ ...this.state.setting, setting: arr }) this.setState({ ...this.state.setting, setting: arr })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content-middle background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content-middle background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core'; import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, Snackbar } from '@material-ui/core';
import api from '../../../api'; import api from '../../../api';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove'; import RemoveIcon from '@material-ui/icons/Remove';
...@@ -7,6 +7,8 @@ import { DatePicker } from "@material-ui/pickers"; ...@@ -7,6 +7,8 @@ import { DatePicker } from "@material-ui/pickers";
import format from "date-fns/format"; import format from "date-fns/format";
import * as R from 'ramda' import * as R from 'ramda'
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import MuiAlert from '@material-ui/lab/Alert';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
color: '#51c6ea', color: '#51c6ea',
...@@ -18,6 +20,9 @@ const CustomCheckbox = withStyles({ ...@@ -18,6 +20,9 @@ const CustomCheckbox = withStyles({
checked: {}, checked: {},
})((props) => <Checkbox color="default" {...props} />); })((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class EditRole extends Component { export default class EditRole extends Component {
constructor(props) { constructor(props) {
...@@ -38,6 +43,9 @@ export default class EditRole extends Component { ...@@ -38,6 +43,9 @@ export default class EditRole extends Component {
msgErrorED: '', msgErrorED: '',
application: [], application: [],
setting: [], setting: [],
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -89,11 +97,19 @@ export default class EditRole extends Component { ...@@ -89,11 +97,19 @@ export default class EditRole extends Component {
getDetailRole() { getDetailRole() {
api.create().getDetailRole(this.state.paramsId).then((response) => { api.create().getDetailRole(this.state.paramsId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ tempData: response.data.data, privileges: response.data.data.privileges }) this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
console.log(response.data.data.start_date) console.log(response.data.data.start_date)
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -125,11 +141,20 @@ export default class EditRole extends Component { ...@@ -125,11 +141,20 @@ export default class EditRole extends Component {
// console.log(payload) // console.log(payload)
api.create().editRole(payload).then((response) => { api.create().editRole(payload).then((response) => {
console.log(response) console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.refresh() this.props.refresh()
this.props.onClickClose() this.props.onClickClose()
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -149,6 +174,8 @@ export default class EditRole extends Component { ...@@ -149,6 +174,8 @@ export default class EditRole extends Component {
getMenu() { getMenu() {
api.create().getMenu().then((response) => { api.create().getMenu().then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let app = null let app = null
let set = null let set = null
...@@ -165,7 +192,13 @@ export default class EditRole extends Component { ...@@ -165,7 +192,13 @@ export default class EditRole extends Component {
this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application)) this.setState({ application: app, setting: set, isLoad: true }, () => console.log(this.state.application))
// this.setState({ menuData: response.data.data }) // this.setState({ menuData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -241,9 +274,18 @@ export default class EditRole extends Component { ...@@ -241,9 +274,18 @@ export default class EditRole extends Component {
return value return value
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content-middle background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content-middle background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import Images from '../assets/Images'; import Images from '../assets/Images';
import { TextField, InputAdornment, Button, Typography, IconButton } from '@material-ui/core'; import { TextField, InputAdornment, Button, Typography, IconButton, Snackbar } 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 MuiAlert from '@material-ui/lab/Alert';
import { withStyles } from '@material-ui/core/styles';
import api from '../api'; import api from '../api';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class ResetPassword extends Component { class ResetPassword extends Component {
constructor(props) { constructor(props) {
...@@ -18,7 +22,10 @@ class ResetPassword extends Component { ...@@ -18,7 +22,10 @@ class ResetPassword extends Component {
errorConfirmPassword: false, errorConfirmPassword: false,
msgPassword: 'Terdiri 8 karakter dengan kombinasi angka.', msgPassword: 'Terdiri 8 karakter dengan kombinasi angka.',
msgConfirmPassword: 'Terdiri 8 karakter dengan kombinasi angka.', msgConfirmPassword: 'Terdiri 8 karakter dengan kombinasi angka.',
userId: 0 userId: 0,
alert: false,
tipeAlert: '',
messageAlert: ''
} }
} }
...@@ -32,12 +39,16 @@ class ResetPassword extends Component { ...@@ -32,12 +39,16 @@ class ResetPassword extends Component {
checkExpiredLink(userId) { checkExpiredLink(userId) {
api.create().isResetPassword(userId).then((response) => { api.create().isResetPassword(userId).then((response) => {
if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
// //
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
this.props.history.push('/login') this.props.history.push('/login')
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
}) })
} }
...@@ -83,15 +94,27 @@ class ResetPassword extends Component { ...@@ -83,15 +94,27 @@ class ResetPassword extends Component {
"user_id": this.state.userId "user_id": this.state.userId
} }
api.create().resetPassword(payload).then((response) => { api.create().resetPassword(payload).then((response) => {
if (response.data) {
if (response.ok) {
if(response.data.status === 'success') { if(response.data.status === 'success') {
alert('success') this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.props.history.push('/login') this.props.history.push('/login')
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
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})
...@@ -105,6 +128,11 @@ class ResetPassword extends Component { ...@@ -105,6 +128,11 @@ class ResetPassword extends Component {
render() { render() {
return ( return (
<div style={{ flex: 1, display: 'flex', backgroundColor: '#152d40', height: '100vh', justifyContent: 'center', alignItems: 'center' }}> <div style={{ flex: 1, display: 'flex', backgroundColor: '#152d40', height: '100vh', justifyContent: 'center', alignItems: 'center' }}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div style={{padding: 56, display: 'flex', flexDirection: 'column', width: 378, height: 415, borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff', justifyContent: 'center', alignItems: 'center' }}> <div style={{padding: 56, display: 'flex', flexDirection: 'column', width: 378, height: 415, 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}/>
......
...@@ -2,8 +2,12 @@ import React, { Component, createRef } from "react" ...@@ -2,8 +2,12 @@ import React, { Component, createRef } from "react"
import Dropzone from 'react-dropzone' import Dropzone from 'react-dropzone'
import LinearProgress from '@material-ui/core/LinearProgress' import LinearProgress from '@material-ui/core/LinearProgress'
import Images from "../assets/Images" import Images from "../assets/Images"
import MuiAlert from '@material-ui/lab/Alert';
import { withStyles, Snackbar } from "@material-ui/core";
const dropzoneRef = createRef() const dropzoneRef = createRef()
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
class Upload extends Component { class Upload extends Component {
constructor(props) { constructor(props) {
...@@ -19,7 +23,9 @@ class Upload extends Component { ...@@ -19,7 +23,9 @@ class Upload extends Component {
iconButtonUpload: 'fa fa-1x fa-upload', iconButtonUpload: 'fa fa-1x fa-upload',
uploadProgress: false, uploadProgress: false,
percentage: '0', percentage: '0',
completed: '0' completed: '0',
alert: false,
alertMessage: ''
} }
} }
...@@ -64,7 +70,8 @@ class Upload extends Component { ...@@ -64,7 +70,8 @@ class Upload extends Component {
uploadProgress: false, uploadProgress: false,
percentage: '0' percentage: '0'
}) })
alert("Unsupported Media Type") this.setState({ alertMessage: "Unsupported Media Type", alert: true })
// alert("Unsupported Media Type")
} }
} }
...@@ -85,15 +92,20 @@ class Upload extends Component { ...@@ -85,15 +92,20 @@ class Upload extends Component {
// console.log(strState); // console.log(strState);
if (strProps.includes(strState)) { if (strProps.includes(strState)) {
if (this.state.sizeFile < 1000000) { if (this.state.sizeFile < 1000) {
this.props.onUpload() this.props.onUpload()
} else { } else {
alert('File Tidak Boleh Lebih Dari 1MB') this.setState({ alertMessage: 'File Tidak Boleh Lebih Dari 1MB', alert: true })
// alert('File Tidak Boleh Lebih Dari 1MB')
} }
} else { } else {
alert('File Tidak Mendukung') this.setState({ alertMessage: 'File Tidak Mendukung', alert: true })
// alert('File Tidak Mendukung')
}
} }
closeAlert() {
this.setState({ alert: false })
} }
render() { render() {
...@@ -102,6 +114,11 @@ class Upload extends Component { ...@@ -102,6 +114,11 @@ class Upload extends Component {
<Dropzone ref={dropzoneRef} onDrop={this.onDrop}> <Dropzone ref={dropzoneRef} onDrop={this.onDrop}>
{({ getRootProps, getInputProps }) => ( {({ getRootProps, getInputProps }) => (
<div> <div>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={"warning"}>
{this.state.alertMessage}
</Alert>
</Snackbar>
<div className="upload-file"> <div className="upload-file">
{/* label */} {/* label */}
......
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