Skip to content

Commit

Permalink
add location apprrver role
Browse files Browse the repository at this point in the history
  • Loading branch information
atalyaalon committed Apr 25, 2024
1 parent 414d8d1 commit f80c594
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/molecules/NewsFlashComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const NewsFlashComp: FC<IProps> = ({ news }) => {
const handleLocationEditorOpen = () => setOpen(true);
const handleLocationEditorClose = () => setOpen(false);

const locationChangeButton = userStore.isUserAdmin &&
const locationChangeButton = (userStore.isUserAdmin || userStore.isUserLocationApprover) &&
<Button.Small onClick={handleLocationEditorOpen} buttonHeight={ICON_HEIGHT}>
{t('changeLocationButton')}
</Button.Small>
Expand Down
1 change: 1 addition & 0 deletions src/const/generalConst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/store/user.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> | null = null;
userInfo: IAnywayUserDetails | null = null;
Expand Down Expand Up @@ -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}`,
Expand All @@ -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;
});
})
Expand Down

0 comments on commit f80c594

Please sign in to comment.