Skip to content

Commit

Permalink
handle undefined conditions for display user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavanakarwade committed Dec 11, 2024
1 parent 62da48b commit 76f5026
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/Profile/DisplayUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ const DisplayUser = () => {
const getUserDetails = async () => {
const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE)
const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES)

if (orgRoles) {
userProfile.roles = orgRoles;
setUserObj(userProfile);
} else {
console.error('');
}
}

useEffect(() => {
const fetchData = async () => {
await getUserDetails();
Expand Down Expand Up @@ -46,7 +52,7 @@ const DisplayUser = () => {
className="text-base font-medium text-gray-900 truncate dark:text-gray-300"
role="none"
>
{TextTittlecase(userObj['roles'])}
{TextTittlecase(userObj?.['roles'])}
</p>
</>
}
Expand Down

0 comments on commit 76f5026

Please sign in to comment.