Commit 0a3f3316 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'rifka' into 'master'

update issue log upload am

See merge request !228
parents 6da3fe27 4b93b16b
...@@ -45,6 +45,7 @@ export default class ApprovalMatrix extends Component { ...@@ -45,6 +45,7 @@ export default class ApprovalMatrix extends Component {
btncreate: false, btncreate: false,
btnedit: false, btnedit: false,
load: false, load: false,
judul: '',
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -52,11 +53,11 @@ export default class ApprovalMatrix extends Component { ...@@ -52,11 +53,11 @@ export default class ApprovalMatrix extends Component {
fileHandler = (event) => { fileHandler = (event) => {
let fileObj = event let fileObj = event
ExcelRenderer(fileObj, (err, resp) => { ExcelRenderer(fileObj, (err, resp) => {
// console.log(resp)
if (err) { if (err) {
// console.log(err); console.log(err);
} }
else { else {
let judul = resp.rows[2]
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
let payload = [] let payload = []
isi.map((item, index) => { isi.map((item, index) => {
...@@ -75,213 +76,218 @@ export default class ApprovalMatrix extends Component { ...@@ -75,213 +76,218 @@ export default class ApprovalMatrix extends Component {
let body = { let body = {
approval_matrix: payload approval_matrix: payload
} }
this.setState({ payload: body, buttonError: false }) console.log(resp.rows[1])
api.create().checkUploadAM(body).then(response => { this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
// console.log(response.data) }
let dataRow = [] });
if(response.data){ }
if (response.ok) {
if (response.data.status === "success") { checkUpload(){
dataRow = response.data.data.map((item, index) => { api.create().checkUploadAM(this.state.payload).then(response => {
return [ console.log(response)
index + 1, let dataRow = []
item.approval_type_name, if (response.data) {
item.orders, if (response.ok) {
item.fullname, if (response.data.status === "success") {
item.operator_type_name, dataRow = response.data.data.map((item, index) => {
item.start_date, return [
item.end_date, index + 1,
item.error item.approval_type_name,
] item.orders,
}) item.fullname,
let columns = [ item.operator_type_name,
"Data", item.start_date,
{ item.end_date,
name: "Approval Type", item.error
options: { ]
customBodyRender: (val, tableMeta) => { })
let check = null let columns = [
if (tableMeta.rowData[7] != null) { "Data",
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('approval_type_name')) {
if (check > -1) { name: "Approval Type",
this.setState({ buttonError: true }) options: {
} customBodyRender: (val, tableMeta) => {
} let check = null
return ( if (tableMeta.rowData[7] != null) {
<div style={{ display: 'flex' }}> check = tableMeta.rowData[7].findIndex((val) => val.field.includes('approval_type_name'))
{tableMeta.rowData[7] != null && check > -1 ? if (check > -1) {
<a data-tip={tableMeta.rowData[7][check].message} data-for="typename"> this.setState({ buttonError: true })
<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" />
</div >
);
} }
} }
}, return (
{ <div style={{ display: 'flex' }}>
name: "Order", {tableMeta.rowData[7] != null && check > -1 ?
options: { <a data-tip={tableMeta.rowData[7][check].message} data-for="approvaltype">
customBodyRender: (val, tableMeta) => { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
let check = null </a> :
if (tableMeta.rowData[7] != null) { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('orders'))
if (check > -1) {
this.setState({ buttonError: true })
}
} }
return ( <ReactTooltip border={true} id="approvaltype" place="bottom" type="light" effect="solid" />
<div style={{ display: 'flex' }}> </div >
{tableMeta.rowData[7] != null && check > -1 ? );
<a data-tip={tableMeta.rowData[7][check].message} data-for="order"> }
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> }
</a> : },
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> {
} name: "Order",
<ReactTooltip border={true} id="order" place="bottom" type="light" effect="solid" /> options: {
</div > customBodyRender: (val, tableMeta) => {
); let check = null
if (tableMeta.rowData[7] != null) {
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('orders'))
if (check > -1) {
this.setState({ buttonError: true })
} }
} }
}, return (
{ <div style={{ display: 'flex' }}>
name: "Approver Name", {tableMeta.rowData[7] != null && check > -1 ?
options: { <a data-tip={tableMeta.rowData[7][check].message} data-for="order">
customBodyRender: (val, tableMeta) => { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
let check = null </a> :
if (tableMeta.rowData[7] != null) { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('fullname'))
if (check > -1) {
this.setState({ buttonError: true })
}
} }
return ( <ReactTooltip border={true} id="order" place="bottom" type="light" effect="solid" />
<div style={{ display: 'flex' }}> </div >
{tableMeta.rowData[7] != null && check > -1 ? );
<a data-tip={tableMeta.rowData[7][check].message} data-for="fullname"> }
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> }
</a> : },
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> {
} name: "Approver Name",
<ReactTooltip border={true} id="fullname" place="bottom" type="light" effect="solid" /> options: {
</div > customBodyRender: (val, tableMeta) => {
); let check = null
if (tableMeta.rowData[7] != null) {
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('fullname'))
if (check > -1) {
this.setState({ buttonError: true })
} }
} }
}, return (
{ <div style={{ display: 'flex' }}>
name: "Operator", {tableMeta.rowData[7] != null && check > -1 ?
options: { <a data-tip={tableMeta.rowData[7][check].message} data-for="fullname">
customBodyRender: (val, tableMeta) => { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
let check = null </a> :
if (tableMeta.rowData[7] != null) { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('operator_type_name'))
if (check > -1) {
this.setState({ buttonError: true })
}
} }
return ( <ReactTooltip border={true} id="fullname" place="bottom" type="light" effect="solid" />
<div style={{ display: 'flex' }}> </div >
{tableMeta.rowData[7] != null && check > -1 ? );
<a data-tip={tableMeta.rowData[7][check].message} data-for="operatorname"> }
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> }
</a> : },
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> {
} name: "Operator",
<ReactTooltip border={true} id="operatorname" place="bottom" type="light" effect="solid" /> options: {
</div > customBodyRender: (val, tableMeta) => {
); let check = null
if (tableMeta.rowData[7] != null) {
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('operator_type_name'))
if (check > -1) {
this.setState({ buttonError: true })
} }
} }
}, return (
{ <div style={{ display: 'flex' }}>
name: "Valid From", {tableMeta.rowData[7] != null && check > -1 ?
options: { <a data-tip={tableMeta.rowData[7][check].message} data-for="operatorname">
customBodyRender: (val, tableMeta) => { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
let check = null </a> :
if (tableMeta.rowData[7] != null) { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('start_date'))
if (check > -1) {
this.setState({ buttonError: true })
}
} }
return ( <ReactTooltip border={true} id="operatorname" place="bottom" type="light" effect="solid" />
<div style={{ display: 'flex' }}> </div >
{tableMeta.rowData[7] != null && check > -1 ? );
<a data-tip={tableMeta.rowData[7][check].message} data-for="startdate"> }
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> }
</a> : },
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> {
} name: "Valid From",
<ReactTooltip border={true} id="startdate" place="bottom" type="light" effect="solid" /> options: {
</div > customBodyRender: (val, tableMeta) => {
); let check = null
if (tableMeta.rowData[7] != null) {
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('start_date'))
if (check > -1) {
this.setState({ buttonError: true })
} }
} }
}, return (
{ <div style={{ display: 'flex' }}>
name: "Valid To", {tableMeta.rowData[7] != null && check > -1 ?
options: { <a data-tip={tableMeta.rowData[7][check].message} data-for="startdate">
customBodyRender: (val, tableMeta) => { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
let check = null </a> :
if (tableMeta.rowData[7] != null) { <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span>
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('end_date'))
if (check > -1) {
this.setState({ buttonError: true })
}
} }
return ( <ReactTooltip border={true} id="startdate" place="bottom" type="light" effect="solid" />
<div style={{ display: 'flex' }}> </div >
{tableMeta.rowData[7] != null && check > -1 ? );
<a data-tip={tableMeta.rowData[7][check].message} data-for="enddate"> }
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> }
</a> : },
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val}</span> {
} name: "Valid To",
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> options: {
</div > customBodyRender: (val, tableMeta) => {
); let check = null
if (tableMeta.rowData[7] != null) {
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('end_date'))
if (check > -1) {
this.setState({ buttonError: true })
} }
} }
}, return (
{ <div style={{ display: 'flex' }}>
name: "", {tableMeta.rowData[7] != null && check > -1 ?
options: { <a data-tip={tableMeta.rowData[7][check].message} data-for="enddate">
display: false <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="enddate" place="bottom" type="light" effect="solid" />
// console.log(dataRow); </div >
this.setState({ );
dataLoaded: true,
cols: columns,
rows: dataRow
});
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
} }
}) }
},
{
name: "",
options: {
display: false
}
} }
} else { ]
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} // console.log(dataRow);
} else {
this.setState({ this.setState({
dataLoaded: false, dataLoaded: true,
alert: true, messageAlert: response.problem, tipeAlert: 'error' cols: columns,
rows: dataRow, visibleUpload: false,
visibleAM: false
}); });
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
} }
}) } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({
dataLoaded: false,
alert: true, messageAlert: response.problem, tipeAlert: 'error'
});
} }
}); })
} }
componentDidMount() { componentDidMount() {
...@@ -537,6 +543,7 @@ export default class ApprovalMatrix extends Component { ...@@ -537,6 +543,7 @@ export default class ApprovalMatrix extends Component {
const columns = [{ const columns = [{
name: "Action", name: "Action",
options: { options: {
sort: false,
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
...@@ -775,7 +782,7 @@ export default class ApprovalMatrix extends Component { ...@@ -775,7 +782,7 @@ export default class ApprovalMatrix extends Component {
theme={getMuiTheme()} theme={getMuiTheme()}
data={this.state.rows} data={this.state.rows}
columns={this.state.cols} columns={this.state.cols}
options={options} options={options2}
/> />
</MuiThemeProvider> </MuiThemeProvider>
)} )}
...@@ -792,7 +799,10 @@ export default class ApprovalMatrix extends Component { ...@@ -792,7 +799,10 @@ export default class ApprovalMatrix extends Component {
</button> </button>
<button <button
type="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={{}} style={{}}
> >
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <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 { ...@@ -851,7 +861,12 @@ export default class ApprovalMatrix extends Component {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) 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>
</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