diff --git a/src/components/molecules/NewsFlashComp.tsx b/src/components/molecules/NewsFlashComp.tsx index aaa3bdea..5b766834 100644 --- a/src/components/molecules/NewsFlashComp.tsx +++ b/src/components/molecules/NewsFlashComp.tsx @@ -63,7 +63,7 @@ const NewsFlashComp: FC = ({ news }) => { const handleLocationEditorOpen = () => setOpen(true); const handleLocationEditorClose = () => setOpen(false); - const locationChangeButton = userStore.isUserAdmin && + const locationChangeButton = (userStore.isUserAdmin || userStore.isUserLocationApprover) && {t('changeLocationButton')} diff --git a/src/const/generalConst.ts b/src/const/generalConst.ts index 59ad513d..c632e48d 100644 --- a/src/const/generalConst.ts +++ b/src/const/generalConst.ts @@ -9,6 +9,7 @@ export const loginPopUpDim = { //server url can be on dev or the heroku server export const serverUrl = process.env.REACT_APP_BASE_URL; export const ROLE_ADMIN_NAME = 'admins'; +export const ROLE_LOCATION_APPROVER_NAME = 'location_verification'; export const authServerUrl = isProd ? process.env.REACT_APP_AUTH_PROD_URL : process.env.REACT_APP_AUTH_DEV_URL; export const AUTH_LOGIN_GOOGLE_URL: URL = new URL(`${authServerUrl}authorize/google`); export const REDIRECT_ROUTE: string | undefined = process.env.REACT_APP_REDIRECT_URL; diff --git a/src/store/user.store.ts b/src/store/user.store.ts index f7f89374..57103678 100644 --- a/src/store/user.store.ts +++ b/src/store/user.store.ts @@ -11,12 +11,13 @@ import { updateUserOrganization, } from 'services/user.service'; import { IUserInfo } from 'models/user/IUserInfo'; -import { ROLE_ADMIN_NAME } from 'const/generalConst'; +import { ROLE_ADMIN_NAME, ROLE_LOCATION_APPROVER_NAME } from 'const/generalConst'; import { IFormInput } from 'components/molecules/UserUpdateForm'; export default class UserStore { isUserAuthenticated: boolean = false; isAdmin: boolean = false; + isLocationApprover: boolean = false; usersInfoList: [IUserInfo] | null = null; organizationsList: Array | null = null; userInfo: IAnywayUserDetails | null = null; @@ -60,6 +61,10 @@ export default class UserStore { return this.isUserAuthenticated && this.isAdmin; } + get isUserLocationApprover(){ + return this.isUserAuthenticated && this.isLocationApprover; + } + get usersManagementTableData(): any { return this.usersInfoList?.map((user) => ({ name: `${user.first_name} ${user.last_name}`, @@ -84,6 +89,7 @@ export default class UserStore { runInAction(() => { this.userInfo = userData; this.isAdmin = userData.data.roles.includes(ROLE_ADMIN_NAME); + this.isLocationApprover = userData.data.roles.includes(ROLE_LOCATION_APPROVER_NAME); this.isUserAuthenticated = true; }); })