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') {
}
else if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a,b) => a.approval_matrix_id - b.approval_matrix_id).map((item, index) => { 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 ] 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 { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -299,6 +304,7 @@ export default class ApprovalMatrix extends Component { ...@@ -299,6 +304,7 @@ 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) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
...@@ -306,7 +312,10 @@ export default class ApprovalMatrix extends Component { ...@@ -306,7 +312,10 @@ export default class ApprovalMatrix extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -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) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
alert(response.data.message)
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
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) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
alert(response.data.message)
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -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) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
alert(response.data.message)
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
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)
if (response.data) {
if (response.data.status === "success") {
// console.log(this.state.payload) // console.log(this.state.payload)
this.getData() this.getData()
this.setState({ visibleAM: true }) this.setState({ visibleAM: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -494,7 +527,12 @@ export default class ApprovalMatrix extends Component { ...@@ -494,7 +527,12 @@ 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()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div class="main-color" style={{ height: 199, width: '100%' }} />
<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={{ 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>
...@@ -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>
...@@ -591,7 +629,7 @@ export default class ApprovalMatrix extends Component { ...@@ -591,7 +629,7 @@ export default class ApprovalMatrix extends Component {
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)}
/> />
: :
...@@ -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,10 +328,10 @@ export default class CreateParameter extends Component { ...@@ -328,10 +328,10 @@ 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)) {
...@@ -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}
...@@ -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
} }
...@@ -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
} }
...@@ -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,
...@@ -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
} }
...@@ -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,6 +42,7 @@ export default class Parameter extends Component { ...@@ -42,6 +42,7 @@ export default class Parameter extends Component {
getAllParameter() { getAllParameter() {
api.create().getAllParameter().then(response => { api.create().getAllParameter().then(response => {
if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response); console.log(response);
let data = response.data.data let data = response.data.data
...@@ -61,7 +62,10 @@ export default class Parameter extends Component { ...@@ -61,7 +62,10 @@ export default class Parameter extends Component {
}) })
this.setState({ dataTable: listData, data: response.data.data }) this.setState({ dataTable: listData, data: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -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,7 +457,8 @@ export default class Perusahaan extends Component { ...@@ -457,7 +457,8 @@ 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' }}>
<a data-tip={'Download Template'} data-for="template">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -469,6 +470,9 @@ export default class Perusahaan extends Component { ...@@ -469,6 +470,9 @@ export default class Perusahaan extends Component {
> >
<img src={Images.template} /> <img src={Images.template} />
</button> </button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -480,6 +484,9 @@ export default class Perusahaan extends Component { ...@@ -480,6 +484,9 @@ export default class Perusahaan extends Component {
> >
<img src={Images.upload} /> <img src={Images.upload} />
</button> </button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -491,6 +498,9 @@ export default class Perusahaan extends Component { ...@@ -491,6 +498,9 @@ export default class Perusahaan extends Component {
> >
<img src={Images.download} /> <img src={Images.download} />
</button> </button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<a data-tip={'Visualisasi'} data-for="visual">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -502,6 +512,9 @@ export default class Perusahaan extends Component { ...@@ -502,6 +512,9 @@ export default class Perusahaan extends Component {
> >
<img src={Images.visualisasi} onClick={() => this.setState({ visibleVisual: true, visiblePerusahaan: false })} /> <img src={Images.visualisasi} onClick={() => this.setState({ visibleVisual: true, visiblePerusahaan: false })} />
</button> </button>
</a>
<ReactTooltip border={true} id="visual" place="bottom" type="light" effect="solid" />
<a data-tip={'Tambah'} data-for="create">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -513,6 +526,8 @@ export default class Perusahaan extends Component { ...@@ -513,6 +526,8 @@ export default class Perusahaan extends Component {
> >
<img src={Images.add} /> <img src={Images.add} />
</button> </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,6 +457,7 @@ export default class ReportItems extends Component { ...@@ -450,6 +457,7 @@ 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) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => { let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
...@@ -457,7 +465,10 @@ export default class ReportItems extends Component { ...@@ -457,7 +465,10 @@ export default class ReportItems extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -482,6 +493,7 @@ export default class ReportItems extends Component { ...@@ -482,6 +493,7 @@ 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) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
...@@ -489,7 +501,10 @@ export default class ReportItems extends Component { ...@@ -489,7 +501,10 @@ export default class ReportItems extends Component {
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -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) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -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) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -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: '',
...@@ -66,15 +74,20 @@ export default class CreateReportItems extends Component { ...@@ -66,15 +74,20 @@ export default class CreateReportItems extends Component {
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,27 +140,33 @@ export default class CreateReportItems extends Component { ...@@ -117,27 +140,33 @@ 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)) {
this.setState({ errorTipeData: true, msgErrorTipeData: 'Tipe Data Harus Diisi' })
} }
else if (R.isNil(this.state.InputType)) return alert("Tipe Data is Required.")
else if (this.state.disabledFormula === false && R.isEmpty(this.state.formula)) { 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 {
...@@ -190,7 +209,7 @@ export default class CreateReportItems extends Component { ...@@ -190,7 +209,7 @@ export default class CreateReportItems extends Component {
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 {
...@@ -212,7 +231,7 @@ export default class CreateReportItems extends Component { ...@@ -212,7 +231,7 @@ export default class CreateReportItems extends Component {
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 {
...@@ -234,7 +253,7 @@ export default class CreateReportItems extends Component { ...@@ -234,7 +253,7 @@ export default class CreateReportItems extends Component {
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)
} }
...@@ -249,7 +268,7 @@ export default class CreateReportItems extends Component { ...@@ -249,7 +268,7 @@ export default class CreateReportItems 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.status === 'success') {
let data = response.data.data let data = response.data.data
let parentData = data.map((item) => { let parentData = data.map((item) => {
return { return {
...@@ -261,7 +280,7 @@ export default class CreateReportItems extends Component { ...@@ -261,7 +280,7 @@ export default class CreateReportItems extends Component {
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,11 +354,11 @@ export default class CreateReportItems extends Component { ...@@ -322,11 +354,11 @@ 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}
...@@ -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,11 +382,11 @@ export default class CreateReportItems extends Component { ...@@ -348,11 +382,11 @@ export default class CreateReportItems extends Component {
<div className="grid grid-2x grid-mobile-none gap-15px" style={{ paddingLeft: 20, paddingRight: 20 }}> <div className="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}
...@@ -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}
...@@ -377,11 +413,13 @@ export default class CreateReportItems extends Component { ...@@ -377,11 +413,13 @@ export default class CreateReportItems extends Component {
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',
...@@ -431,11 +469,11 @@ export default class CreateReportItems extends Component { ...@@ -431,11 +469,11 @@ 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) =>
...@@ -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}
...@@ -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,17 +666,19 @@ export default class CreateReportItems extends Component { ...@@ -601,17 +666,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 }}>
<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}
error={this.state.errorCondition}
helperText={this.state.msgErrorCondition}
label="Kondisi Jika Salah" label="Kondisi Jika Salah"
InputLabelProps={{ InputLabelProps={{
style: { style: {
...@@ -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>
...@@ -656,7 +723,7 @@ export default class CreateReportItems extends Component { ...@@ -656,7 +723,7 @@ export default class CreateReportItems extends Component {
} }
}} }}
style={{padding: 0, margin: 0, width: '100%'}} style={{ padding: 0, margin: 0, width: '100%' }}
/> />
</div> </div>
</div> </div>
...@@ -689,7 +756,7 @@ export default class CreateReportItems extends Component { ...@@ -689,7 +756,7 @@ export default class CreateReportItems extends Component {
} }
}} }}
style={{padding: 0, margin: 0, width: '100%'}} style={{ padding: 0, margin: 0, width: '100%' }}
/> />
</div> </div>
</div> </div>
...@@ -722,16 +789,14 @@ export default class CreateReportItems extends Component { ...@@ -722,16 +789,14 @@ export default class CreateReportItems extends Component {
</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,7 +813,7 @@ export default class CreateReportItems extends Component { ...@@ -748,7 +813,7 @@ 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) {
...@@ -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,16 +41,27 @@ export default class EditReportItems extends Component { ...@@ -38,16 +41,27 @@ 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: ''
} }
} }
...@@ -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) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ tempData: response.data.data}, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),) this.setState({ tempData: response.data.data }, () => this.getInputType(), this.getPerusahaan(), this.getReportType(),)
console.log(response.data.data) console.log(response.data.data)
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -182,7 +193,8 @@ export default class EditReportItems extends Component { ...@@ -182,7 +193,8 @@ 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) {
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 {
...@@ -196,9 +208,12 @@ export default class EditReportItems extends Component { ...@@ -196,9 +208,12 @@ export default class EditReportItems extends Component {
}; };
let index = inputData.findIndex((val) => val.type_report_id === this.state.tempData.type_report_id) let index = inputData.findIndex((val) => val.type_report_id === this.state.tempData.type_report_id)
this.setState({listInputType: defaultProps, InputType: index === -1 ? null : inputData[index]}) this.setState({ listInputType: defaultProps, InputType: index === -1 ? null : inputData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -206,7 +221,8 @@ export default class EditReportItems extends Component { ...@@ -206,7 +221,8 @@ 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) {
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 {
...@@ -220,9 +236,12 @@ export default class EditReportItems extends Component { ...@@ -220,9 +236,12 @@ export default class EditReportItems extends Component {
}; };
let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id) let index = companyData.findIndex((val) => val.company_id === this.state.tempData.company_id)
this.setState({listCompany: defaultProps, company: index === -1 ? null : companyData[index]}, () => this.getParent()) this.setState({ listCompany: defaultProps, company: index === -1 ? null : companyData[index] }, () => this.getParent())
} else { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -230,7 +249,8 @@ export default class EditReportItems extends Component { ...@@ -230,7 +249,8 @@ 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) {
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 {
...@@ -244,9 +264,12 @@ export default class EditReportItems extends Component { ...@@ -244,9 +264,12 @@ export default class EditReportItems extends Component {
}; };
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 { } else {
alert(response.data.message) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -259,7 +282,8 @@ export default class EditReportItems extends Component { ...@@ -259,7 +282,8 @@ 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) {
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 {
...@@ -272,12 +296,30 @@ export default class EditReportItems extends Component { ...@@ -272,12 +296,30 @@ export default class EditReportItems extends Component {
getOptionLabel: (option) => titleCase(option.description), getOptionLabel: (option) => titleCase(option.description),
}; };
let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent) let index = parentData.findIndex((val) => val.item_report_id === this.state.tempData.parent)
this.setState({listParent: defaultProps, parent: index == -1? null : parentData[index]}) this.setState({ listParent: defaultProps, parent: index == -1 ? null : parentData[index] })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else { } 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() {
...@@ -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,11 +376,11 @@ export default class EditReportItems extends Component { ...@@ -330,11 +376,11 @@ 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}
...@@ -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,11 +403,11 @@ export default class EditReportItems extends Component { ...@@ -355,11 +403,11 @@ 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}
...@@ -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'
...@@ -436,11 +488,11 @@ export default class EditReportItems extends Component { ...@@ -436,11 +488,11 @@ 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) =>
...@@ -516,16 +568,16 @@ export default class EditReportItems extends Component { ...@@ -516,16 +568,16 @@ 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}
...@@ -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,7 +636,7 @@ export default class EditReportItems extends Component { ...@@ -582,7 +636,7 @@ 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}
...@@ -603,13 +657,13 @@ export default class EditReportItems extends Component { ...@@ -603,13 +657,13 @@ 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) =>
...@@ -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,6 +287,8 @@ export default class AddUser extends Component { ...@@ -272,6 +287,8 @@ export default class AddUser extends Component {
padding = 20 padding = 20
} }
return ( return (
<div>
{item.children.length > 0 && (
<ul> <ul>
{item.children.map((data, index) => { {item.children.map((data, index) => {
return ( return (
...@@ -313,6 +330,8 @@ export default class AddUser extends Component { ...@@ -313,6 +330,8 @@ export default class AddUser extends Component {
) )
})} })}
</ul> </ul>
)}
</div>
) )
} }
...@@ -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,6 +289,8 @@ export default class EditUser extends Component { ...@@ -274,6 +289,8 @@ export default class EditUser extends Component {
padding = 20 padding = 20
} }
return ( return (
<div>
{item.children.length > 0 && (
<ul> <ul>
{item.children.map((data, index) => { {item.children.map((data, index) => {
return ( return (
...@@ -315,6 +332,8 @@ export default class EditUser extends Component { ...@@ -315,6 +332,8 @@ export default class EditUser extends Component {
) )
})} })}
</ul> </ul>
)}
</div>
) )
} }
...@@ -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.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.setState({ oldPassword: "", password: "", confirmPassword: "" }) this.setState({ oldPassword: "", password: "", confirmPassword: "" })
localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
setTimeout(() => {
window.location.reload(); window.location.reload();
}, 1000);
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
} }
alert(response.data.message) } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -136,11 +152,20 @@ export default class Profile extends Component { ...@@ -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) {
if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.setState({ company: response.data.data.company, photo: response.data.data.photo, name: response.data.data.fullname }) this.setState({ company: response.data.data.company, photo: response.data.data.photo, name: response.data.data.fullname })
console.log(response) 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.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.setState({ listCompany: response.data.data }) this.setState({ listCompany: response.data.data })
console.log(response.data.data) console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
} }
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -169,6 +202,8 @@ export default class Profile extends Component { ...@@ -169,6 +202,8 @@ export default class Profile extends Component {
padding = 20 padding = 20
} }
return ( return (
<div>
{item.children.length > 0 && (
<ul> <ul>
{item.children.map((data, index) => { {item.children.map((data, index) => {
return ( return (
...@@ -199,6 +234,8 @@ export default class Profile extends Component { ...@@ -199,6 +234,8 @@ export default class Profile extends Component {
) )
})} })}
</ul> </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.ok){
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ uploadVisible: false }, () => { this.setState({ uploadVisible: false }, () => {
alert(response.data.message)
this.getUser() this.getUser()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' }, () => {
setTimeout(() => {
window.location.reload() 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