Commit f213909a authored by faisalhamdi's avatar faisalhamdi

handle login

parent 14f0420e
......@@ -9,6 +9,7 @@ import ReactTooltip from 'react-tooltip';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
import { Alert } from '@material-ui/lab';
import Constant from '../../library/Constant';
import * as R from 'ramda'
const LightTooltip = withStyles((theme) => ({
......@@ -90,6 +91,8 @@ export default class FixedAssetsMovement extends Component {
// console.log(response);
let dataTable = []
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
let res = response.data.data
const handlePushChild = (item) => {
let indexIDzz = dataTable.findIndex((val) => val[1] === item.id)
......@@ -167,6 +170,19 @@ export default class FixedAssetsMovement extends Component {
}
})
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' })
}
} else {
this.setState({ dataTable, loading: false, buttonError: true, editable: true })
}
......@@ -304,6 +320,7 @@ export default class FixedAssetsMovement extends Component {
// // console.log(JSON.stringify(this.state.payload));
// // console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleFixedAssetsMovement: false, loading: true })
let dataTable = response.data.data.map((item, index) => {
......@@ -345,7 +362,21 @@ export default class FixedAssetsMovement extends Component {
})
// // 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);
}
})
}
} 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 {
api.create('UPLOAD').uploadMasterBudget(body).then(response => {
// // console.log(response);
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.onClickClose()
this.props.getReport()
} else {
alert(response.data.status)
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' })
}
} else {
this.setState({ loading: false })
alert(response.problem)
// this.setState({ loading: false })
// 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