Commit c0898c4f authored by d.arizona's avatar d.arizona

token expired

parent 0a799d7b
...@@ -71,11 +71,25 @@ class HomePage extends Component { ...@@ -71,11 +71,25 @@ class HomePage extends Component {
let userId = localStorage.getItem(Constant.USER) let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => { api.create().getDetailUser(userId).then((response) => {
if (response.data) { if (response.data) {
if (response.data.status === 'success') { if (response.ok) {
this.setState({ userData: response.data.data }, () => { if (response.data.status === 'success') {
// console.log(this.state.userData) this.setState({ userData: response.data.data })
}) // console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
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' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
// api.create().checkApprover().then(response => { // api.create().checkApprover().then(response => {
......
...@@ -82,8 +82,24 @@ export default class DashboardCAT extends Component { ...@@ -82,8 +82,24 @@ export default class DashboardCAT extends Component {
this.getCompanyActive() this.getCompanyActive()
}) })
} }
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
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' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
// }
// }
}) })
} }
......
...@@ -104,7 +104,21 @@ export default class DashboardFinancial extends React.Component { ...@@ -104,7 +104,21 @@ export default class DashboardFinancial extends React.Component {
this.getCompanyActive() this.getCompanyActive()
}) })
} }
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
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' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -132,10 +146,10 @@ export default class DashboardFinancial extends React.Component { ...@@ -132,10 +146,10 @@ export default class DashboardFinancial extends React.Component {
}) })
let defaultProps = { let defaultProps = {
options: arrayBaru.sort((a,b) => a.company_name.localeCompare(b.company_name)), options: arrayBaru.sort((a, b) => a.company_name.localeCompare(b.company_name)),
getOptionLabel: (option) => titleCase(option.company_name), getOptionLabel: (option) => titleCase(option.company_name),
}; };
let index = arrayBaru.findIndex((val) => val.company_id == comID) let index = arrayBaru.findIndex((val) => val.company_id == comID)
this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => { this.setState({ listCompany: defaultProps, company: arrayBaru.length < 1 ? companyData[0] : (index == -1 ? arrayBaru[0] : arrayBaru[index]) }, () => {
this.getAllBusiness() this.getAllBusiness()
......
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