Commit d6966f25 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'riri' into 'master'

push response api

See merge request !623
parents 6323df73 9523c2a0
...@@ -10,6 +10,7 @@ import UploadFile from "../../library/Upload"; ...@@ -10,6 +10,7 @@ import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import { Alert } from '@material-ui/lab'; import { Alert } from '@material-ui/lab';
import * as R from 'ramda'; import * as R from 'ramda';
import Constant from '../../library/Constant';
const LightTooltip = withStyles((theme) => ({ const LightTooltip = withStyles((theme) => ({
tooltip: { tooltip: {
...@@ -106,86 +107,100 @@ export default class ProfitLoss extends Component { ...@@ -106,86 +107,100 @@ export default class ProfitLoss extends Component {
let dataTable = [] let dataTable = []
this.setState({ visibleProfitLoss: true }) this.setState({ visibleProfitLoss: true })
if (response.data) { if (response.data) {
let res = response.data.data if (response.ok) {
const handlePushChild = (item) => { if (response.data.status === 'success') {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id) let res = response.data.data
if (indexIDzz === -1) { const handlePushChild = (item) => {
dataTable.push([ let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
item.type_report_id, if (indexIDzz === -1) {
item.id, dataTable.push([
item.parent, item.type_report_id,
item.formula, item.id,
item.level, item.parent,
item.description, item.formula,
item.profit_loss.notes === "" ? null : item.profit_loss.notes, item.level,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before, item.description,
item.profit_loss.january, item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.february, item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.march, item.profit_loss.january,
item.profit_loss.april, item.profit_loss.february,
item.profit_loss.may, item.profit_loss.march,
item.profit_loss.june, item.profit_loss.april,
item.profit_loss.july, item.profit_loss.may,
item.profit_loss.august, item.profit_loss.june,
item.profit_loss.september, item.profit_loss.july,
item.profit_loss.october, item.profit_loss.august,
item.profit_loss.november, item.profit_loss.september,
item.profit_loss.december, item.profit_loss.october,
item.profit_loss.total_current_year, item.profit_loss.november,
item.profit_loss.total_next_year, item.profit_loss.december,
item.profit_loss.total_more_year, item.profit_loss.total_current_year,
item.order item.profit_loss.total_next_year,
]) item.profit_loss.total_more_year,
} item.order
if (item.children !== null) { ])
if (item.children.length > 0) { }
item.children.map((items, indexs) => { if (item.children !== null) {
handlePushChild(items) if (item.children.length > 0) {
}) item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
} }
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
item.order
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
// console.log(dataTable)
this.setState({ dataTable, loading: false, buttonError: true, editable: true }, () => {
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
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', loading: false })
} }
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.profit_loss.notes === "" ? null : item.profit_loss.notes,
item.profit_loss.total_actual_before === null ? "0" : item.profit_loss.total_actual_before === "" ? "0" : item.profit_loss.total_actual_before,
item.profit_loss.january,
item.profit_loss.february,
item.profit_loss.march,
item.profit_loss.april,
item.profit_loss.may,
item.profit_loss.june,
item.profit_loss.july,
item.profit_loss.august,
item.profit_loss.september,
item.profit_loss.october,
item.profit_loss.november,
item.profit_loss.december,
item.profit_loss.total_current_year,
item.profit_loss.total_next_year,
item.profit_loss.total_more_year,
item.order
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
// console.log(dataTable)
this.setState({ dataTable, loading: false, buttonError: true, editable: true }, () => {
// console.log(dataTable)
})
} else { } else {
this.setState({ dataTable, loading: false, buttonError: true, editable: true }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} }
}) })
...@@ -406,17 +421,25 @@ export default class ProfitLoss extends Component { ...@@ -406,17 +421,25 @@ export default class ProfitLoss extends Component {
api.create('UPLOAD').uploadMasterBudget(body).then(response => { api.create('UPLOAD').uploadMasterBudget(body).then(response => {
// console.log(response); // console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.ok) {
this.props.onClickClose() if (response.data.status === "success") {
this.props.getReport() 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")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else { } else {
alert(response.data.status) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
} }
} else { } else {
this.setState({ loading: false }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
alert(response.problem)
// this.props.onClickClose()
// this.props.getReport()
} }
}) })
} }
......
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