Commit f6c27c4e authored by faisalhamdi's avatar faisalhamdi

merge conflict

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