Commit f213909a authored by faisalhamdi's avatar faisalhamdi

handle login

parent 14f0420e
...@@ -9,6 +9,7 @@ import ReactTooltip from 'react-tooltip'; ...@@ -9,6 +9,7 @@ import ReactTooltip from 'react-tooltip';
import UploadFile from "../../library/Upload"; 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 Constant from '../../library/Constant';
import * as R from 'ramda' import * as R from 'ramda'
const LightTooltip = withStyles((theme) => ({ const LightTooltip = withStyles((theme) => ({
...@@ -90,83 +91,98 @@ export default class FixedAssetsMovement extends Component { ...@@ -90,83 +91,98 @@ export default class FixedAssetsMovement extends Component {
// console.log(response); // console.log(response);
let dataTable = [] let dataTable = []
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.fixed_asset_movement.total_actual_before === null ? "0" : item.fixed_asset_movement.total_actual_before === "" ? "0" : item.fixed_asset_movement.total_actual_before, item.level,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.january, formula: item.fixed_asset_movement.january_formula } : item.fixed_asset_movement.january, item.description,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.february, formula: item.fixed_asset_movement.february_formula } : item.fixed_asset_movement.february, item.fixed_asset_movement.total_actual_before === null ? "0" : item.fixed_asset_movement.total_actual_before === "" ? "0" : item.fixed_asset_movement.total_actual_before,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.march, formula: item.fixed_asset_movement.march_formula } : item.fixed_asset_movement.march, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.january, formula: item.fixed_asset_movement.january_formula } : item.fixed_asset_movement.january,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.april, formula: item.fixed_asset_movement.april_formula } : item.fixed_asset_movement.april, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.february, formula: item.fixed_asset_movement.february_formula } : item.fixed_asset_movement.february,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.may, formula: item.fixed_asset_movement.may_formula } : item.fixed_asset_movement.may, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.march, formula: item.fixed_asset_movement.march_formula } : item.fixed_asset_movement.march,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.june, formula: item.fixed_asset_movement.june_formula } : item.fixed_asset_movement.june, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.april, formula: item.fixed_asset_movement.april_formula } : item.fixed_asset_movement.april,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.july, formula: item.fixed_asset_movement.july_formula } : item.fixed_asset_movement.july, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.may, formula: item.fixed_asset_movement.may_formula } : item.fixed_asset_movement.may,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.august, formula: item.fixed_asset_movement.august_formula } : item.fixed_asset_movement.august, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.june, formula: item.fixed_asset_movement.june_formula } : item.fixed_asset_movement.june,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.september, formula: item.fixed_asset_movement.september_formula } : item.fixed_asset_movement.september, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.july, formula: item.fixed_asset_movement.july_formula } : item.fixed_asset_movement.july,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.october, formula: item.fixed_asset_movement.october_formula } : item.fixed_asset_movement.october, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.august, formula: item.fixed_asset_movement.august_formula } : item.fixed_asset_movement.august,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.november, formula: item.fixed_asset_movement.november_formula } : item.fixed_asset_movement.november, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.september, formula: item.fixed_asset_movement.september_formula } : item.fixed_asset_movement.september,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.december, formula: item.fixed_asset_movement.december_formula } : item.fixed_asset_movement.december, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.october, formula: item.fixed_asset_movement.october_formula } : item.fixed_asset_movement.october,
item.fixed_asset_movement.total_current_year, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.november, formula: item.fixed_asset_movement.november_formula } : item.fixed_asset_movement.november,
item.type_report_id == 5 || item.type_report_id == 6 ? 0 : item.fixed_asset_movement.total_next_year, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.december, formula: item.fixed_asset_movement.december_formula } : item.fixed_asset_movement.december,
item.type_report_id == 5 || item.type_report_id == 6 ? 0 : item.fixed_asset_movement.total_more_year, item.fixed_asset_movement.total_current_year,
item.order, item.type_report_id == 5 || item.type_report_id == 6 ? 0 : item.fixed_asset_movement.total_next_year,
item.fixed_asset_movement.forecast_formula, item.type_report_id == 5 || item.type_report_id == 6 ? 0 : item.fixed_asset_movement.total_more_year,
item.fixed_asset_movement.before_formula item.order,
]) item.fixed_asset_movement.forecast_formula,
} item.fixed_asset_movement.before_formula
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.fixed_asset_movement.total_actual_before === null ? "0" : item.fixed_asset_movement.total_actual_before === "" ? "0" : item.fixed_asset_movement.total_actual_before,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.january, formula: item.fixed_asset_movement.january_formula } : item.fixed_asset_movement.january,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.february, formula: item.fixed_asset_movement.february_formula } : item.fixed_asset_movement.february,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.march, formula: item.fixed_asset_movement.march_formula } : item.fixed_asset_movement.march,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.april, formula: item.fixed_asset_movement.april_formula } : item.fixed_asset_movement.april,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.may, formula: item.fixed_asset_movement.may_formula } : item.fixed_asset_movement.may,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.june, formula: item.fixed_asset_movement.june_formula } : item.fixed_asset_movement.june,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.july, formula: item.fixed_asset_movement.july_formula } : item.fixed_asset_movement.july,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.august, formula: item.fixed_asset_movement.august_formula } : item.fixed_asset_movement.august,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.september, formula: item.fixed_asset_movement.september_formula } : item.fixed_asset_movement.september,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.october, formula: item.fixed_asset_movement.october_formula } : item.fixed_asset_movement.october,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.november, formula: item.fixed_asset_movement.november_formula } : item.fixed_asset_movement.november,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.december, formula: item.fixed_asset_movement.december_formula } : item.fixed_asset_movement.december,
item.fixed_asset_movement.total_current_year,
item.type_report_id == 5 || item.type_report_id == 6 ? 0 : item.fixed_asset_movement.total_next_year,
item.type_report_id == 5 || item.type_report_id == 6 ? 0 : item.fixed_asset_movement.total_more_year,
item.order,
item.fixed_asset_movement.forecast_formula,
item.fixed_asset_movement.before_formula
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
this.setState({ dataTable, loading: false, buttonError: true, editable: true })
} 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' })
} }
res.map((item, index) => {
dataTable.push([
item.type_report_id,
item.id,
item.parent,
item.formula,
item.level,
item.description,
item.fixed_asset_movement.total_actual_before === null ? "0" : item.fixed_asset_movement.total_actual_before === "" ? "0" : item.fixed_asset_movement.total_actual_before,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.january, formula: item.fixed_asset_movement.january_formula } : item.fixed_asset_movement.january,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.february, formula: item.fixed_asset_movement.february_formula } : item.fixed_asset_movement.february,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.march, formula: item.fixed_asset_movement.march_formula } : item.fixed_asset_movement.march,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.april, formula: item.fixed_asset_movement.april_formula } : item.fixed_asset_movement.april,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.may, formula: item.fixed_asset_movement.may_formula } : item.fixed_asset_movement.may,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.june, formula: item.fixed_asset_movement.june_formula } : item.fixed_asset_movement.june,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.july, formula: item.fixed_asset_movement.july_formula } : item.fixed_asset_movement.july,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.august, formula: item.fixed_asset_movement.august_formula } : item.fixed_asset_movement.august,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.september, formula: item.fixed_asset_movement.september_formula } : item.fixed_asset_movement.september,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.october, formula: item.fixed_asset_movement.october_formula } : item.fixed_asset_movement.october,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.november, formula: item.fixed_asset_movement.november_formula } : item.fixed_asset_movement.november,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.fixed_asset_movement.december, formula: item.fixed_asset_movement.december_formula } : item.fixed_asset_movement.december,
item.fixed_asset_movement.total_current_year,
item.type_report_id == 5 || item.type_report_id == 6 ? 0 : item.fixed_asset_movement.total_next_year,
item.type_report_id == 5 || item.type_report_id == 6 ? 0 : item.fixed_asset_movement.total_more_year,
item.order,
item.fixed_asset_movement.forecast_formula,
item.fixed_asset_movement.before_formula
])
if (item.children !== null) {
if (item.children.length > 0) {
item.children.map((items, indexs) => {
handlePushChild(items)
})
}
}
})
this.setState({ dataTable, loading: false, buttonError: true, editable: true })
} else { } else {
this.setState({ dataTable, loading: false, buttonError: true, editable: true }) this.setState({ dataTable, loading: false, buttonError: true, editable: true })
} }
...@@ -304,48 +320,63 @@ export default class FixedAssetsMovement extends Component { ...@@ -304,48 +320,63 @@ export default class FixedAssetsMovement extends Component {
// // console.log(JSON.stringify(this.state.payload)); // // console.log(JSON.stringify(this.state.payload));
// // console.log(response) // // console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.ok) {
this.setState({ visibleUpload: false, visibleFixedAssetsMovement: false, loading: true }) if (response.data.status === 'success') {
let dataTable = response.data.data.map((item, index) => { this.setState({ visibleUpload: false, visibleFixedAssetsMovement: false, loading: true })
return [ let dataTable = response.data.data.map((item, index) => {
item.type_report_id, return [
item.item_report_id, item.type_report_id,
item.parent, item.item_report_id,
item.formula, item.parent,
item.level, item.formula,
item.item_report, item.level,
item.total_actual_before, item.item_report,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.january, formula: item.january_formula } : item.january, item.total_actual_before,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.february, formula: item.february_formula } : item.february, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.january, formula: item.january_formula } : item.january,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.march, formula: item.march_formula } : item.march, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.february, formula: item.february_formula } : item.february,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.april, formula: item.april_formula } : item.april, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.march, formula: item.march_formula } : item.march,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.may, formula: item.may_formula } : item.may, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.april, formula: item.april_formula } : item.april,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.june, formula: item.june_formula } : item.june, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.may, formula: item.may_formula } : item.may,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.july, formula: item.july_formula } : item.july, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.june, formula: item.june_formula } : item.june,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.august, formula: item.august_formula } : item.august, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.july, formula: item.july_formula } : item.july,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.september, formula: item.september_formula } : item.september, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.august, formula: item.august_formula } : item.august,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.october, formula: item.october_formula } : item.october, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.september, formula: item.september_formula } : item.september,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.november, formula: item.november_formula } : item.november, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.october, formula: item.october_formula } : item.october,
item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.december, formula: item.december_formula } : item.december, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.november, formula: item.november_formula } : item.november,
item.total_current_year, item.type_report_id == 5 || item.type_report_id == 6 ? { value: item.december, formula: item.december_formula } : item.december,
item.total_next_year, item.total_current_year,
item.total_more_year, item.total_next_year,
item.orders, item.total_more_year,
item.forecast_formula, item.orders,
item.before_formula, item.forecast_formula,
item.error item.before_formula,
] item.error
}) ]
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => { })
this.state.dataTable.map(item => { this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true }, () => {
if (item[24].length > 0) { this.state.dataTable.map(item => {
// // console.log('masuk') if (item[24].length > 0) {
this.setState({ buttonError: true, errorPreview: true, editable: true }) // // console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
})
// // console.log(this.state.dataTable);
})
} 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);
} }
}) })
// // console.log(this.state.dataTable); }
}) } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -385,15 +416,27 @@ export default class FixedAssetsMovement extends Component { ...@@ -385,15 +416,27 @@ export default class FixedAssetsMovement 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' }, () => {
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' })
} }
} else { } else {
this.setState({ loading: false }) // this.setState({ loading: false })
alert(response.problem) // alert(response.problem)
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} }
}) })
} }
......
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