Commit f6c27c4e authored by faisalhamdi's avatar faisalhamdi

merge conflict

parents 3799d451 d534fd40
import React, { Component } from 'react';
import { Container, Row, Col } from "react-bootstrap";
import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { TextField, InputBase } from "@material-ui/core";
import { makeStyles, createMuiTheme, MuiThemeProvider, withStyles } from '@material-ui/core/styles';
import { TextField, InputBase, Snackbar } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer';
import Images from '../../assets/Images';
import MUIDataTable from "mui-datatables";
import ReactTooltip from 'react-tooltip';
import MuiAlert from '@material-ui/lab/Alert';
import UploadFile from "../../library/Upload";
import CreateApprovalMatrix from "./CreateApprovalMatrix";
import EditApprovalMatrix from "./EditApprovalMatrix";
......@@ -18,6 +19,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const options2 = ct.customOptions2();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class ApprovalMatrix extends Component {
constructor(props) {
super(props)
......@@ -264,17 +268,18 @@ export default class ApprovalMatrix extends Component {
getData() {
api.create().getAM().then((response) => {
// console.log(response)
if(response.status == null){
alert(response.problem)
}
else if (response.data.status == 'success') {
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.sort((a,b) => a.approval_matrix_id - b.approval_matrix_id).map((item, index) => {
return [index, item.approval_matrix_id, item.approval_type_name, item.orders, item.fullname, item.operator_type_name, item.status ]
let listData = data.sort((a, b) => a.approval_matrix_id - b.approval_matrix_id).map((item, index) => {
return [index, item.approval_matrix_id, item.approval_type_name, item.orders, item.fullname, item.operator_type_name, item.status]
})
this.setState({ dataTable: listData, listData: response.data.data })
} 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' })
}
})
}
......@@ -299,6 +304,7 @@ export default class ApprovalMatrix extends Component {
}
api.create().searchAM(body).then(response => {
// console.log(response.data);
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
......@@ -306,7 +312,10 @@ export default class ApprovalMatrix extends Component {
})
this.setState({ dataTable: listData, listData: response.data.data })
} 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' })
}
})
}
......@@ -314,11 +323,15 @@ export default class ApprovalMatrix extends Component {
createAM = (payload) => {
this.setState({ visibleCreate: false })
api.create().createAM(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') {
alert(response.data.message)
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -326,11 +339,15 @@ export default class ApprovalMatrix extends Component {
updateAM = (payload) => {
this.setState({ visibleEdit: false })
api.create().updateAM(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') {
alert(response.data.message)
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} 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' })
}
})
}
......@@ -338,11 +355,15 @@ export default class ApprovalMatrix extends Component {
updateVAM = (payload) => {
this.setState({ visibleVisual: false, visibleAM: true })
api.create().updateVAM(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') {
alert(response.data.message)
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -381,12 +402,24 @@ export default class ApprovalMatrix extends Component {
uploadAM() {
api.create().uploadAM(this.state.payload).then(response => {
console.log(response.data)
if (response.data) {
if (response.data.status === "success") {
// console.log(this.state.payload)
this.getData()
this.setState({ visibleAM: true })
this.setState({ visibleAM: 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() {
const columns = [{
name: "Action",
......@@ -494,7 +527,12 @@ export default class ApprovalMatrix extends Component {
<div>
{this.state.visibleAM === true ?
<div style={{ height: this.props.height }}>
<div class="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 class="main-color" style={{ height: 199, width: '100%' }} />
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ width: '20%', color: 'white', fontSize: 16, alignSelf: 'center', paddingTop: 8 }}>Master Data - Approval Matrix</label>
......@@ -519,7 +557,7 @@ export default class ApprovalMatrix extends Component {
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} title="Download Template"/>
<img src={Images.template} title="Download Template" />
</button>
<button
style={{
......@@ -527,12 +565,12 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 16,
padding:0,
padding: 0,
margin: 5
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} title="Upload File"/>
<img src={Images.upload} title="Upload File" />
</button>
<button
style={{
......@@ -540,12 +578,12 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 16,
padding:0,
padding: 0,
margin: 5
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} title="Download File"/>
<img src={Images.download} title="Download File" />
</button>
<button
style={{
......@@ -553,12 +591,12 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 16,
padding:0,
padding: 0,
margin: 5
}}
onClick={() => this.setState({ visibleVisual: true, visibleAM: false })}
>
<img src={Images.visualisasi} title="Visualisasi"/>
<img src={Images.visualisasi} title="Visualisasi" />
</button>
<button
style={{
......@@ -566,12 +604,12 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 16,
padding:0,
padding: 0,
margin: 5
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} title="Tambah Approval Matrix"/>
<img src={Images.add} title="Tambah Approval Matrix" />
</button>
</div >
</div>
......@@ -591,7 +629,7 @@ export default class ApprovalMatrix extends Component {
this.state.visibleVisual == true ?
<VisualisasiAM
onClickClose={() => this.setState({ visibleVisual: false, visibleAM: true })}
height= {this.props.height}
height={this.props.height}
updateVAM={this.updateVAM.bind(this)}
/>
:
......@@ -655,7 +693,7 @@ export default class ApprovalMatrix extends Component {
/>
)}
{this.state.popupError && (
<PopUpFailedSave onClickClose={()=> this.setState({ popupError: false })} />
<PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
)}
{this.state.visibleUpload && (
<div className="test app-popup-show">
......@@ -672,7 +710,7 @@ export default class ApprovalMatrix extends Component {
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......
......@@ -328,10 +328,10 @@ export default class CreateParameter extends Component {
}
validasi() {
if (R.isNil(this.state.getParameter)) {
this.setState({ errorParameter: true, msgErrorParameter: 'Parameter tidak boleh kosong' })
} else if (R.isNil(this.state.getTypes)) {
if (R.isNil(this.state.getTypes)) {
this.setState({ errorGroup: true, msgErrorGroup: 'Group tidak boleh kosong' })
} else if (R.isNil(this.state.getParameter)) {
this.setState({ errorParameter: true, msgErrorParameter: 'Parameter tidak boleh kosong' })
} else if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Perusahaan tidak boleh kosong' })
// } else if (R.isEmpty(this.state.tempData.description)) {
......@@ -468,7 +468,7 @@ export default class CreateParameter extends Component {
{...this.state.parameter}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, ()=> this.clearMessage())}
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
......@@ -513,6 +513,7 @@ export default class CreateParameter extends Component {
value={this.state.tempData === null ? '' : this.state.tempData.value}
type={"number"}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -538,6 +539,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.min_value}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -623,8 +625,15 @@ export default class CreateParameter extends Component {
{...this.state.types}
debug
id="tipe"
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" />}
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}
error={this.state.errorGroup}
helperText={this.state.msgErrorGroup}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Group" />}
value={this.state.getTypes}
/>
</div>
......@@ -633,8 +642,14 @@ export default class CreateParameter extends Component {
{...this.state.perusahaan}
debug
id="tipe"
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" />}
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField {...params}
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Perusahaan" />}
value={this.state.getPerusahaan}
/>
</div>
......@@ -646,6 +661,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.order}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -671,6 +687,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.tempData === null ? '' : this.state.tempData.max_value}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -797,7 +814,7 @@ export default class CreateParameter extends Component {
debug
disabled={!this.state.enableParameter}
id="tipe"
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, ()=> this.clearMessage())}
onChange={(event, newInputValue) => this.setState({ getParameter: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
......@@ -840,10 +857,12 @@ export default class CreateParameter extends Component {
value={this.state.value === null ? '' : this.state.value}
type={"number"}
inputProps={{
min: 0,
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
......@@ -865,6 +884,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.minValue === null ? '' : this.state.minValue}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -932,7 +952,7 @@ export default class CreateParameter extends Component {
/>
</div>
<div style={{ padding: 10, borderRadius: 5 }}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Typography style={{ fontSize: 11 }}>Dibuat : </Typography>
<Typography style={{ fontSize: 11 }}>Diubah : </Typography>
</div>
......@@ -944,7 +964,7 @@ export default class CreateParameter extends Component {
{...this.state.types}
debug
id="tipe"
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() )}
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}
......@@ -962,7 +982,7 @@ export default class CreateParameter extends Component {
{...this.state.perusahaan}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, ()=> this.clearMessage())}
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, () => this.clearMessage())}
renderInput={(params) =>
<TextField
{...params}
......@@ -983,6 +1003,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.order === null ? '' : this.state.order}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......@@ -1008,6 +1029,7 @@ export default class CreateParameter extends Component {
type={"number"}
value={this.state.maxValue === null ? '' : this.state.maxValue}
inputProps={{
min: 0,
style: {
fontSize: 11
}
......
......@@ -42,6 +42,7 @@ export default class Parameter extends Component {
getAllParameter() {
api.create().getAllParameter().then(response => {
if (response.data) {
if (response.data.status === "success") {
console.log(response);
let data = response.data.data
......@@ -61,7 +62,10 @@ export default class Parameter extends Component {
})
this.setState({ dataTable: listData, data: response.data.data })
} 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' })
}
})
}
......@@ -83,6 +87,7 @@ export default class Parameter extends Component {
updateParameter = (payload) => {
this.setState({ visibleEdit: false })
api.create().updateParameter(payload).then(response => {
console.log(response);
if (response.data) {
if (response.data.status == 'success') {
this.getAllParameter()
......@@ -517,8 +522,7 @@ export default class Parameter extends Component {
if (response.data.status === "success") {
console.log(response)
this.getAllParameter()
this.setState({ visibleParameter: true })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.setState({ visibleParameter: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
......
......@@ -96,7 +96,7 @@ export default class CreatePerusahaan extends Component {
options: perusahaanData,
getOptionLabel: (option) => option.company_name,
};
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? perusahaanData[0] : perusahaanData[index] })
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? null : perusahaanData[index] })
} else {
alert(response.data.message)
}
......@@ -120,7 +120,7 @@ export default class CreatePerusahaan extends Component {
options: typeData,
getOptionLabel: (option) => option.business_unit_name,
};
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] })
this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? null : typeData[index] })
} else {
alert(response.data.message)
}
......@@ -174,19 +174,21 @@ export default class CreatePerusahaan extends Component {
errorSD: false,
errorED: false,
errorJL: false,
errorUB: false,
msgErrorNP: '',
msgErrorPC: '',
msgErrorSD: '',
msgErrorED: '',
msgErrorJL: '',
msgErrorUB: ''
})
}
validasiEdit() {
if (R.isEmpty(this.state.company)) {
this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' })
// } else if (R.isEmpty(this.state.totalReport)) {
// this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' })
} else if (R.isNil(this.state.getTypes)) {
this.setState({ errorUB: true, msgErrorUB: 'Unit Bisnis harus diisi' })
} else if (R.isNil(this.state.startDate)) {
this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.endDate)) {
......@@ -196,7 +198,7 @@ export default class CreatePerusahaan extends Component {
"company_id": this.state.companyID,
"company_name": this.state.company,
"business_unit_id": this.state.getTypes.business_unit_id,
"parent": this.state.getPerusahaan.company_id,
"parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
// "total_report": this.state.totalReport,
"start_date": this.state.startDate,
"end_date": this.state.endDate
......@@ -209,7 +211,7 @@ export default class CreatePerusahaan extends Component {
validasi() {
if (R.isEmpty(this.state.company)) {
this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' })
} else if (R.isNil(this.state.types)) {
} else if (R.isNil(this.state.getTypes)) {
this.setState({ errorUB: true, msgErrorUB: 'Unit Bisnis harus diisi' })
} else if (R.isNil(this.state.startDate)) {
this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' })
......@@ -217,12 +219,14 @@ export default class CreatePerusahaan extends Component {
this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' })
} else if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) {
return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai")
// } else if (R.isEmpty(this.state.totalReport)) {
}
// else if (R.isEmpty(this.state.totalReport)) {
// this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' })
} else {
// }
else {
let payload = {
"company_name": this.state.company,
"parent": this.state.getPerusahaan.company_id,
"parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
"business_unit_id": this.state.getTypes.business_unit_id,
// "total_report": this.state.totalReport,
"start_date": this.state.startDate,
......@@ -282,8 +286,17 @@ export default class CreatePerusahaan extends Component {
{...this.state.types}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue })}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Unit Bisnis" />}
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, ()=> this.clearError())}
renderInput={(params) =>
<TextField
{...params}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
label="Unit Bisnis"
error={this.state.errorUB}
helperText={this.state.msgErrorUB}
/>
}
value={this.state.getTypes}
/>
</div>
......@@ -510,14 +523,13 @@ export default class CreatePerusahaan extends Component {
{...this.state.types}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue })}
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, ()=> this.clearError())}
renderInput={(params) =>
<TextField
{...params}
label="Unit Bisnis"
margin="normal"
style={{marginTop: 7}}
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorUB}
helperText={this.state.msgErrorUB}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
......
......@@ -138,7 +138,7 @@ export default class EditPerusahaan extends Component {
"company_id": this.state.companyID,
"company_name": this.state.company,
"business_unit_id": this.state.getTypes.business_unit_id,
"parent": this.state.getPerusahaan.company_id,
"parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
"total_report": this.state.totalReport,
"start_date": this.state.startDate,
"end_date": this.state.endDate
......
......@@ -446,7 +446,7 @@ export default class Perusahaan extends Component {
{this.state.visiblePerusahaan === true ?
<div>
<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 - Perusahaan</label>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Perusahaan</label>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase
......@@ -457,7 +457,8 @@ export default class Perusahaan extends Component {
inputProps={{ 'aria-label': 'naked' }}
/>
</div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex', flexFlow: 'wrap' }}>
<div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
......@@ -469,6 +470,9 @@ export default class Perusahaan extends Component {
>
<img src={Images.template} />
</button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
......@@ -480,6 +484,9 @@ export default class Perusahaan extends Component {
>
<img src={Images.upload} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
......@@ -491,6 +498,9 @@ export default class Perusahaan extends Component {
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<a data-tip={'Visualisasi'} data-for="visual">
<button
style={{
backgroundColor: 'transparent',
......@@ -502,6 +512,9 @@ export default class Perusahaan extends Component {
>
<img src={Images.visualisasi} onClick={() => this.setState({ visibleVisual: true, visiblePerusahaan: false })} />
</button>
</a>
<ReactTooltip border={true} id="visual" place="bottom" type="light" effect="solid" />
<a data-tip={'Tambah'} data-for="create">
<button
style={{
backgroundColor: 'transparent',
......@@ -513,6 +526,8 @@ export default class Perusahaan extends Component {
>
<img src={Images.add} />
</button>
</a>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div>
</div>
<div style={{ padding: 25 }}>
......@@ -626,7 +641,7 @@ export default class Perusahaan extends Component {
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["pdf"]}
acceptedFiles={["xsls"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
......
import React, { Component } from "react";
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { createMuiTheme, MuiThemeProvider, withStyles } from '@material-ui/core/styles';
import Images from "../../assets/Images";
import MUIDataTable from "mui-datatables";
import { InputBase } from "@material-ui/core";
import { InputBase, Snackbar } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer';
import UploadFile from "../../library/Upload";
import MuiAlert from '@material-ui/lab/Alert';
import CreateReportItems from "./formReportItems/CreateReportItems";
import EditReportItems from "./formReportItems/EditReportItems";
import VisualReportItems from "./formReportItems/VisualReportItems";
......@@ -17,6 +18,9 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const options2 = ct.customOptions2();
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class ReportItems extends Component {
constructor(props) {
super(props)
......@@ -32,7 +36,10 @@ export default class ReportItems extends Component {
dataLoaded: false,
cols: null,
rows: null,
popupError: false
popupError: false,
alert: false,
tipeAlert: '',
messageAlert: ''
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -450,6 +457,7 @@ export default class ReportItems extends Component {
getData() {
api.create().getReportItems().then((response) => {
console.log(response)
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
......@@ -457,7 +465,10 @@ export default class ReportItems extends Component {
})
this.setState({ dataTable: listData, listData: response.data.data })
} 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' })
}
})
}
......@@ -482,6 +493,7 @@ export default class ReportItems extends Component {
}
api.create().searchReportItems(body).then(response => {
// console.log(response.data);
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
......@@ -489,7 +501,10 @@ export default class ReportItems extends Component {
})
this.setState({ dataTable: listData, listData: response.data.data })
} 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' })
}
})
}
......@@ -497,10 +512,15 @@ export default class ReportItems extends Component {
createReportItems = (payload) => {
this.setState({ add: false })
api.create().createReportItems(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') {
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} 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' })
}
})
}
......@@ -538,10 +558,15 @@ export default class ReportItems extends Component {
updateReportItems = (payload) => {
this.setState({ edit: false })
api.create().updateReportItems(payload).then(response => {
if (response.data) {
if (response.data.status == 'success') {
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} 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' })
}
})
}
......@@ -550,15 +575,22 @@ export default class ReportItems extends Component {
api.create().uploadReportItems(this.state.payload).then(response => {
if (response.data) {
if (response.data.status === "success") {
console.log(response)
alert(response.data.message)
this.getData()
this.setState({ itemReport: true })
this.setState({ itemReport: 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() {
const columns = [{
name: "Action",
......@@ -716,10 +748,15 @@ export default class ReportItems extends Component {
<div style={{ height: this.props.height }}>
{/* <Row> */}
<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.itemReport === true ?
<div>
<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 - Item Report</label>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Item Laporan</label>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase
......
......@@ -21,7 +21,7 @@ export default class CreateReportItems extends Component {
order: '',
description: '',
uom: '',
weight: null,
weight: '',
formula: '',
realVal: '',
condition: null,
......@@ -36,6 +36,14 @@ export default class CreateReportItems extends Component {
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
errorJenisLaporan: false,
errorPerusahaan: false,
msgErrorJenisLaporan: '',
msgErrorPerusahaan: '',
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
......@@ -66,15 +74,20 @@ export default class CreateReportItems extends Component {
handleChange(e, type) {
let data = this.state
let isDate = type !== ''? true : false
let isDate = type !== '' ? true : false
if (isDate && type === 'start_date') {
this.setState({...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
this.setState({
...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
......@@ -83,13 +96,18 @@ export default class CreateReportItems extends Component {
msgErrorED: '',
})
} else if (isDate && type === 'end_date') {
this.setState({...data, endDate : format(e, 'yyyy-MM-dd'),
this.setState({
...data, endDate: format(e, 'yyyy-MM-dd'),
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
......@@ -98,13 +116,18 @@ export default class CreateReportItems extends Component {
msgErrorED: '',
})
} else {
this.setState({...data, [e.target.name]: e.target.value,
this.setState({
...data, [e.target.name]: e.target.value,
errorOrder: false,
errorDesc: false,
errorFormula: false,
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
......@@ -117,27 +140,33 @@ export default class CreateReportItems extends Component {
validasi() {
// alert('coba ya')
if (R.isNil(this.state.reportType)) return alert("Jenis Laporan is Required.");
if (R.isNil(this.state.company)) return alert("Perusahaan is Required.");
else if (R.isEmpty(this.state.order)) {
this.setState({errorOrder: true, msgErrorOrder: 'Order Harus Diisi'})
if (R.isNil(this.state.reportType)) {
this.setState({errorJenisLaporan: true, msgErrorJenisLaporan: 'Jenis Laporan Harus Diisi'})
} else if (R.isNil(this.state.company)){
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Perusahaan Harus Diisi'})
} else if (R.isEmpty(this.state.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order Harus Diisi' })
}
else if (R.isEmpty(this.state.description)) {
this.setState({errorDesc: true, msgErrorDesc: 'Deskripsi Harus Diisi'})
this.setState({ errorDesc: true, msgErrorDesc: 'Deskripsi Harus Diisi' })
}
else if (R.isNil(this.state.InputType)) {
this.setState({ errorTipeData: true, msgErrorTipeData: 'Tipe Data Harus Diisi' })
}
else if (R.isNil(this.state.InputType)) return alert("Tipe Data is Required.")
else if (this.state.disabledFormula === false && R.isEmpty(this.state.formula)) {
this.setState({errorFormula: true, msgErrorFormula: 'Formula Harus Diisi'})
this.setState({ errorFormula: true, msgErrorFormula: 'Formula Harus Diisi' })
}
else if (this.state.disabledValue === false && R.isEmpty(this.state.realVal)) {
this.setState({errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi'})
this.setState({ errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi' })
}
else if (this.state.disabledCondt === false && R.isEmpty(this.state.condition)) {
this.setState({ errorCondition: true, msgErrorCondition: 'Kondisi Jika Salah Harus Diisi' })
}
else if (this.state.disabledCondt === false && R.isEmpty(this.state.condition)) return alert("Kondisi Jika Salah is Required.")
else if (R.isNil(this.state.startDate)) {
this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'})
this.setState({ errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong' })
}
else if (R.isNil(this.state.endDate)) {
this.setState({errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong'})
this.setState({ errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong' })
}
else {
this.addReportItems()
......@@ -162,23 +191,13 @@ export default class CreateReportItems extends Component {
"end_date": this.state.endDate
}
console.log(payload)
api.create().createReportItems(payload).then((response) => {
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
alert(response.data.message)
}
}
})
this.props.createReportItems(payload)
}
getInputType() {
api.create().getInputType().then((response) => {
console.log(response.data)
if(response.data.status === 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let inputData = data.map((item) => {
return {
......@@ -190,7 +209,7 @@ export default class CreateReportItems extends Component {
options: inputData,
getOptionLabel: (option) => titleCase(option.type_report_name),
};
this.setState({listInputType: defaultProps, inputData: response.data.data})
this.setState({ listInputType: defaultProps, inputData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -200,7 +219,7 @@ export default class CreateReportItems extends Component {
getPerusahaan() {
api.create().getPerusahaanActive().then((response) => {
// console.log(response)
if(response.data.status === 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let companyData = data.map((item) => {
return {
......@@ -212,7 +231,7 @@ export default class CreateReportItems extends Component {
options: companyData,
getOptionLabel: (option) => titleCase(option.company_name),
};
this.setState({listCompany: defaultProps, companyData: response.data.data})
this.setState({ listCompany: defaultProps, companyData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -222,7 +241,7 @@ export default class CreateReportItems extends Component {
getReportType() {
api.create().getReportType().then((response) => {
// console.log(response)
if(response.data.status === 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let reportTypeData = data.map((item) => {
return {
......@@ -234,7 +253,7 @@ export default class CreateReportItems extends Component {
options: reportTypeData,
getOptionLabel: (option) => titleCase(option.report_name),
};
this.setState({listReportType: defaultProps, reportTypeData: response.data.data})
this.setState({ listReportType: defaultProps, reportTypeData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -249,7 +268,7 @@ export default class CreateReportItems extends Component {
}
api.create().getReportParent(payload).then((response) => {
console.log(response)
if(response.data.status === 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let parentData = data.map((item) => {
return {
......@@ -261,7 +280,7 @@ export default class CreateReportItems extends Component {
options: parentData,
getOptionLabel: (option) => titleCase(option.description),
};
this.setState({listParent: defaultProps, parentData: response.data.data})
this.setState({ listParent: defaultProps, parentData: response.data.data })
} else {
alert(response.data.message)
}
......@@ -274,6 +293,19 @@ export default class CreateReportItems extends Component {
return value
}
clearMessage() {
this.setState({
errorFormula: false, msgErrorFormula: '',
errorTipeData: false,
errorCondition: false,
msgErrorTipeData: '',
msgErrorCondition: '',
errorRV: false, msgErrorRV: '',
errorJenisLaporan: false, msgErrorJenisLaporan: '',
errorPerusahaan: false, msgErrorPerusahaan: ''
})
}
render() {
return (
......@@ -291,7 +323,7 @@ export default class CreateReportItems extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -322,11 +354,11 @@ export default class CreateReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listReportType}
id="reportType"
onChange={(event, newInputValue) => this.setState({reportType: newInputValue})}
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, ()=> this.clearMessage())}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -338,6 +370,8 @@ export default class CreateReportItems extends Component {
color: '#7e8085'
}
}}
error={this.state.errorJenisLaporan}
helperText={this.state.msgErrorJenisLaporan}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.reportType}
......@@ -348,11 +382,11 @@ export default class CreateReportItems extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}} >
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }} >
<Autocomplete
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({company: newInputValue}, () => this.getParent())}
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => this.getParent(), this.clearMessage())}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -364,6 +398,8 @@ export default class CreateReportItems extends Component {
color: '#7e8085'
}
}}
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.company}
......@@ -377,11 +413,13 @@ export default class CreateReportItems extends Component {
id="orders"
name="order"
label="Order"
type="number"
onChange={(e) => this.handleChange(e, null)}
value={this.state.order}
error={this.state.errorOrder}
helperText={this.state.msgErrorOrder}
inputProps={{
min: 0,
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
......@@ -431,11 +469,11 @@ export default class CreateReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}} >
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }} >
<Autocomplete
{...this.state.listParent}
id="parentId"
onChange={(event, newInputValue) => this.setState({parent: newInputValue})}
onChange={(event, newInputValue) => this.setState({ parent: newInputValue })}
debug
disabled={this.state.reportType == null || this.state.company == null}
renderInput={(params) =>
......@@ -513,20 +551,45 @@ export default class CreateReportItems extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.listInputType}
id="inputType"
onChange={(event, newInputValue) => this.setState({InputType: newInputValue},
() => newInputValue === null ? this.setState({disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
: newInputValue.type_report_name === 'Formula' ? this.setState({disabledFormula: false, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
: newInputValue.type_report_name === 'Validation' ? this.setState({disabledFormula: false, disabledCondt: false, disabledValue: false, formula: '', condition: '', realVal: ''})
: this.setState({disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: ''})
onChange={(event, newInputValue) => this.setState({ InputType: newInputValue },
() => newInputValue === null ? this.setState({ disabledFormula: true, disabledCondt: true, disabledValue: true, formula: '', condition: '', realVal: '' })
: newInputValue.type_report_name === 'Formula' ?
this.setState({
disabledFormula: false,
disabledCondt: true,
disabledValue: true,
formula: '',
condition: '',
realVal: ''
}, () => this.clearMessage())
: newInputValue.type_report_name === 'Validation' ?
this.setState({
disabledFormula: false,
disabledCondt: false,
disabledValue: false,
formula: '',
condition: '',
realVal: ''
}, () => this.clearMessage())
: this.setState({
disabledFormula: true,
disabledCondt: true,
disabledValue: true,
formula: '',
condition: '',
realVal: ''
}, () => this.clearMessage())
)}
debug
renderInput={(params) =>
<TextField {...params}
label="Tipe Data"
error={this.state.errorTipeData}
helperText={this.state.msgErrorTipeData}
InputLabelProps={{
style: {
fontSize: 11,
......@@ -534,6 +597,8 @@ export default class CreateReportItems extends Component {
color: '#7e8085'
}
}}
error={this.state.errorTipeData}
helperText={this.state.msgErrorTipeData}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.InputType}
......@@ -573,7 +638,7 @@ export default class CreateReportItems extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="realVal"
......@@ -601,17 +666,19 @@ export default class CreateReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10, borderRadius: 5}}>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
value={this.state.condition}
id="isWrongCondition"
disabled={this.state.disabledCondt}
onChange={(event, newValue) => {
this.setState({condition: newValue});
this.setState({ condition: newValue }, () => this.clearMessage());
}}
options={this.state.options}
renderInput={(params) =>
<TextField {...params}
error={this.state.errorCondition}
helperText={this.state.msgErrorCondition}
label="Kondisi Jika Salah"
InputLabelProps={{
style: {
......@@ -620,7 +687,7 @@ export default class CreateReportItems extends Component {
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11,fontFamily: 'Nunito Sans, sans-serif' } }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
</div>
......@@ -656,7 +723,7 @@ export default class CreateReportItems extends Component {
}
}}
style={{padding: 0, margin: 0, width: '100%'}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......@@ -689,7 +756,7 @@ export default class CreateReportItems extends Component {
}
}}
style={{padding: 0, margin: 0, width: '100%'}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......@@ -722,16 +789,14 @@ export default class CreateReportItems extends Component {
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingBottom: 20, paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div style={{display: 'flex'}}>
<Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
<Typography style={{ fontSize: 11 }}>: Admin - 21 Jul 2020, 18:45</Typography>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11 }}>Dibuat :</Typography>
</div>
<div style={{display: 'flex'}}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: Admin - 21 Jul 2020, 18:45</Typography>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11 }}>Diubah :</Typography>
</div>
</div>
</div>
......@@ -748,7 +813,7 @@ export default class CreateReportItems extends Component {
</div>
</button>
</div>
<div className="column-2" style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'center'}}>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.validasi()}
......
import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core';
import { TextField, Typography, withStyles, Snackbar } from '@material-ui/core';
import { DatePicker } from '@material-ui/pickers';
import format from "date-fns/format";
import Autocomplete from '@material-ui/lab/Autocomplete';
import MuiAlert from '@material-ui/lab/Alert';
import api from '../../../api';
import * as R from 'ramda'
import { titleCase } from '../../../library/Utils';
import Images from '../../../assets/Images';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class EditReportItems extends Component {
constructor(props) {
......@@ -23,7 +26,7 @@ export default class EditReportItems extends Component {
order: null,
description: '',
uom: '',
weight: null,
weight: "",
formula: '',
realVal: '',
condition: null,
......@@ -38,16 +41,27 @@ export default class EditReportItems extends Component {
errorRV: false,
errorStartDate: false,
errorEndDate: false,
errorJenisLaporan: false,
errorPerusahaan: false,
msgErrorJenisLaporan: '',
msgErrorPerusahaan: '',
msgErrorOrder: '',
msgErrorDesc: '',
msgErrorFormula: '',
errorTipeData: false,
msgErrorTipeData: '',
errorCondition: false,
msgErrorCondition: '',
msgErrorRV: '',
msgErrorSD: '',
msgErrorED: '',
disabledFormula: true,
disabledCondt: true,
disabledValue: true,
options: ['WARNING', 'STOPPER']
options: ['WARNING', 'STOPPER'],
alert: false,
tipeAlert: '',
messageAlert: ''
}
}
......@@ -113,21 +127,23 @@ export default class EditReportItems extends Component {
validasi() {
// alert('coba ya')
if (R.isNil(this.state.reportType)) return alert("Jenis Laporan is Required.");
if (R.isNil(this.state.company)) return alert("Perusahaan is Required.");
else if (R.isEmpty(this.state.tempData.order)) {
this.setState({errorOrder: true, msgErrorOrder: 'Order Harus Diisi'})
if (R.isNil(this.state.reportType)){
this.setState({errorJenisLaporan: true, msgErrorJenisLaporan: 'Jenis Laporan Harus Diisi'})
} else if (R.isNil(this.state.company)){
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Perusahaan Harus Diisi'})
} else if (R.isEmpty(this.state.tempData.order)) {
this.setState({ errorOrder: true, msgErrorOrder: 'Order Harus Diisi' })
} else if (R.isEmpty(this.state.tempData.description)) {
this.setState({errorDesc: true, msgErrorDesc: 'Deskripsi Harus Diisi'})
} else if (R.isNil(this.state.InputType)) return alert("Tipe Data harus dipilih.")
else if (this.state.InputType.type_report_name === 'Formula' || this.state.InputType.type_report_name === 'Validation' && R.isEmpty(this.state.tempData.formula)) {
this.setState({errorFormula: true, msgErrorFormula: 'Formula Harus Diisi'})
}
else if (this.state.InputType.type_report_name === 'Validation' && R.isEmpty(this.state.tempData.condition_it_should_be)) {
this.setState({errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi'})
}
else if (this.state.InputType.type_report_name === 'Validation' && R.isNil(this.state.condition)) return alert("Kondisi Jika Salah is Required.");
else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorDesc: true, msgErrorDesc: 'Deskripsi Harus Diisi' })
} else if (R.isNil(this.state.InputType)) {
this.setState({ errorTipeData: true, msgErrorTipeData: 'Tipe Data Harus Diisi' })
} else if ((this.state.InputType.type_report_name === 'Formula' && R.isEmpty(this.state.tempData.formula)) || (this.state.InputType.type_report_name === 'Validation' && R.isEmpty(this.state.tempData.formula))) {
this.setState({ errorFormula: true, msgErrorFormula: 'Formula Harus Diisi' })
} else if (this.state.InputType.type_report_name === 'Validation' && R.isEmpty(this.state.tempData.condition_it_should_be)) {
this.setState({ errorRV: true, msgErrorRV: 'Nilai Seharusnya Harus Diisi' })
} else if (this.state.InputType.type_report_name === 'Validation' && R.isNil(this.state.tempData.condition_if_wrong)) {
this.setState({ errorCondition: true, msgErrorCondition: 'Kondisi Jika Salah Harus Diisi' })
} else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorSD: 'Start Date Harus Diisi' })
} else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorED: 'End Date Harus Diisi' })
......@@ -141,40 +157,35 @@ export default class EditReportItems extends Component {
// alert('test')
let payload = {
"item_report_id": this.state.tempData.item_report_id,
"report_id": this.state.reportType == null? this.state.tempData.report_id : this.state.reportType.report_id,
"company_id": this.state.company == null? this.state.tempData.company_id : this.state.company.company_id,
"report_id": this.state.reportType == null ? this.state.tempData.report_id : this.state.reportType.report_id,
"company_id": this.state.company == null ? this.state.tempData.company_id : this.state.company.company_id,
"description": this.state.tempData.description,
"orders": this.state.tempData.order,
"parent": this.state.parent == null? this.state.tempData.parent : this.state.parent.item_report_id,
"type_report_id": this.state.InputType == null? this.state.tempData.type_report_id : this.state.InputType.type_report_id,
"parent": this.state.parent == null ? this.state.tempData.parent : this.state.parent.item_report_id,
"type_report_id": this.state.InputType == null ? this.state.tempData.type_report_id : this.state.InputType.type_report_id,
"formula": this.state.tempData.formula,
"uom": this.state.tempData.uom,
"weight": this.state.tempData.weight,
"weight": this.state.tempData.weight == null ? "" : this.state.tempData.weight,
"condition_if_wrong": this.state.tempData.condition_if_wrong,
"condition_it_should_be": this.state.tempData.condition_it_should_be,
"start_date": this.state.tempData.start_date,
"end_date": this.state.tempData.end_date
}
console.log(payload)
// api.create().updateReportItems(payload).then((response) => {
// if (response.data) {
// if (response.data.status === 'success') {
// this.props.onClickClose()
// this.props.refresh()
// } else {
// alert(response.data.message)
// }
// }
// })
this.props.updateReportItems(payload)
}
getDetailReportItems() {
api.create().getDetailReportItems(this.props.data[1]).then((response) => {
if (response.data) {
if (response.data.status === 'success') {
this.setState({ tempData: response.data.data}, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),)
this.setState({ tempData: response.data.data }, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),)
console.log(response.data.data)
} 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' })
}
})
}
......@@ -182,7 +193,8 @@ export default class EditReportItems extends Component {
getInputType() {
api.create().getInputType().then((response) => {
// console.log(response)
if(response.data.status === 'success') {
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let inputData = data.map((item) => {
return {
......@@ -196,9 +208,12 @@ export default class EditReportItems extends Component {
};
let index = inputData.findIndex((val) => val.type_report_id === this.state.tempData.type_report_id)
this.setState({listInputType: defaultProps, InputType: index === -1 ? null : inputData[index]})
this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -206,7 +221,8 @@ export default class EditReportItems extends Component {
getPerusahaan() {
api.create().getPerusahaanActive().then((response) => {
console.log(response)
if(response.data.status === 'success') {
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let companyData = data.map((item) => {
return {
......@@ -220,9 +236,12 @@ export default class EditReportItems extends Component {
};
let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
this.setState({listCompany: defaultProps, company: index === -1 ? null : companyData[index]}, () => this.getParent())
this.setState({ listCompany: defaultProps, company: index === -1 ? null : companyData[index] }, () => this.getParent())
} 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' })
}
})
}
......@@ -230,7 +249,8 @@ export default class EditReportItems extends Component {
getReportType() {
api.create().getReportType().then((response) => {
console.log(response)
if(response.data.status === 'success') {
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let reportTypeData = data.map((item) => {
return {
......@@ -244,9 +264,12 @@ export default class EditReportItems extends Component {
};
let index = reportTypeData.findIndex((val) => val.report_id === this.state.tempData.report_id)
this.setState({listReportType: defaultProps, reportType: index === -1 ? null: reportTypeData[index]}, () => this.getParent())
this.setState({ listReportType: defaultProps, reportType: index === -1 ? null : reportTypeData[index] }, () => this.getParent())
} 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' })
}
})
}
......@@ -259,7 +282,8 @@ export default class EditReportItems extends Component {
}
api.create().getReportParent(payload).then((response) => {
console.log(response)
if(response.data.status === 'success') {
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let parentData = data.map((item) => {
return {
......@@ -272,12 +296,30 @@ export default class EditReportItems extends Component {
getOptionLabel: (option) => titleCase(option.description),
};
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent)
this.setState({listParent: defaultProps, parent: index == -1? null : parentData[index]})
this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
alert(response.data.message)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
}
clearMessage() {
this.setState({
errorFormula: false, msgErrorFormula: '',
errorTipeData: false, msgErrorTipeData: '',
errorCondition: false, msgErrorCondition: '',
errorRV: false, msgErrorRV: '',
errorJenisLaporan: false, msgErrorJenisLaporan: '',
errorPerusahaan: false, msgErrorPerusahaan: ''
})
}
closeAlert() {
this.setState({ alert: false })
}
render() {
......@@ -297,21 +339,25 @@ export default class EditReportItems extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
<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="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={this.state.tempData === null ? '' : this.state.tempData.item_report_id}
id="ID"
label="ID"
disabled
variant="filled"
onChange={(e) => null}
inputProps={{
style: {
......@@ -330,11 +376,11 @@ export default class EditReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10}}>
<div className="margin-top-10px" style={{ padding: 10 }}>
<Autocomplete
{...this.state.listReportType}
id="reportType"
onChange={(event, newInputValue) => this.setState({reportType: newInputValue}, () => this.getParent())}
onChange={(event, newInputValue) => this.setState({ reportType: newInputValue }, () => this.getParent(), this.clearMessage() )}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -346,6 +392,8 @@ export default class EditReportItems extends Component {
color: '#7e8085'
}
}}
error={this.state.errorJenisLaporan}
helperText={this.state.msgErrorJenisLaporan}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.reportType}
......@@ -355,11 +403,11 @@ export default class EditReportItems extends Component {
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{padding: 10}} >
<div className="margin-top-10px" style={{ padding: 10 }} >
<Autocomplete
{...this.state.listCompany}
id="company"
onChange={(event, newInputValue) => this.setState({company: newInputValue}, () => this.getParent())}
onChange={(event, newInputValue) => this.setState({ company: newInputValue }, () => this.getParent(), this.clearMessage())}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -371,6 +419,8 @@ export default class EditReportItems extends Component {
color: '#7e8085'
}
}}
error={this.state.errorPerusahaan}
helperText={this.state.msgErrorPerusahaan}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.company}
......@@ -384,11 +434,13 @@ export default class EditReportItems extends Component {
id="order"
label="Order"
name="order"
type="number"
value={this.state.tempData === null ? '' : this.state.tempData.order}
error={this.state.errorOrder}
helperText={this.state.msgErrorOrder}
onChange={(e) => this.handleChange(e, '')}
inputProps={{
min: 0,
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif'
......@@ -436,11 +488,11 @@ export default class EditReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10}} >
<div className="margin-top-10px" style={{ padding: 10 }} >
<Autocomplete
{...this.state.listParent}
id="parentId"
onChange={(event, newInputValue) => this.setState({parent: newInputValue})}
onChange={(event, newInputValue) => this.setState({ parent: newInputValue })}
disabled={this.state.reportType == null || this.state.company == null}
debug
renderInput={(params) =>
......@@ -516,16 +568,16 @@ export default class EditReportItems extends Component {
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<div className="margin-top-10px" style={{padding: 10}}>
<div className="margin-top-10px" style={{ padding: 10 }}>
<Autocomplete
{...this.state.listInputType}
id="inputType"
onChange={(event, newInputValue) =>
this.setState({InputType: newInputValue,
tempData: {...this.state.tempData, formula: '', condition_it_should_be: '', condition_if_wrong: ''},
errorFormula: false, msgErrorFormula: '',
errorRV: false, msgErrorRV: ''},
() => console.log(this.state.InputType))}
this.setState({
InputType: newInputValue,
tempData: { ...this.state.tempData, formula: '', condition_it_should_be: '', condition_if_wrong: '' },
},
() => console.log(this.state.InputType), this.clearMessage())}
debug
renderInput={(params) =>
<TextField {...params}
......@@ -537,6 +589,8 @@ export default class EditReportItems extends Component {
color: '#7e8085'
}
}}
error={this.state.errorTipeData}
helperText={this.state.msgErrorTipeData}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
value={this.state.InputType}
......@@ -549,7 +603,7 @@ export default class EditReportItems extends Component {
style={{ width: '100%' }}
id="formula"
label="Formula"
disabled={this.state.InputType == null? true : (this.state.InputType.type_report_name === 'Formula' || this.state.InputType.type_report_name === 'Validation'? false : true)}
disabled={this.state.InputType == null ? true : (this.state.InputType.type_report_name === 'Formula' || this.state.InputType.type_report_name === 'Validation' ? false : true)}
name="formula"
error={this.state.errorFormula}
helperText={this.state.msgErrorFormula}
......@@ -582,7 +636,7 @@ export default class EditReportItems extends Component {
label="Nilai Seharusnya"
error={this.state.errorRV}
helperText={this.state.msgErrorRV}
disabled={this.state.InputType == null? true : (this.state.InputType.type_report_name === 'Validation'? false : true)}
disabled={this.state.InputType == null ? true : (this.state.InputType.type_report_name === 'Validation' ? false : true)}
name="condition_it_should_be"
onChange={(e) => this.handleChange(e, '')}
value={this.state.tempData === null ? '' : this.state.tempData.condition_it_should_be}
......@@ -603,13 +657,13 @@ export default class EditReportItems extends Component {
</div>
</div>
<div className="column-2">
<div className="margin-top-10px" style={{padding: 10}}>
<div className="margin-top-10px" style={{ padding: 10 }}>
<Autocomplete
value={this.state.tempData === null ? '' : this.state.tempData.condition}
value={this.state.tempData === null ? "" : this.state.tempData.condition_if_wrong}
id="isWrongCondition"
disabled={this.state.InputType == null? true : (this.state.InputType.type_report_name === 'Validation'? false : true)}
disabled={this.state.InputType == null ? true : (this.state.InputType.type_report_name === 'Validation' ? false : true)}
onChange={(event, newValue) => {
this.setState({condition: newValue});
this.setState({ tempData: { ...this.state.tempData, condition_if_wrong: newValue } }, () => this.clearMessage());
}}
options={this.state.options}
renderInput={(params) =>
......@@ -622,6 +676,8 @@ export default class EditReportItems extends Component {
color: '#7e8085'
}
}}
error={this.state.errorCondition}
helperText={this.state.msgErrorCondition}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>}
/>
......@@ -694,16 +750,16 @@ export default class EditReportItems extends Component {
</div>
</div>
</div>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}>
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingBottom: 20, paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1">
<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 }}>: Admin - 21 Jul 2020, 18:45</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.created}</Typography>
</div>
<div style={{display: 'flex'}}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: Admin - 21 Jul 2020, 18:45</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.tempData === null ? "" : this.state.tempData.updated}</Typography>
</div>
</div>
</div>
......
......@@ -134,6 +134,21 @@ export default class AddUser extends Component {
}
}
clearError() {
this.setState({
errorFullname: false,
errorEmail: false,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
}
isEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
......@@ -272,6 +287,8 @@ export default class AddUser extends Component {
padding = 20
}
return (
<div>
{item.children.length > 0 && (
<ul>
{item.children.map((data, index) => {
return (
......@@ -313,6 +330,8 @@ export default class AddUser extends Component {
)
})}
</ul>
)}
</div>
)
}
......@@ -498,7 +517,7 @@ export default class AddUser extends Component {
<Autocomplete
{...this.state.listRole}
id="role"
onChange={(event, newInputValue) => this.setState({ role: newInputValue })}
onChange={(event, newInputValue) => this.setState({ role: newInputValue }, ()=> this.clearError())}
debug
renderInput={(params) =>
<TextField
......@@ -662,8 +681,8 @@ export default class AddUser extends Component {
</div>
</div>
<div style={{ flexDirection: 'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{ fontSize: 12 }}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', { locale: localeID })}`}</Typography>
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography> */}
<Typography style={{ fontSize: 12 }}>{`Dibuat: `}</Typography>
<Typography style={{fontSize: 12}}>{`Diubah: `}</Typography>
</div>
<Divider style={{ margin: 20 }} />
<div style={{ paddingLeft: 20, paddingRight: 20 }}>
......
......@@ -121,6 +121,21 @@ export default class EditUser extends Component {
}
}
clearError() {
this.setState({
errorFullname: false,
errorEmail: false,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
}
getDetailUser() {
api.create().getDetailUser(this.state.paramsId).then((response) => {
this.getRole()
......@@ -274,6 +289,8 @@ export default class EditUser extends Component {
padding = 20
}
return (
<div>
{item.children.length > 0 && (
<ul>
{item.children.map((data, index) => {
return (
......@@ -315,6 +332,8 @@ export default class EditUser extends Component {
)
})}
</ul>
)}
</div>
)
}
......@@ -497,7 +516,7 @@ export default class EditUser extends Component {
<Autocomplete
{...this.state.listRole}
id="role"
onChange={(event, newInputValue) => this.setState({ role: newInputValue })}
onChange={(event, newInputValue) => this.setState({ role: newInputValue }, ()=> this.clearError())}
debug
renderInput={(params) => <TextField
......
......@@ -116,7 +116,7 @@ export default class AddRole extends Component {
} else if (R.isNil(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong' })
} else if (this.state.privileges.length < 1) {
alert('Hak Akses belum di pilih !!')
this.setState({ alert: true, messageAlert: 'Hak Akses belum di pilih !!', tipeAlert: 'warning' })
} else {
this.addRole()
}
......@@ -468,8 +468,8 @@ export default class AddRole extends Component {
</div>
</div>
<div style={{ flexDirection: 'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{ fontSize: 12 }}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', { locale: localeID })}`}</Typography>
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography> */}
<Typography style={{ fontSize: 12 }}>{`Dibuat: `}</Typography>
<Typography style={{fontSize: 12}}>{`Diubah: `}</Typography>
</div>
<Divider style={{ margin: 20 }} />
<div style={{ paddingLeft: 20, paddingRight: 20 }}>
......
......@@ -122,7 +122,7 @@ export default class EditRole extends Component {
} else if (R.isNil(this.state.tempData.end_date)) {
this.setState({ errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong' })
} else if (this.state.privileges.length < 1) {
alert('Hak Akses belum di pilih !!')
this.setState({ alert: true, messageAlert: 'Hak Akses belum di pilih !!', tipeAlert: 'warning' })
} else {
this.updateRole()
}
......
import React, { Component } from 'react';
import { Typography, AppBar, Tabs, Tab, TextField, Collapse, withStyles, Checkbox, InputAdornment, IconButton } from '@material-ui/core';
import { Typography, AppBar, Tabs, Tab, TextField, Snackbar, Collapse, withStyles, Checkbox, InputAdornment, IconButton } from '@material-ui/core';
import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff';
import HomePage from './HomePage';
import MuiAlert from '@material-ui/lab/Alert';
import Images from '../assets/Images';
import api from '../api';
import Constant from '../library/Constant';
......@@ -22,6 +22,9 @@ const CustomCheckbox = withStyles({
checked: {},
})((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class Profile extends Component {
constructor(props) {
super(props)
......@@ -43,7 +46,10 @@ export default class Profile extends Component {
showPass2: false,
showPass3: false,
pictures: [],
name: ""
name: "",
alert: false,
tipeAlert: '',
messageAlert: ''
}
this.onDrop = this.onDrop.bind(this);
}
......@@ -111,12 +117,22 @@ export default class Profile extends Component {
api.create().changePassword(body).then(response => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.setState({ oldPassword: "", password: "", confirmPassword: "" })
localStorage.removeItem(Constant.TOKEN)
setTimeout(() => {
window.location.reload();
}, 1000);
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
alert(response.data.message)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
......@@ -136,11 +152,20 @@ export default class Profile extends Component {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
this.setState({ company: response.data.data.company, photo: response.data.data.photo, name: response.data.data.fullname })
console.log(response)
} 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' })
}
})
}
......@@ -148,10 +173,18 @@ export default class Profile extends Component {
api.create().getPerusahaanHierarki().then((response) => {
// console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
this.setState({ listCompany: 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' })
}
})
}
......@@ -169,6 +202,8 @@ export default class Profile extends Component {
padding = 20
}
return (
<div>
{item.children.length > 0 && (
<ul>
{item.children.map((data, index) => {
return (
......@@ -199,6 +234,8 @@ export default class Profile extends Component {
)
})}
</ul>
)}
</div>
)
}
......@@ -269,20 +306,40 @@ export default class Profile extends Component {
api.create().uploadFoto(formData).then(response => {
console.log(response)
if (response.data) {
if (response.ok){
if (response.data.status === "success") {
this.setState({ uploadVisible: false }, () => {
alert(response.data.message)
this.getUser()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }, () => {
setTimeout(() => {
window.location.reload()
}, 1000);
})
})
} 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() {
return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<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={"main-color"} style={{ height: 203, flex: 1, display: 'flex', alignItems: 'flex-end', padding: 20 }}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
......
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