Fix #4317 Default role permissions are not recognised by UI on Manage tab on sign-up (#4360)

This commit is contained in:
Sachin Chaurasiya 2022-04-22 20:07:36 +05:30 committed by GitHub
parent 32a16b059d
commit 981be65ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ import { UserProfile } from 'Models';
import React, { useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import appState from '../../AppState';
import { getLoggedInUserPermissions } from '../../axiosAPIs/miscAPI';
import { getTeams } from '../../axiosAPIs/teamsAPI';
import { createUser } from '../../axiosAPIs/userAPI';
import { Button } from '../../components/buttons/Button/Button';
@ -46,6 +47,23 @@ const Signup = () => {
const history = useHistory();
const getUserPermissions = () => {
getLoggedInUserPermissions()
.then((res: AxiosResponse) => {
if (res.data) {
appState.updateUserPermissions(res.data.metadataOperations);
} else {
throw jsonData['api-error-messages']['unexpected-server-response'];
}
})
.catch((err: AxiosError) => {
showErrorToast(
err,
jsonData['api-error-messages']['fetch-user-permission-error']
);
});
};
const selectedTeamsHandler = (id?: string) => {
setSelectedTeams((prevState: Array<string | undefined>) => {
if (prevState.includes(id as string)) {
@ -68,6 +86,7 @@ const Signup = () => {
if (res.data) {
appState.updateUserDetails(res.data);
fetchAllUsers();
getUserPermissions();
history.push(ROUTES.HOME);
} else {
setLoading(false);