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/') => ...@@ -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 getItemReportHierarki = (body) => api.post('item_report/get_item_report_hierarki', body)
const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', body) const saveVisualisasiReport = (body) => api.post('item_report/save_visualization', body)
const getReportParent = (body) => api.post('item_report/get_parent_item_report', 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 //PARAMETER
const getAllParameter = () => api.get('/setting/get_all_setting') const getAllParameter = () => api.get('/setting/get_all_setting')
...@@ -271,7 +272,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -271,7 +272,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
deleteAttachment, deleteAttachment,
getDetailReportMB, getDetailReportMB,
deleteUnitBisnis, deleteUnitBisnis,
deleteParameter deleteParameter,
deleteReportItems
} }
} }
......
...@@ -13,6 +13,7 @@ import api from "../../api"; ...@@ -13,6 +13,7 @@ import api from "../../api";
import ReactTooltip from "react-tooltip"; import ReactTooltip from "react-tooltip";
import PopUpFailedSave from "../../library/PopUpFailedSave"; import PopUpFailedSave from "../../library/PopUpFailedSave";
import Constant from "../../library/Constant"; import Constant from "../../library/Constant";
import PopUpDelete from "../../library/PopUpDelete";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -44,7 +45,9 @@ export default class ReportItems extends Component { ...@@ -44,7 +45,9 @@ export default class ReportItems extends Component {
buttonCreate: false, buttonCreate: false,
buttonEdit: false, buttonEdit: false,
load: false, load: false,
judul: '' judul: '',
reportNameDelete: '',
visibleDelete: false
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -616,12 +619,46 @@ export default class ReportItems extends Component { ...@@ -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) { openPopUp(index, type) {
if (type === 'edit') { if (type === 'edit') {
this.setState({ this.setState({
rowData: index, rowData: index,
edit: true edit: true
}) })
} else if (type === 'delete') {
this.setState({
rowData: index,
reportNameDelete: "[" + String(index[2]) + " - " + String(index[3]) + " - " + String(index[5]) + "]",
visibleDelete: true
})
} else { } else {
this.setState({ this.setState({
add: true add: true
...@@ -785,8 +822,9 @@ export default class ReportItems extends Component { ...@@ -785,8 +822,9 @@ export default class ReportItems extends Component {
sort: false, sort: false,
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
this.state.buttonEdit && (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{this.state.buttonEdit && ( <a data-tip={'Edit'} data-for="edit">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -798,8 +836,25 @@ export default class ReportItems extends Component { ...@@ -798,8 +836,25 @@ export default class ReportItems extends Component {
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </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 > </div >
)
); );
} }
} }
...@@ -1150,6 +1205,14 @@ export default class ReportItems extends Component { ...@@ -1150,6 +1205,14 @@ export default class ReportItems extends Component {
</div> </div>
</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> </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