Skip to content

Commit

Permalink
Removed: unused check for facility when fetching user profile as now …
Browse files Browse the repository at this point in the history
…we fetch the facilities of the users separately and also improved the reject statement from login flow to display correct message in the UI(#232)
  • Loading branch information
ymaheshwari1 committed Dec 19, 2023
1 parent c1e0c12 commit 0078fb6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ const getUserProfile = async (token: any): Promise<any> => {
'Content-Type': 'application/json'
}
});
if(hasError(resp)) return Promise.reject("Error getting user profile: " + JSON.stringify(resp.data));
if(resp.data.facilities.length === 0 ) return Promise.reject("User is not associated with any facility: " + JSON.stringify(resp.data));
if(hasError(resp)) return Promise.reject("Error getting user profile");
return Promise.resolve(resp.data)
} catch(error: any) {
return Promise.reject(error)
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ const actions: ActionTree<UserState, RootState> = {
// TODO Check if handling of specific status codes is required.
showToast(translate('Something went wrong while login. Please contact administrator'));
console.error("error", err);
return Promise.reject(new Error(err))
// Added ternary check for serverResponse as in to correctly display the message on UI, need to remove this once all the service reject in same format
return Promise.reject(new Error(err?.serverResponse ? err.serverResponse : err))
}
},

Expand Down

0 comments on commit 0078fb6

Please sign in to comment.