Commit 4db09279 authored by Riri Novita's avatar Riri Novita

+++

parent 18f19d7f
......@@ -180,10 +180,22 @@ export default class ProfitLossMR extends Component {
api.create().getHierarkiMontlyReportPL(payload).then(response => {
console.log(response);
let dataTable = []
let err = false
if (response.data) {
if (response.data.status === 'success') {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
if (item.profit_loss.mtd_vs_previous_month == "" && Number(item.profit_loss.percent_act_vs_previous_month) < this.state.minValue || Number(item.profit_loss.percent_act_vs_previous_month) > this.state.maxValue) {
err = true
}
if (item.profit_loss.mtd_vs_mb == "" && Number(item.profit_loss.percent_act_vs_mb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_mb) > this.state.maxValue) {
err = true
}
if (item.profit_loss.mtd_vs_rb == "" && Number(item.profit_loss.percent_act_vs_rb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_rb) > this.state.maxValue) {
err = true
}
if (indexIDzz === -1) {
dataTable.push([
item.type_report_id,
......@@ -221,6 +233,15 @@ export default class ProfitLossMR extends Component {
}
}
res.map((item, index) => {
if (item.profit_loss.mtd_vs_previous_month == "" && Number(item.profit_loss.percent_act_vs_previous_month) < this.state.minValue || Number(item.profit_loss.percent_act_vs_previous_month) > this.state.maxValue) {
err = true
}
if (item.profit_loss.mtd_vs_mb == "" && Number(item.profit_loss.percent_act_vs_mb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_mb) > this.state.maxValue) {
err = true
}
if (item.profit_loss.mtd_vs_rb == "" && Number(item.profit_loss.percent_act_vs_rb) < this.state.minValue || Number(item.profit_loss.percent_act_vs_rb) > this.state.maxValue) {
err = true
}
dataTable.push([
item.type_report_id,
item.id,
......@@ -255,27 +276,24 @@ export default class ProfitLossMR extends Component {
}
}
})
this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true, bebas: true })
}
console.log(dataTable);
let err = false
dataTable.map((item, index) => {
if (item[19] == "" && Number(item[14]) < this.state.minValue || Number(item[14]) > this.state.maxValue) {
err = true
}
if (item[20] == "" && Number(item[16]) < this.state.minValue || Number(item[16]) > this.state.maxValue) {
err = true
if (err === true) {
this.setState({ bebas: true })
}
if (item[21] == "" && Number(item[18]) < this.state.minValue || Number(item[18]) > this.state.maxValue) {
err = true
this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
} else {
this.setState({ loading: false, 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);
}
})
if (err === true) {
this.setState({ bebas: true })
}
} else {
this.setState({ dataTable, loading: false, buttonError: true, saveDraft: true })
}
console.log(dataTable);
})
}
......
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