Commit 28757fdc authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

update layout dan function approval matrix

parent 4f9bb316
......@@ -16,17 +16,6 @@ const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const options2 = ct.customOptions2();
const type = [
{
value: 'KPI',
label: 'KPI',
},
{
value: 'Gatau',
label: 'Gatau',
},
];
export default class ApprovalMatrix extends Component {
constructor(props) {
super(props)
......@@ -107,18 +96,23 @@ export default class ApprovalMatrix extends Component {
}
}
handleInputChange = (e) => {
// Immediately update the state
this.setState({
search: e.target.value
handleInputChange(e) {
this.setState({ search: e })
let body = {
"keyword": e
}
api.create().searchAM(body).then(response => {
// console.log(response.data);
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
return [index, item.approval_matrix_id, item.approval_type_name, item.orders, item.fullname, item.operator_type_name, item.status]
})
// Execute the debounced onChange method
this.onChangeDebounced(e)
this.setState({ dataTable: listData, listData: response.data.data })
} else {
alert(response.data.message)
}
onChangeDebounced = (e) => {
// Delayed logic goes here
})
}
createAM = (payload) => {
......@@ -132,6 +126,32 @@ export default class ApprovalMatrix extends Component {
})
}
updateAM = (payload) => {
this.setState({ visibleEdit: false })
api.create().updateAM(payload).then(response => {
if (response.data.status == 'success') {
this.getData()
} else {
alert(response.data.message)
}
})
}
downloadFile = async () => {
let res = await fetch(
"https://tia.eksad.com/tia-reporting-dev/public/attachment/download_file?fileName=ApprovalMatrixTemplate&&fileType=xlsx"
)
res = await res.blob()
console.log(res)
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Template Approval Matrix.xlsx';
a.click();
}
}
render() {
const columns = [{
name: "Action",
......@@ -242,29 +262,27 @@ export default class ApprovalMatrix extends Component {
<div style={{ height: 199, width: '100%', backgroundColor: '#354960' }} />
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', paddingTop: 8 }}>Master Data - Approval Matrix</label>
{/* <form style={{ }}>
<TextField id="" label="" variant="outlined" size="small" placeholder="Search" style={{ width: 423, backgroundColor: 'white', borderRadius: 6 }}/>
</form> */}
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5 }}>
<label style={{ width: '20%', color: 'white', fontSize: 16, alignSelf: 'center', paddingTop: 8 }}>Master Data - Approval Matrix</label>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase
style={{ width: '100%' }}
placeholder="Search"
value={this.state.search}
onChange={(e) => this.handleInputChange(e)}
onChange={(e) => this.handleInputChange(e.target.value)}
inputProps={{ 'aria-label': 'naked' }}
/>
</div>
<div style={{ display: 'flex' }}>
<div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
padding: 0
padding: 0,
margin: 5
}}
onClick={() => null}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
......@@ -274,11 +292,12 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 16,
padding:0
padding:0,
margin: 5
}}
onClick={() => null}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} onClick={() => this.setState({ visibleUpload: true })}/>
<img src={Images.upload} />
</button>
<button
style={{
......@@ -286,7 +305,8 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 16,
padding:0
padding:0,
margin: 5
}}
onClick={() => null}
>
......@@ -298,11 +318,12 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 16,
padding:0
padding:0,
margin: 5
}}
onClick={() => null}
onClick={() => this.setState({ visibleVisual: true, visibleAM: false })}
>
<img src={Images.visualisasi} onClick={() => this.setState({ visibleVisual: true, visibleAM: false })} />
<img src={Images.visualisasi} />
</button>
<button
style={{
......@@ -310,10 +331,12 @@ export default class ApprovalMatrix extends Component {
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 16,
padding:0
padding:0,
margin: 5
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} onClick={() => this.setState({ visibleCreate: true })} />
<img src={Images.add} />
</button>
</div >
</div>
......@@ -386,6 +409,7 @@ export default class ApprovalMatrix extends Component {
type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.listData[this.state.selectIndex]}
updateAM={this.updateAM.bind(this)}
/>
)}
{this.state.visibleUpload && (
......
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