Commit 2f461a19 authored by Deni Rinaldi's avatar Deni Rinaldi

api aplot ++

parent bd1aea9a
...@@ -3,14 +3,18 @@ import apisauce from 'apisauce' ...@@ -3,14 +3,18 @@ import apisauce from 'apisauce'
import Constant from '../library/Constant' import Constant from '../library/Constant'
// our "constructor" // our "constructor"
const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => { const create = (type = "") => {
let api;
// ------ // ------
// STEP 1 // STEP 1
// ------ // ------
// //
// Create and configure an apisauce-based api object. // Create and configure an apisauce-based api object.
// //
const api = apisauce.create({ const baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/'
switch (type) {
case '':
api = apisauce.create({
// base URL is read from the "constructor" // base URL is read from the "constructor"
baseURL, baseURL,
// here are some default headers // here are some default headers
...@@ -19,9 +23,27 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -19,9 +23,27 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
Accept: 'application/json', Accept: 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
// 10 second timeout... // 60 second timeout...
timeout: 30000 timeout: 30000
}) })
break;
case 'UPLOAD':
api = apisauce.create({
// base URL is read from the "constructor"
baseURL,
// here are some default headers
headers: {
'Cache-Control': 'no-cache',
Accept: 'application/json',
'Content-Type': 'application/json',
},
// 40 second timeout...
timeout: 40000
})
break;
default:
break;
}
api.addAsyncRequestTransform(request => async () => { api.addAsyncRequestTransform(request => async () => {
var token var token
...@@ -169,6 +191,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -169,6 +191,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const createSubmitReport = (body) => api.post('transaction/master_budget/create_submission_report', body) const createSubmitReport = (body) => api.post('transaction/master_budget/create_submission_report', body)
const getSubmission = (body) => api.post('transaction/get_submission_id', body) const getSubmission = (body) => api.post('transaction/get_submission_id', body)
const checkUploadMB = (body) => api.post('transaction/master_budget/check_import', body) const checkUploadMB = (body) => api.post('transaction/master_budget/check_import', body)
const uploadMasterBudget = (body) => api.post('transaction/master_budget/import_master_budget', body)
//Template //Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`) const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
...@@ -293,7 +316,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -293,7 +316,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
downloadDocument, downloadDocument,
createSubmitReport, createSubmitReport,
getSubmission, getSubmission,
checkUploadMB checkUploadMB,
uploadMasterBudget
} }
} }
......
...@@ -653,6 +653,8 @@ export default class BudgetTahunan extends Component { ...@@ -653,6 +653,8 @@ export default class BudgetTahunan extends Component {
submissionID={this.state.submissionID} submissionID={this.state.submissionID}
saveToMasterBudget={this.saveToMasterBudget.bind(this)} saveToMasterBudget={this.saveToMasterBudget.bind(this)}
onClickClose={() => this.setState({ visibleBS: false, visibleBudgetTahunan: true })} onClickClose={() => this.setState({ visibleBS: false, visibleBudgetTahunan: true })}
getReport={this.getReport.bind(this)}
getReportAttachment={this.getReportAttachment.bind(this)}
/> />
)} )}
{this.state.visiblePL && ( {this.state.visiblePL && (
......
...@@ -714,11 +714,6 @@ export default class BalanceSheet extends Component { ...@@ -714,11 +714,6 @@ export default class BalanceSheet extends Component {
} else { } else {
data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val) data[tableMeta.rowIndex][tableMeta.columnIndex] = Number(val)
} }
// this.forceUpdate()
// console.log(this.state.dataTable)
// this.setState({
// data: a,
// }, () => console.log(this.state.dataTable))
} }
backToMasterBudget(type) { backToMasterBudget(type) {
...@@ -880,12 +875,37 @@ export default class BalanceSheet extends Component { ...@@ -880,12 +875,37 @@ export default class BalanceSheet extends Component {
item.error item.error
] ]
}) })
this.setState({ dataTable, dataLoaded: true, loading: false }) this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false })
} }
} }
}) })
} }
checkError(tableMeta) {
if (tableMeta.rowData[22]) {
if (tableMeta.rowData[22][0] === 'item') {
this.setState({ buttonError: true })
}
}
}
uploadBalanceSheet() {
api.create('UPLOAD').uploadMasterBudget(this.state.payload).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
this.props.getReportAttachment()
} else {
alert(response.data.status)
}
} else {
alert(response.problem)
}
})
}
render() { render() {
let dataTable2 = this.state.dataTable let dataTable2 = this.state.dataTable
const handleChange = (value, tableMeta) => { const handleChange = (value, tableMeta) => {
...@@ -957,6 +977,7 @@ export default class BalanceSheet extends Component { ...@@ -957,6 +977,7 @@ export default class BalanceSheet extends Component {
return a return a
} }
const columns = [{ const columns = [{
name: "", name: "",
options: { options: {
...@@ -1000,11 +1021,13 @@ export default class BalanceSheet extends Component { ...@@ -1000,11 +1021,13 @@ export default class BalanceSheet extends Component {
tableMeta.rowData[4] == 0 ? tableMeta.rowData[4] == 0 ?
<a data-tip={tableMeta.rowData[22][0].message} data-for="account"> <a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span> <span style={{ fontSize: 12, fontWeight: 'bold', color: 'red' }}>{String(tableMeta.rowData[0] === 4 ? "" : val).toUpperCase()}</span>
{this.checkError(tableMeta)}
</a> </a>
: :
<div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}> <div style={{ paddingLeft: 20 * Number(tableMeta.rowData[4]) }}>
<a data-tip={tableMeta.rowData[22][0].message} data-for="account"> <a data-tip={tableMeta.rowData[22][0].message} data-for="account">
<span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span> <span style={{ fontSize: 12, color: 'red' }}>{tableMeta.rowData[0] === 4 ? "" : val}</span>
{this.checkError(tableMeta)}
</a> </a>
</div> </div>
: :
...@@ -2554,7 +2577,7 @@ export default class BalanceSheet extends Component { ...@@ -2554,7 +2577,7 @@ export default class BalanceSheet extends Component {
marginRight: 20 marginRight: 20
}} }}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center'}}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save</Typography>
</div> </div>
</button> </button>
...@@ -2609,14 +2632,18 @@ export default class BalanceSheet extends Component { ...@@ -2609,14 +2632,18 @@ export default class BalanceSheet extends Component {
onClick={() => this.setState({ visibleBalanceSheet: true }, () => this.getItemHierarki())} onClick={() => this.setState({ visibleBalanceSheet: true }, () => this.getItemHierarki())}
style={{ marginRight: 20 }} style={{ marginRight: 20 }}
> >
<div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960'}}> <div style={{ backgroundColor: '#fff', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #354960' }}>
<Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography> <Typography style={{ fontSize: '11px', color: '#354960', textAlign: 'center' }}>Cancel</Typography>
</div> </div>
</button> </button>
<button <button
type="button" type="button"
disabled={this.state.buttonError == true ? true : false} disabled={this.state.buttonError == true ? true : false}
onClick={() => null} onClick={() => this.setState({ loading: true }, () => {
setTimeout(() => {
this.uploadBalanceSheet()
}, 100);
})}
style={{ marginRight: 20 }} style={{ marginRight: 20 }}
> >
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
...@@ -2635,7 +2662,7 @@ export default class BalanceSheet extends Component { ...@@ -2635,7 +2662,7 @@ export default class BalanceSheet extends Component {
onClick={() => { onClick={() => {
this.setState({ loading: true }, () => { this.setState({ loading: true }, () => {
setTimeout(() => { setTimeout(() => {
this.setState({ loading: false, buttonError: false }) this.setState({ loading: false })
}, 100); }, 100);
}) })
}} }}
......
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