Commit d2afc224 authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

update apprv matrix

parent 32966a92
......@@ -45,6 +45,7 @@ export default class ApprovalMatrix extends Component {
btncreate: false,
btnedit: false,
load: false,
judul: '',
}
this.fileHandler = this.fileHandler.bind(this);
}
......@@ -52,11 +53,11 @@ export default class ApprovalMatrix extends Component {
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
// console.log(resp)
if (err) {
// console.log(err);
console.log(err);
}
else {
let judul = resp.rows[2]
let isi = resp.rows.slice(3)
let payload = []
isi.map((item, index) => {
......@@ -75,11 +76,17 @@ export default class ApprovalMatrix extends Component {
let body = {
approval_matrix: payload
}
this.setState({ payload: body, buttonError: false })
api.create().checkUploadAM(body).then(response => {
// console.log(response.data)
console.log(resp.rows[1])
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
}
});
}
checkUpload(){
api.create().checkUploadAM(this.state.payload).then(response => {
console.log(response)
let dataRow = []
if(response.data){
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
dataRow = response.data.data.map((item, index) => {
......@@ -110,12 +117,12 @@ export default class ApprovalMatrix extends Component {
return (
<div style={{ display: 'flex' }}>
{tableMeta.rowData[7] != null && check > -1 ?
<a data-tip={tableMeta.rowData[7][check].message} data-for="typename">
<a data-tip={tableMeta.rowData[7][check].message} data-for="approvaltype">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
</a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
}
<ReactTooltip border={true} id="typename" place="bottom" type="light" effect="solid" />
<ReactTooltip border={true} id="approvaltype" place="bottom" type="light" effect="solid" />
</div >
);
}
......@@ -258,7 +265,8 @@ export default class ApprovalMatrix extends Component {
this.setState({
dataLoaded: true,
cols: columns,
rows: dataRow
rows: dataRow, visibleUpload: false,
visibleAM: false
});
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
......@@ -281,8 +289,6 @@ export default class ApprovalMatrix extends Component {
}
})
}
});
}
componentDidMount() {
this.getData()
......@@ -537,6 +543,7 @@ export default class ApprovalMatrix extends Component {
const columns = [{
name: "Action",
options: {
sort: false,
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
......@@ -775,7 +782,7 @@ export default class ApprovalMatrix extends Component {
theme={getMuiTheme()}
data={this.state.rows}
columns={this.state.cols}
options={options}
options={options2}
/>
</MuiThemeProvider>
)}
......@@ -792,7 +799,10 @@ export default class ApprovalMatrix extends Component {
</button>
<button
type="button"
onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadAM()}
// disabled={this.state.buttonError == true ? { buttonError: true, cursor: 'none' } : false}
disabled={this.state.buttonError == true ? true : false}
// onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadAM()}
onClick={() => this.uploadAM()}
style={{}}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
......@@ -851,7 +861,12 @@ export default class ApprovalMatrix extends Component {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onUpload={() => this.setState({ visibleUpload: false, visibleAM: false })}
// onUpload={() => this.setState({ visibleUpload: false, visibleAM: false })}
onUpload={() => {
this.state.judul === "APPROVAL MATRIX" ?
this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment