- removed unwanted call for companies for admin user;
This commit is contained in:
16
src/App.js
16
src/App.js
@@ -7,7 +7,7 @@ import './assets/scss/theme.scss';
|
||||
import AuthenticationService from './service/authentication-service';
|
||||
|
||||
// store
|
||||
import { useStore, storeSet } from './store';
|
||||
import { useStore, storeSet, storeGet } from './store';
|
||||
import CompanyService from './service/company-service';
|
||||
|
||||
const i18n = createI18n({}, 'gepafin');
|
||||
@@ -16,17 +16,15 @@ function App() {
|
||||
const role = useStore().main.getRole();
|
||||
|
||||
const callback = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.userData(data.data);
|
||||
storeSet.main.setAsyncRequest();
|
||||
CompanyService.getCompanyForUser(data.data.id, companyCallback, errCompanyCallback)
|
||||
} else {
|
||||
storeSet.main.doLogout();
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errCallback = (data) => {
|
||||
const errCallback = () => {
|
||||
storeSet.main.doLogout();
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -43,6 +41,14 @@ function App() {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (role === 'ROLE_BENEFICIARY') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
const userData = storeGet.main.userData();
|
||||
CompanyService.getCompanyForUser(userData.id, companyCallback, errCompanyCallback)
|
||||
}
|
||||
}, [role])
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
AuthenticationService.me(callback, errCallback);
|
||||
|
||||
Reference in New Issue
Block a user