Commit 58c7ee4a authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

push download baru testing di qreview soal nya dari postman network error -curcol

parent f2548ac7
......@@ -180,6 +180,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const getAllDocument = (body) => api.post('document/get_all_document', body)
const uploadDocument = (body) => api.post('document/upload_document', body)
const updateDocument = (body) => api.post('document/update_document', body)
const downloadDocument = (body) => api.post('document/download_document', body)
// ------
// STEP 3
......@@ -288,6 +289,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
getAllDocument,
uploadDocument,
updateDocument,
downloadDocument,
createSubmitReport,
getSubmission
}
......
......@@ -143,6 +143,35 @@ export default class DocumentManagement extends Component {
this.setState({ alert: false })
}
getDownloadDocument(payload){
// console.log(payload)
api.create().downloadDocument(payload).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
// this.getDataDocument(settingID)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', visibleCreate: false })
}
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
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' })
}
})
}
render() {
return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8' }}>
......@@ -202,6 +231,7 @@ export default class DocumentManagement extends Component {
<QReview
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
getDownloadDocument={this.getDownloadDocument.bind(this)}
/>
:
this.state.id === 68543 ?
......@@ -226,8 +256,6 @@ export default class DocumentManagement extends Component {
{this.state.konfirmasi && (
<PopUpKonfirmasi
onClickClosePopUp={() => this.setState({ konfirmasi: false })}
// getList={() => this.getData.bind(this)}
// deleteAM={this.deleteAM.bind(this)}
uploadDocId={this.createUploadDocument.bind(this)}
/>
)}
......
......@@ -86,6 +86,29 @@ export default class QReview extends Component {
})
}
openPopUp(index, type){
if (type === 'download') {
const formData = new FormData();
formData.append("documentName", index[1]);
formData.append("fileType", index[5]);
this.setState({ formData }, ()=> {
this.props.getDownloadDocument(this.state.formData)
})
}
}
downloadDoc() {
let datax = this.state.index
console.log(datax)
// let payload = {
// "documentName": this.state.typeId.approval_type_id,
// "fileType": this.state.order
// }
// this.props.getDownloadDocument(payload)
}
render() {
let columns = [{
name: "Action",
......@@ -106,7 +129,7 @@ export default class QReview extends Component {
marginRight: 15
}}
// onClick={() => console.log(tableMeta)}
// onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
onClick={() => this.openPopUp(tableMeta.rowData, 'download')}
>
<img src={Images.download} />
</button>
......
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