diff --git a/package.json b/package.json index f8f480c..9ea416e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mojaloop/reporting-hub-bop-role-ui", - "version": "1.5.0", + "version": "1.5.1", "description": "", "main": "index.js", "scripts": { diff --git a/src/App/UserProfile/connectors.ts b/src/App/UserProfile/connectors.ts index 2dc2a0a..810bdbc 100644 --- a/src/App/UserProfile/connectors.ts +++ b/src/App/UserProfile/connectors.ts @@ -8,6 +8,7 @@ import { RolesDelta, ParticipantsDelta, RoleDeletionItem, ParticipantDeletionIte const mapStatePropsUserProfile = (state: State) => ({ userProfile: selectors.getUserProfile(state), userProfileError: selectors.getUserProfileError(state), + userProfileRolesError: selectors.getUserProfileRolesError(state), isUserProfileRequestPending: selectors.getIsUserProfileRequestPending(state), showChangeRolesModal: selectors.showChangeRolesModal(state), showParticipantsRolesModal: selectors.showParticipantsRolesModal(state), diff --git a/src/App/UserProfile/sagas.ts b/src/App/UserProfile/sagas.ts index b7fdd16..08906fc 100644 --- a/src/App/UserProfile/sagas.ts +++ b/src/App/UserProfile/sagas.ts @@ -98,19 +98,22 @@ function* updateUserRoles(action: PayloadAction) { roleOperations: roleDelta, }, }; + try { + const userResponse = (yield call(api.userRoles.modify, requestBody)) as MakeResponse; + if (userResponse.status !== 200) { + throw new Error(JSON.stringify(userResponse)); + } - const userResponse = (yield call(api.userRoles.modify, requestBody)) as MakeResponse; - if (userResponse.status !== 200) { - throw new Error(JSON.stringify(userResponse)); - } - - const assignedRolesResponse = (yield call(api.userRoles.read, { - id: action.payload.id, - })) as MakeResponse; - if (assignedRolesResponse.status !== 200) { - throw new Error(JSON.stringify(assignedRolesResponse)); + const assignedRolesResponse = (yield call(api.userRoles.read, { + id: action.payload.id, + })) as MakeResponse; + if (assignedRolesResponse.status !== 200) { + throw new Error(JSON.stringify(assignedRolesResponse)); + } + yield put(actions.setUserProfileRoles(assignedRolesResponse.data.roles)); + } catch (e) { + yield put(actions.setUserProfileRolesError(e.message)); } - yield put(actions.setUserProfileRoles(assignedRolesResponse.data.roles)); } function* updateUserParticipants(action: PayloadAction) { diff --git a/src/App/UserProfile/selectors.ts b/src/App/UserProfile/selectors.ts index ca3435a..8c1de79 100644 --- a/src/App/UserProfile/selectors.ts +++ b/src/App/UserProfile/selectors.ts @@ -3,6 +3,7 @@ import { State } from 'store/types'; // user profile selectors export const getUserProfile = (state: State) => state.userProfile.userProfile; export const getUserProfileError = (state: State) => state.userProfile.userProfileError; +export const getUserProfileRolesError = (state: State) => state.userProfile.userProfileRolesError; export const getIsUserProfileRequestPending = (state: State) => state.userProfile.isUserProfileRequestPending; diff --git a/src/App/UserProfile/slice.ts b/src/App/UserProfile/slice.ts index a1f837d..ce75afb 100644 --- a/src/App/UserProfile/slice.ts +++ b/src/App/UserProfile/slice.ts @@ -11,6 +11,7 @@ import { export const initialState: UserProfileState = { userProfile: null, userProfileError: null, + userProfileRolesError: null, isUserProfileRequestPending: true, showChangeRolesModal: false, showChangeParticipantsModal: false, @@ -98,6 +99,12 @@ const slice = createSlice({ }, }; }, + setUserProfileRolesError(state: UserProfileState, action: PayloadAction) { + return { + ...state, + userProfileRolesError: action.payload, + }; + }, requestUserProfileParticipantsUpdate( state: UserProfileState, // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/src/App/UserProfile/types.ts b/src/App/UserProfile/types.ts index 7e77045..a59c5cf 100644 --- a/src/App/UserProfile/types.ts +++ b/src/App/UserProfile/types.ts @@ -16,6 +16,7 @@ export interface UserProfile { export interface UserProfileState { userProfile: UserProfile | null; userProfileError: string | null; + userProfileRolesError: string | null; isUserProfileRequestPending: boolean; showChangeRolesModal: boolean; showChangeParticipantsModal: boolean; diff --git a/src/App/UserProfile/views.tsx b/src/App/UserProfile/views.tsx index 7a1227f..8c2c262 100644 --- a/src/App/UserProfile/views.tsx +++ b/src/App/UserProfile/views.tsx @@ -37,6 +37,7 @@ const participantColumns = [ function UserProfile({ userProfile, userProfileError, + userProfileRolesError, isUserProfileRequestPending, showChangeRolesModal, showParticipantsRolesModal, @@ -92,6 +93,15 @@ function UserProfile({ }); }); + let userProfileRolesErrorContent = null; + if (userProfileRolesError) { + userProfileRolesErrorContent = ( + + Error updating the user roles: {userProfileRolesError} + + ); + } + content = (
{userProfile!.username} @@ -107,6 +117,7 @@ function UserProfile({ /> + {userProfileRolesErrorContent}
Participant Companies