Commit 1a494a1c authored by a.bairuha's avatar a.bairuha

update Delete Report Item

parent 1955d960
......@@ -143,6 +143,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getItemReportHierarki = (body) => api.post('item_report/get_item_report_hierarki', body)
const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', body)
const getReportParent = (body) => api.post('item_report/get_parent_item_report', body)
const deleteReportItems = (id) => api.post(`item_report/delete_item_report/${id}`)
//PARAMETER
const getAllParameter = () => api.get('/setting/get_all_setting')
......@@ -271,7 +272,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
deleteAttachment,
getDetailReportMB,
deleteUnitBisnis,
deleteParameter
deleteParameter,
deleteReportItems
}
}
......
......@@ -13,6 +13,7 @@ import api from "../../api";
import ReactTooltip from "react-tooltip";
import PopUpFailedSave from "../../library/PopUpFailedSave";
import Constant from "../../library/Constant";
import PopUpDelete from "../../library/PopUpDelete";
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
......@@ -44,7 +45,9 @@ export default class ReportItems extends Component {
buttonCreate: false,
buttonEdit: false,
load: false,
judul: ''
judul: '',
reportNameDelete: '',
visibleDelete: false
}
this.fileHandler = this.fileHandler.bind(this);
......@@ -616,12 +619,46 @@ export default class ReportItems extends Component {
})
}
deleteReport(payload) {
console.log(payload);
let id = String(payload[1])
api.create().deleteReportItems(id).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.getData()
this.setState({ visibleDelete: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} 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({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
openPopUp(index, type) {
if (type === 'edit') {
this.setState({
rowData: index,
edit: true
})
} else if (type === 'delete') {
this.setState({
rowData: index,
reportNameDelete: "[" + String(index[2]) + " - " + String(index[3]) + " - " + String(index[5]) + "]",
visibleDelete: true
})
} else {
this.setState({
add: true
......@@ -785,21 +822,39 @@ export default class ReportItems extends Component {
sort: false,
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
{this.state.buttonEdit && (
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
this.state.buttonEdit && (
<div style={{ display: 'flex' }}>
<a data-tip={'Edit'} data-for="edit">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
>
<img src={Images.editCopy} />
</button>
)}
</div >
>
<img src={Images.editCopy} />
</button>
</a>
<ReactTooltip border={true} id="edit" place="bottom" type="light" effect="solid" />
<a data-tip={'Delete'} data-for="delete">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginLeft: 15
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, 'delete')}
>
<img src={Images.delete} />
</button>
</a>
<ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
</div >
)
);
}
}
......@@ -1150,6 +1205,14 @@ export default class ReportItems extends Component {
</div>
</div>
)}
{this.state.visibleDelete && (
<PopUpDelete
rowData={this.state.rowData}
name={this.state.reportNameDelete}
onClickClose={() => this.setState({ visibleDelete: false })}
onClickDelete={this.deleteReport.bind(this)}
/>
)}
</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