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

token expired

parent 0a799d7b
......@@ -71,11 +71,25 @@ class HomePage extends Component {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.data.status === 'success') {
this.setState({ userData: response.data.data }, () => {
// console.log(this.state.userData)
})
if (response.ok) {
if (response.data.status === 'success') {
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 => {
......
......@@ -82,8 +82,24 @@ export default class DashboardCAT extends Component {
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 {
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 {
})
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),
};
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.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