Commit bfa1b3ee authored by Riri Novita's avatar Riri Novita

Check API MB MR

parent af06568d
......@@ -662,17 +662,26 @@ export default class CorporateAnnualTarget extends Component {
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
if (type == 'submitted') {
this.props.saveToMasterBudget(body, 'CAT')
} else {
this.props.saveToMasterBudget(body)
}
// this.props.onClickClose()
// this.props.getReport()
} else {
this.setState({alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
......@@ -899,11 +908,27 @@ export default class CorporateAnnualTarget extends Component {
// api.create().validateSubmitReport(payloadBro).then((response) => {
// // // // // console.log(response)
// if (response.data.data.result) {
if (type == 'submitted') {
this.props.saveToMasterBudget(payloadBro, 'CAT')
if (response.data.status === "success") {
if (type == 'submitted') {
this.props.saveToMasterBudget(payloadBro, 'CAT')
} else {
this.props.saveToMasterBudget(payloadBro)
}
} else {
this.props.saveToMasterBudget(payloadBro)
if (response.data?.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
}
// this.props.saveToMasterBudget(payloadBro)
// this.props.onClickClose()
// } else {
......
......@@ -97,6 +97,10 @@ class DownloadReport extends Component {
return () => clearInterval(interval);
}
closeAlert() {
this.setState({ alert: false })
}
getListDownload() {
api.create().getListDownload().then((response) => {
// console.log(response);
......
......@@ -884,7 +884,7 @@ export default class ListOfCreditFacilities extends Component {
downloadTemplate = async () => {
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}`
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/locf/monthly_report/download_template?report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&months=${this.props.month.month_id}&&currency_id=${this.props.defaultCurrency.id}`
)
res = await res.blob()
// console.log(this.props.report_id)
......
......@@ -92,6 +92,10 @@ export default class OperatingIndicator extends Component {
this.getPermission()
}
closeAlert() {
this.setState({ alert: false })
}
getPermission() {
let payload = {
menu: "operating indicator"
......@@ -691,8 +695,7 @@ export default class OperatingIndicator extends Component {
// }, 200);
// }
// }
async handleGenerateReport(data) {
handleGenerateReport = async (data) => {
let { selectReport, operatingIndID, company, periode, downloadedFileReportId, defaultCurrency } = this.state
if (selectReport.length > 0) {
let result = []
......@@ -718,34 +721,45 @@ export default class OperatingIndicator extends Component {
String(report[1]).toLocaleLowerCase().includes('dec') ? 12 : null
if (String(report[1]).toLocaleLowerCase().includes('master budget')) {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/master_budget/export_master_budget?operating_indicator_id=${operatingIndID == null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
console.log(url);
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/master_budget/export_master_budget?operating_indicator_id=${operatingIndID == null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
)
if (res.status === 200) {
result = [...result, res];
try {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/master_budget/export_master_budget?operating_indicator_id=${operatingIndID == null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/master_budget/export_master_budget?operating_indicator_id=${operatingIndID == null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
)
if (res.status === 200) {
result = [...result, res];
}
} catch (e) {
alert(e)
}
} else if (String(report[1]).toLocaleLowerCase().includes('monthly report')) {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/monthly_report/export_monthly_report?operating_indicator_id=${operatingIndID == null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&months=${month}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/monthly_report/export_monthly_report?operating_indicator_id=${operatingIndID === null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&months=${month}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
)
if (res.status === 200) {
result = [...result, res];
} else if (String(report[1]).toLocaleLowerCase().includes('monthly report')) {
try {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/monthly_report/export_monthly_report?operating_indicator_id=${operatingIndID == null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&months=${month}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/monthly_report/export_monthly_report?operating_indicator_id=${operatingIndID === null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&months=${month}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
)
if (res.status === 200) {
result = [...result, res];
}
} catch (error) {
alert(error)
}
} else if (String(report[1]).toLocaleLowerCase().includes('rolling outlook')) {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/rolling_outlook/export_rolling_outlook?operating_indicator_id=${operatingIndID == null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&quartal=${quarter}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/rolling_outlook/export_rolling_outlook?operating_indicator_id=${operatingIndID === null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&quartal=${quarter}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
)
if (res.status === 200) {
result = [...result, res];
try {
let url = `${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/rolling_outlook/export_rolling_outlook?operating_indicator_id=${operatingIndID == null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&quartal=${quarter}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/transaction/operating_indicator/rolling_outlook/export_rolling_outlook?operating_indicator_id=${operatingIndID === null ? "" : operatingIndID}&&report_id=${report[3]}&&company_id=${company.company_id}&&year=${periode.periode}&&quartal=${quarter}&&download_file_report_id=${downloadedFileReportId}&&currency_id=${defaultCurrency.id}`
)
if (res.status === 200) {
result = [...result, res];
}
} catch (error) {
alert(error)
}
}
}
......
......@@ -898,18 +898,31 @@ export default class OutlookPA extends Component {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
if (type === "PL") {
this.setState({ visiblePL: false, visibleOutlookPA: true })
} else if (type === "TP") {
this.setState({ visibleTP: false, visibleOutlookPA: true })
} else if (type === "BS") {
this.setState({ visibleBS: false, visibleOutlookPA: true })
} else {
this.setState({ visibleOutlookPA: true, loading: false })
}
this.getOutlookPAID(type)
} else {
this.setState({ visibleAlertSave: true, alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.getOutlookPAID()
})
if (response.data.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false, handleDoubleClick: 0 }, () => {
document.body.style.overflow = 'unset';
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
this.getOutlookPAID()
})
}
}
// else {
// this.setState({ loading: false }, () => {
......@@ -2714,6 +2727,42 @@ export default class OutlookPA extends Component {
</div>
</div>
)}
{this.state.visibleAlertSave && (
<div className="test app-popup-show">
<div className="popup-content border-radius" style={{ background: '#FFF27D', borderRadius: 10, width: 715, height: 238 }}>
<div style={{ margin: 30 }}>
<div style={{ display: 'flex', marginTop: 76, marginBottom: 43 }}>
<div style={{ alignSelf: 'center', marginRight: 25 }}>
<img src={Images.warning} />
</div>
<div style={{ justifyContent: 'center', fontSize: 20, color: '#1D2995', marginTop: 10 }}>
<b>Rate Currency USD</b> pada periode yang dipilih <b>belum</b> diatur.<br /> Silahkan menghubungi Superadmin
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<button
className="button"
type="button"
style={{
background: '#F6F7F9',
cursor: 'pointer',
border: '1px solid #3549609e',
outline: 'none',
marginRight: 20,
borderRadius: 9
}}
onClick={() => this.setState({ visibleAlertSave: false, loading: false })}
>
<div style={{ backgroundColor: '#fff', width: 105, height: 30, borderRadius: 9, justifyContent: 'center', display: 'flex', alignItems: 'center', border: 'solid 1px #3549609e' }}>
<Typography style={{ fontSize: '15px', color: '#354960', textAlign: 'center' }}>Close</Typography>
</div>
</button>
</div>
</div>
</div>
</div>
)}
</div >
);
}
......
......@@ -328,7 +328,7 @@ export default class ProfitLossOLPA extends Component {
} else {
this.props.saveToOLPA(payload)
}
this.props.onClickClose()
// this.props.onClickClose()
}
downloadTemplate = async () => {
......@@ -494,15 +494,19 @@ export default class ProfitLossOLPA extends Component {
this.props.getReport()
}
} else {
this.setState({ visibleAlertSave: true, alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
alert(response.data.status)
if (response.data.message == "Please Set Up Rate Currency First") {
this.setState({ visibleAlertSave: true })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
alert(response.data.status)
}
}
} else {
this.setState({ loading: false })
......@@ -1742,6 +1746,11 @@ export default class ProfitLossOLPA extends Component {
options: {
display: false
}
}, {
name: "",
options: {
display: false
}
}
]
......
......@@ -514,8 +514,13 @@ export default class TaxPlanningOLPA extends Component {
console.log(payload);
// console.log(JSON.stringify(payload));
// this.setState({ loading: false })
this.props.saveToOLPA(payload)
this.props.onClickClose()
if (type == 'submitted') {
this.props.saveToOLPA(payload, 'TP')
} else {
this.props.saveToOLPA(payload)
}
// this.props.saveToOLPA(payload)
// this.props.onClickClose()
}
fileHandler = (event) => {
......
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