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/') => ...@@ -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 getAllDocument = (body) => api.post('document/get_all_document', body)
const uploadDocument = (body) => api.post('document/upload_document', body) const uploadDocument = (body) => api.post('document/upload_document', body)
const updateDocument = (body) => api.post('document/update_document', body) const updateDocument = (body) => api.post('document/update_document', body)
const downloadDocument = (body) => api.post('document/download_document', body)
// ------ // ------
// STEP 3 // STEP 3
...@@ -288,6 +289,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -288,6 +289,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
getAllDocument, getAllDocument,
uploadDocument, uploadDocument,
updateDocument, updateDocument,
downloadDocument,
createSubmitReport, createSubmitReport,
getSubmission getSubmission
} }
......
...@@ -143,6 +143,35 @@ export default class DocumentManagement extends Component { ...@@ -143,6 +143,35 @@ export default class DocumentManagement extends Component {
this.setState({ alert: false }) 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() { render() {
return ( return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8' }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8' }}>
...@@ -202,6 +231,7 @@ export default class DocumentManagement extends Component { ...@@ -202,6 +231,7 @@ export default class DocumentManagement extends Component {
<QReview <QReview
data={this.state.listData[this.state.tab]} data={this.state.listData[this.state.tab]}
refresh={this.state.refresh} refresh={this.state.refresh}
getDownloadDocument={this.getDownloadDocument.bind(this)}
/> />
: :
this.state.id === 68543 ? this.state.id === 68543 ?
...@@ -226,8 +256,6 @@ export default class DocumentManagement extends Component { ...@@ -226,8 +256,6 @@ export default class DocumentManagement extends Component {
{this.state.konfirmasi && ( {this.state.konfirmasi && (
<PopUpKonfirmasi <PopUpKonfirmasi
onClickClosePopUp={() => this.setState({ konfirmasi: false })} onClickClosePopUp={() => this.setState({ konfirmasi: false })}
// getList={() => this.getData.bind(this)}
// deleteAM={this.deleteAM.bind(this)}
uploadDocId={this.createUploadDocument.bind(this)} uploadDocId={this.createUploadDocument.bind(this)}
/> />
)} )}
......
...@@ -33,12 +33,12 @@ export default class QReview extends Component { ...@@ -33,12 +33,12 @@ export default class QReview extends Component {
} }
componentWillReceiveProps(props) { componentWillReceiveProps(props) {
// console.log(props); // console.log(props);
const { refresh, id } = this.props; const { refresh, id } = this.props;
if (props.refresh !== refresh) { if (props.refresh !== refresh) {
this.getData() this.getData()
}
} }
}
getData() { getData() {
let payload = { let payload = {
...@@ -86,6 +86,29 @@ export default class QReview extends Component { ...@@ -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() { render() {
let columns = [{ let columns = [{
name: "Action", name: "Action",
...@@ -106,7 +129,7 @@ export default class QReview extends Component { ...@@ -106,7 +129,7 @@ export default class QReview extends Component {
marginRight: 15 marginRight: 15
}} }}
// onClick={() => console.log(tableMeta)} // onClick={() => console.log(tableMeta)}
// onClick={() => this.openPopUp(tableMeta.rowData, 'edit')} onClick={() => this.openPopUp(tableMeta.rowData, 'download')}
> >
<img src={Images.download} /> <img src={Images.download} />
</button> </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